feat(nuxt3): expose /app export paths (#3323)

This commit is contained in:
Daniel Roe 2022-02-18 18:26:43 +00:00 committed by GitHub
parent 22c3e33c1e
commit 70542a3af7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 26 additions and 8 deletions

View File

@ -10,6 +10,8 @@ export function setupAppBridge (_options: any) {
// Setup aliases // Setup aliases
nuxt.options.alias['#app'] = resolve(distDir, 'runtime/index.mjs') nuxt.options.alias['#app'] = resolve(distDir, 'runtime/index.mjs')
nuxt.options.alias['nuxt3/app'] = nuxt.options.alias['#app']
nuxt.options.alias['nuxt/app'] = nuxt.options.alias['#app']
nuxt.options.alias['#build'] = nuxt.options.buildDir nuxt.options.alias['#build'] = nuxt.options.buildDir
// Mock `bundleBuilder.build` to support `nuxi prepare` // Mock `bundleBuilder.build` to support `nuxi prepare`

1
packages/nuxt3/app.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export * from './dist/app'

View File

@ -10,7 +10,18 @@
"nuxi": "./bin/nuxt.mjs", "nuxi": "./bin/nuxt.mjs",
"nuxt": "./bin/nuxt.mjs" "nuxt": "./bin/nuxt.mjs"
}, },
"exports": {
".": "./dist/index.mjs",
"./app": "./dist/app/index.mjs",
"./package.json": "./package.json"
},
"imports": {
"#app": "./dist/app/index.mjs",
"#meta": "./dist/meta/runtime/index.mjs",
"#pages": "./dist/pages/runtime/index.mjs"
},
"files": [ "files": [
"app.d.ts",
"bin", "bin",
"types.d.ts", "types.d.ts",
"dist" "dist"

View File

@ -1,5 +1,12 @@
/// <reference path="types/augments.d.ts" />
export * from './nuxt' export * from './nuxt'
export * from './composables' export * from './composables'
// eslint-disable-next-line import/no-restricted-paths
export type { PageMeta } from '../pages/runtime'
// eslint-disable-next-line import/no-restricted-paths
export type { MetaObject } from '../meta/runtime'
export { useMeta } from '#meta'
export const isVue2 = false export const isVue2 = false
export const isVue3 = true export const isVue3 = true

View File

@ -1,3 +0,0 @@
import './augments'
export * from '../index'

View File

@ -13,7 +13,7 @@ interface ImportProtectionOptions {
} }
export const vueAppPatterns = (nuxt: Nuxt) => [ export const vueAppPatterns = (nuxt: Nuxt) => [
[/^(nuxt3|nuxt)/, '`nuxt3`/`nuxt` cannot be imported directly. Instead, import runtime Nuxt composables from `#app` or `#imports`.'], [/^(nuxt3|nuxt)$/, '`nuxt3`/`nuxt` cannot be imported directly. Instead, import runtime Nuxt composables from `#app` or `#imports`.'],
[/nuxt\.config/, 'Importing directly from a `nuxt.config` file is not allowed. Instead, use runtime config or a module.'], [/nuxt\.config/, 'Importing directly from a `nuxt.config` file is not allowed. Instead, use runtime config or a module.'],
[/(^|node_modules\/)@vue\/composition-api/], [/(^|node_modules\/)@vue\/composition-api/],
...nuxt.options.modules.filter(m => typeof m === 'string').map((m: string) => ...nuxt.options.modules.filter(m => typeof m === 'string').map((m: string) =>

View File

@ -1,6 +1,6 @@
import { createApp } from 'vue' import { createApp } from 'vue'
import { createMetaManager } from 'vue-meta' import { createMetaManager } from 'vue-meta'
import type { MetaObject } from '../types' import type { MetaObject } from '..'
import { defineNuxtPlugin } from '#app' import { defineNuxtPlugin } from '#app'
export default defineNuxtPlugin((nuxtApp) => { export default defineNuxtPlugin((nuxtApp) => {

View File

@ -0,0 +1 @@
export * from './composables'

View File

@ -1,3 +1,2 @@
import type { } from '@nuxt/nitro' import type { } from '@nuxt/nitro'
export * from './dist/index' export * from './dist/index'
export * from './dist/app/types/index'

View File

@ -46,8 +46,7 @@ export async function buildServer (ctx: ViteBuildContext) {
/\.(es|esm|esm-browser|esm-bundler).js$/, /\.(es|esm|esm-browser|esm-bundler).js$/,
'/__vue-jsx', '/__vue-jsx',
'#app', '#app',
/nuxt3\/dist/, 'nuxt3',
/nuxt3\/src/,
/@nuxt\/nitro\/dist/, /@nuxt\/nitro\/dist/,
/@nuxt\/nitro\/src/ /@nuxt\/nitro\/src/
] ]

View File

@ -38,6 +38,7 @@ function serverStandalone (ctx: WebpackConfigContext) {
const inline = [ const inline = [
'src/', 'src/',
'#app', '#app',
'nuxt3',
'!', '!',
'-!', '-!',
'~', '~',