Skip to content

Commit

Permalink
feat(nuxt3): expose /app export paths (nuxt#3323)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored Feb 18, 2022
1 parent 22c3e33 commit 70542a3
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 8 deletions.
2 changes: 2 additions & 0 deletions packages/bridge/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export function setupAppBridge (_options: any) {

// Setup aliases
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

// Mock `bundleBuilder.build` to support `nuxi prepare`
Expand Down
1 change: 1 addition & 0 deletions packages/nuxt3/app.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './dist/app'
11 changes: 11 additions & 0 deletions packages/nuxt3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@
"nuxi": "./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": [
"app.d.ts",
"bin",
"types.d.ts",
"dist"
Expand Down
7 changes: 7 additions & 0 deletions packages/nuxt3/src/app/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
/// <reference path="types/augments.d.ts" />

export * from './nuxt'
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 isVue3 = true
File renamed without changes.
3 changes: 0 additions & 3 deletions packages/nuxt3/src/app/types/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/nuxt3/src/core/plugins/import-protection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface ImportProtectionOptions {
}

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.'],
[/(^|node_modules\/)@vue\/composition-api/],
...nuxt.options.modules.filter(m => typeof m === 'string').map((m: string) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt3/src/meta/runtime/lib/vue-meta.plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createApp } from 'vue'
import { createMetaManager } from 'vue-meta'
import type { MetaObject } from '../types'
import type { MetaObject } from '..'
import { defineNuxtPlugin } from '#app'

export default defineNuxtPlugin((nuxtApp) => {
Expand Down
1 change: 1 addition & 0 deletions packages/nuxt3/src/pages/runtime/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './composables'
1 change: 0 additions & 1 deletion packages/nuxt3/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
import type { } from '@nuxt/nitro'
export * from './dist/index'
export * from './dist/app/types/index'
3 changes: 1 addition & 2 deletions packages/vite/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ export async function buildServer (ctx: ViteBuildContext) {
/\.(es|esm|esm-browser|esm-bundler).js$/,
'/__vue-jsx',
'#app',
/nuxt3\/dist/,
/nuxt3\/src/,
'nuxt3',
/@nuxt\/nitro\/dist/,
/@nuxt\/nitro\/src/
]
Expand Down
1 change: 1 addition & 0 deletions packages/webpack/src/configs/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function serverStandalone (ctx: WebpackConfigContext) {
const inline = [
'src/',
'#app',
'nuxt3',
'!',
'-!',
'~',
Expand Down

0 comments on commit 70542a3

Please sign in to comment.