mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
fix(nuxt3): don't restrict nitro/nuxt3 runtime components (#2885)
This commit is contained in:
parent
03cc1913a3
commit
81ee59ce0c
@ -14,14 +14,14 @@ interface ImportProtectionOptions {
|
||||
const escapeRE = (str: string) => str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
|
||||
|
||||
export const vueAppPatterns = (nuxt: Nuxt) => [
|
||||
[/(^|node_modules\/)(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) =>
|
||||
[new RegExp(`^${escapeRE(m)}$`), 'Importing directly from module entrypoints is not allowed.']),
|
||||
...['#static-assets', '#static', '#config', '#assets', '#storage', '#server-middleware']
|
||||
.map(i => [i, 'Nitro aliases cannot be imported in the Vue part of your app.']),
|
||||
...[/(^|node_modules\/)@nuxt\/kit/, /(^|node_modules\/)@nuxt\/nitro/]
|
||||
...[/(^|node_modules\/)@nuxt\/kit/, /^@nuxt\/nitro/]
|
||||
.map(i => [i, 'This module cannot be imported in the Vue part of your app.']),
|
||||
[new RegExp(escapeRE(resolve(nuxt.options.srcDir, (nuxt.options.dir as any).server || 'server'))), 'Importing from server middleware is not allowed in the Vue part of your app.']
|
||||
] as ImportProtectionOptions['patterns']
|
||||
|
Loading…
Reference in New Issue
Block a user