From 81ee59ce0c07a00279a18ec6c87b742b8540f6b0 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 24 Jan 2022 14:32:08 +0000 Subject: [PATCH] fix(nuxt3): don't restrict nitro/nuxt3 runtime components (#2885) --- packages/nuxt3/src/core/plugins/import-protection.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nuxt3/src/core/plugins/import-protection.ts b/packages/nuxt3/src/core/plugins/import-protection.ts index 0d2bfa6991..d6ff6446d1 100644 --- a/packages/nuxt3/src/core/plugins/import-protection.ts +++ b/packages/nuxt3/src/core/plugins/import-protection.ts @@ -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']