mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
fix(nuxt): add import protection for nuxt/*
exports (#23357)
This commit is contained in:
parent
3b90f82f8d
commit
e900190278
@ -19,7 +19,7 @@ export const vueAppPatterns = (nuxt: Nuxt) => [
|
|||||||
[/(^|node_modules\/)@vue\/composition-api/],
|
[/(^|node_modules\/)@vue\/composition-api/],
|
||||||
...nuxt.options.modules.filter(m => typeof m === 'string').map((m: any) =>
|
...nuxt.options.modules.filter(m => typeof m === 'string').map((m: any) =>
|
||||||
[new RegExp(`^${escapeRE(m as string)}$`), 'Importing directly from module entry points is not allowed.']),
|
[new RegExp(`^${escapeRE(m as string)}$`), 'Importing directly from module entry points is not allowed.']),
|
||||||
...[/(^|node_modules\/)@nuxt\/kit/, /^nitropack/]
|
...[/(^|node_modules\/)@nuxt\/kit/, /(^|node_modules\/)nuxt\/(config|kit|schema)/, /^nitropack/]
|
||||||
.map(i => [i, 'This module cannot be imported in the Vue part of your app.']),
|
.map(i => [i, 'This module cannot be imported in the Vue part of your app.']),
|
||||||
[new RegExp(escapeRE(join(nuxt.options.srcDir, (nuxt.options.dir as any).server || 'server')) + '\\/(api|routes|middleware|plugins)\\/'), 'Importing from server is not allowed in the Vue part of your app.']
|
[new RegExp(escapeRE(join(nuxt.options.srcDir, (nuxt.options.dir as any).server || 'server')) + '\\/(api|routes|middleware|plugins)\\/'), 'Importing from server is not allowed in the Vue part of your app.']
|
||||||
] as ImportProtectionOptions['patterns']
|
] as ImportProtectionOptions['patterns']
|
||||||
|
@ -14,6 +14,9 @@ const testsToTriggerOn = [
|
|||||||
['/root/node_modules/@vue/composition-api', 'components/Component.vue', true],
|
['/root/node_modules/@vue/composition-api', 'components/Component.vue', true],
|
||||||
['@vue/composition-api', 'components/Component.vue', true],
|
['@vue/composition-api', 'components/Component.vue', true],
|
||||||
['@nuxt/kit', 'components/Component.vue', true],
|
['@nuxt/kit', 'components/Component.vue', true],
|
||||||
|
['nuxt/config', 'components/Component.vue', true],
|
||||||
|
['nuxt/kit', 'components/Component.vue', true],
|
||||||
|
['nuxt/schema', 'components/Component.vue', true],
|
||||||
['/root/node_modules/@nuxt/kit', 'components/Component.vue', true],
|
['/root/node_modules/@nuxt/kit', 'components/Component.vue', true],
|
||||||
['some-nuxt-module', 'components/Component.vue', true],
|
['some-nuxt-module', 'components/Component.vue', true],
|
||||||
['/root/src/server/api/test.ts', 'components/Component.vue', true],
|
['/root/src/server/api/test.ts', 'components/Component.vue', true],
|
||||||
|
Loading…
Reference in New Issue
Block a user