@@ -119,30 +119,33 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin {
119
119
compressedCount = 0
120
120
} ,
121
121
122
- renderChunk ( code , chunk ) {
123
- for ( const id of chunk . moduleIds ) {
124
- const module = this . getModuleInfo ( id )
125
- if ( ! module ) continue
126
- // When a dynamic importer shares a chunk with the imported module,
127
- // warn that the dynamic imported module will not be moved to another chunk (#12850).
128
- if ( module . importers . length && module . dynamicImporters . length ) {
129
- // Filter out the intersection of dynamic importers and sibling modules in
130
- // the same chunk. The intersecting dynamic importers' dynamic import is not
131
- // expected to work. Note we're only detecting the direct ineffective
132
- // dynamic import here.
133
- const detectedIneffectiveDynamicImport = module . dynamicImporters . some (
134
- ( id ) => ! isInNodeModules ( id ) && chunk . moduleIds . includes ( id ) ,
135
- )
136
- if ( detectedIneffectiveDynamicImport ) {
137
- this . warn (
138
- `\n(!) ${
139
- module . id
140
- } is dynamically imported by ${ module . dynamicImporters . join (
141
- ', ' ,
142
- ) } but also statically imported by ${ module . importers . join (
143
- ', ' ,
144
- ) } , dynamic import will not move module into another chunk.\n`,
145
- )
122
+ renderChunk ( code , chunk , options ) {
123
+ if ( ! options . inlineDynamicImports ) {
124
+ for ( const id of chunk . moduleIds ) {
125
+ const module = this . getModuleInfo ( id )
126
+ if ( ! module ) continue
127
+ // When a dynamic importer shares a chunk with the imported module,
128
+ // warn that the dynamic imported module will not be moved to another chunk (#12850).
129
+ if ( module . importers . length && module . dynamicImporters . length ) {
130
+ // Filter out the intersection of dynamic importers and sibling modules in
131
+ // the same chunk. The intersecting dynamic importers' dynamic import is not
132
+ // expected to work. Note we're only detecting the direct ineffective
133
+ // dynamic import here.
134
+ const detectedIneffectiveDynamicImport =
135
+ module . dynamicImporters . some (
136
+ ( id ) => ! isInNodeModules ( id ) && chunk . moduleIds . includes ( id ) ,
137
+ )
138
+ if ( detectedIneffectiveDynamicImport ) {
139
+ this . warn (
140
+ `\n(!) ${
141
+ module . id
142
+ } is dynamically imported by ${ module . dynamicImporters . join (
143
+ ', ' ,
144
+ ) } but also statically imported by ${ module . importers . join (
145
+ ', ' ,
146
+ ) } , dynamic import will not move module into another chunk.\n`,
147
+ )
148
+ }
146
149
}
147
150
}
148
151
}
0 commit comments