This repository was archived by the owner on Apr 6, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -112,7 +112,8 @@ export async function initNitro (nuxt: Nuxt) {
112112 patterns : [
113113 ...[ '#app' , / ^ # b u i l d ( \/ | $ ) / ]
114114 . map ( p => [ p , 'Vue app aliases are not allowed in server routes.' ] ) as [ RegExp | string , string ] [ ]
115- ]
115+ ] ,
116+ exclude : [ / c o r e [ \\ / ] r u n t i m e [ \\ / ] n i t r o [ \\ / ] r e n d e r e r / ]
116117 } ) )
117118
118119 // Extend nitro config with hook
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ const _require = createRequire(import.meta.url)
1010interface ImportProtectionOptions {
1111 rootDir : string
1212 patterns : [ importPattern : string | RegExp , warning ?: string ] [ ]
13+ exclude ?: Array < RegExp | string >
1314}
1415
1516export const vueAppPatterns = ( nuxt : Nuxt ) => [
@@ -25,10 +26,13 @@ export const vueAppPatterns = (nuxt: Nuxt) => [
2526
2627export const ImportProtectionPlugin = createUnplugin ( function ( options : ImportProtectionOptions ) {
2728 const cache : Record < string , Map < string | RegExp , boolean > > = { }
29+ const importersToExclude = options ?. exclude || [ ]
2830 return {
2931 name : 'nuxt:import-protection' ,
3032 enforce : 'pre' ,
3133 resolveId ( id , importer ) {
34+ if ( importersToExclude . some ( p => typeof p === 'string' ? importer === p : p . test ( importer ) ) ) { return }
35+
3236 const invalidImports = options . patterns . filter ( ( [ pattern ] ) => pattern instanceof RegExp ? pattern . test ( id ) : pattern === id )
3337 let matched : boolean
3438 for ( const match of invalidImports ) {
You can’t perform that action at this time.
0 commit comments