@@ -553,42 +553,46 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
553
553
// for pre-transforming
554
554
staticImportedUrls . add ( { url : urlWithoutBase , id : resolvedId } )
555
555
}
556
- } else if ( ! importer . startsWith ( clientDir ) && ! ssr ) {
557
- // check @vite -ignore which suppresses dynamic import warning
558
- const hasViteIgnore = / \/ \* \s * @ v i t e - i g n o r e \s * \* \/ / . test (
559
- // complete expression inside parens
560
- source . slice ( dynamicIndex + 1 , end )
561
- )
562
-
563
- const url = rawUrl
564
- . replace ( / \/ \* [ \s \S ] * ?\* \/ | ( [ ^ \\ : ] | ^ ) \/ \/ .* $ / gm, '' )
565
- . trim ( )
566
- if ( ! hasViteIgnore ) {
567
- this . warn (
568
- `\n` +
569
- colors . cyan ( importerModule . file ) +
570
- `\n` +
571
- generateCodeFrame ( source , start ) +
572
- `\nThe above dynamic import cannot be analyzed by vite.\n` +
573
- `See ${ colors . blue (
574
- `https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations`
575
- ) } ` +
576
- `for supported dynamic import formats. ` +
577
- `If this is intended to be left as-is, you can use the ` +
578
- `/* @vite-ignore */ comment inside the import() call to suppress this warning.\n`
556
+ } else if ( ! importer . startsWith ( clientDir ) ) {
557
+ if ( ! importer . includes ( 'node_modules' ) ) {
558
+ // check @vite -ignore which suppresses dynamic import warning
559
+ const hasViteIgnore = / \/ \* \s * @ v i t e - i g n o r e \s * \* \/ / . test (
560
+ // complete expression inside parens
561
+ source . slice ( dynamicIndex + 1 , end )
579
562
)
563
+ if ( ! hasViteIgnore ) {
564
+ this . warn (
565
+ `\n` +
566
+ colors . cyan ( importerModule . file ) +
567
+ `\n` +
568
+ generateCodeFrame ( source , start ) +
569
+ `\nThe above dynamic import cannot be analyzed by Vite.\n` +
570
+ `See ${ colors . blue (
571
+ `https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations`
572
+ ) } ` +
573
+ `for supported dynamic import formats. ` +
574
+ `If this is intended to be left as-is, you can use the ` +
575
+ `/* @vite-ignore */ comment inside the import() call to suppress this warning.\n`
576
+ )
577
+ }
580
578
}
581
- if (
582
- ! / ^ ( ' .* ' | " .* " | ` .* ` ) $ / . test ( url ) ||
583
- isExplicitImportRequired ( url . slice ( 1 , - 1 ) )
584
- ) {
585
- needQueryInjectHelper = true
586
- str ( ) . overwrite (
587
- start ,
588
- end ,
589
- `__vite__injectQuery(${ url } , 'import')` ,
590
- { contentOnly : true }
591
- )
579
+
580
+ if ( ! ssr ) {
581
+ const url = rawUrl
582
+ . replace ( / \/ \* [ \s \S ] * ?\* \/ | ( [ ^ \\ : ] | ^ ) \/ \/ .* $ / gm, '' )
583
+ . trim ( )
584
+ if (
585
+ ! / ^ ( ' .* ' | " .* " | ` .* ` ) $ / . test ( url ) ||
586
+ isExplicitImportRequired ( url . slice ( 1 , - 1 ) )
587
+ ) {
588
+ needQueryInjectHelper = true
589
+ str ( ) . overwrite (
590
+ start ,
591
+ end ,
592
+ `__vite__injectQuery(${ url } , 'import')` ,
593
+ { contentOnly : true }
594
+ )
595
+ }
592
596
}
593
597
}
594
598
}
0 commit comments