@@ -327,29 +327,6 @@ async function initNuxt (nuxt: Nuxt) {
327327 composables : nuxt . options . optimization . keyedComposables ,
328328 } ) )
329329
330- // shared folder import protection
331- const sharedDir = withTrailingSlash ( resolve ( nuxt . options . rootDir , nuxt . options . dir . shared ) )
332- const relativeSharedDir = withTrailingSlash ( relative ( nuxt . options . rootDir , resolve ( nuxt . options . rootDir , nuxt . options . dir . shared ) ) )
333- const sharedPatterns = [ / ^ # s h a r e d \/ / , new RegExp ( '^' + escapeRE ( sharedDir ) ) , new RegExp ( '^' + escapeRE ( relativeSharedDir ) ) ]
334- const sharedProtectionConfig = {
335- cwd : nuxt . options . rootDir ,
336- include : sharedPatterns ,
337- patterns : createImportProtectionPatterns ( nuxt , { context : 'shared' } ) ,
338- }
339- addVitePlugin ( ( ) => ImpoundPlugin . vite ( sharedProtectionConfig ) , { server : false } )
340- addWebpackPlugin ( ( ) => ImpoundPlugin . webpack ( sharedProtectionConfig ) , { server : false } )
341-
342- // Add import protection
343- const nuxtProtectionConfig = {
344- cwd : nuxt . options . rootDir ,
345- // Exclude top-level resolutions by plugins
346- exclude : [ relative ( nuxt . options . rootDir , join ( nuxt . options . srcDir , 'index.html' ) ) , ...sharedPatterns ] ,
347- patterns : createImportProtectionPatterns ( nuxt , { context : 'nuxt-app' } ) ,
348- }
349- addVitePlugin ( ( ) => Object . assign ( ImpoundPlugin . vite ( { ...nuxtProtectionConfig , error : false } ) , { name : 'nuxt:import-protection' } ) , { client : false } )
350- addVitePlugin ( ( ) => Object . assign ( ImpoundPlugin . vite ( { ...nuxtProtectionConfig , error : true } ) , { name : 'nuxt:import-protection' } ) , { server : false } )
351- addWebpackPlugin ( ( ) => ImpoundPlugin . webpack ( nuxtProtectionConfig ) )
352-
353330 // add resolver for modules used in virtual files
354331 addVitePlugin ( ( ) => ResolveDeepImportsPlugin ( nuxt ) )
355332
@@ -392,6 +369,29 @@ async function initNuxt (nuxt: Nuxt) {
392369 composables : nuxt . options . optimization . treeShake . composables . client ,
393370 } ) , { server : false } )
394371 }
372+
373+ // shared folder import protection
374+ const sharedDir = withTrailingSlash ( resolve ( nuxt . options . rootDir , nuxt . options . dir . shared ) )
375+ const relativeSharedDir = withTrailingSlash ( relative ( nuxt . options . rootDir , resolve ( nuxt . options . rootDir , nuxt . options . dir . shared ) ) )
376+ const sharedPatterns = [ / ^ # s h a r e d \/ / , new RegExp ( '^' + escapeRE ( sharedDir ) ) , new RegExp ( '^' + escapeRE ( relativeSharedDir ) ) ]
377+ const sharedProtectionConfig = {
378+ cwd : nuxt . options . rootDir ,
379+ include : sharedPatterns ,
380+ patterns : createImportProtectionPatterns ( nuxt , { context : 'shared' } ) ,
381+ }
382+ addVitePlugin ( ( ) => ImpoundPlugin . vite ( sharedProtectionConfig ) , { server : false } )
383+ addWebpackPlugin ( ( ) => ImpoundPlugin . webpack ( sharedProtectionConfig ) , { server : false } )
384+
385+ // Add import protection
386+ const nuxtProtectionConfig = {
387+ cwd : nuxt . options . rootDir ,
388+ // Exclude top-level resolutions by plugins
389+ exclude : [ relative ( nuxt . options . rootDir , join ( nuxt . options . srcDir , 'index.html' ) ) , ...sharedPatterns ] ,
390+ patterns : createImportProtectionPatterns ( nuxt , { context : 'nuxt-app' } ) ,
391+ }
392+ addVitePlugin ( ( ) => Object . assign ( ImpoundPlugin . vite ( { ...nuxtProtectionConfig , error : false } ) , { name : 'nuxt:import-protection' } ) , { client : false } )
393+ addVitePlugin ( ( ) => Object . assign ( ImpoundPlugin . vite ( { ...nuxtProtectionConfig , error : true } ) , { name : 'nuxt:import-protection' } ) , { server : false } )
394+ addWebpackPlugin ( ( ) => ImpoundPlugin . webpack ( nuxtProtectionConfig ) )
395395 } )
396396
397397 if ( ! nuxt . options . dev ) {
0 commit comments