Skip to content

Commit 30d47e5

Browse files
committed
chore: disable dynamic import warning at dev build
1 parent ba1d974 commit 30d47e5

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

packages/vite/src/node/plugins/reporter.ts

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -298,37 +298,37 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin {
298298
},
299299

300300
renderChunk(_, chunk, options) {
301-
if (!options.inlineDynamicImports) {
302-
for (const id of chunk.moduleIds) {
303-
const module = this.getModuleInfo(id)
304-
if (!module) continue
305-
// When a dynamic importer shares a chunk with the imported module,
306-
// warn that the dynamic imported module will not be moved to another chunk (#12850).
307-
if (module.importers.length && module.dynamicImporters.length) {
308-
// Filter out the intersection of dynamic importers and sibling modules in
309-
// the same chunk. The intersecting dynamic importers' dynamic import is not
310-
// expected to work. Note we're only detecting the direct ineffective
311-
// dynamic import here.
312-
const detectedIneffectiveDynamicImport =
313-
module.dynamicImporters.some(
314-
(id) => !isInNodeModules(id) && chunk.moduleIds.includes(id),
315-
)
316-
if (detectedIneffectiveDynamicImport) {
317-
this.warn(
318-
`\n(!) ${
319-
module.id
320-
} is dynamically imported by ${module.dynamicImporters.join(
321-
', ',
322-
)} but also statically imported by ${module.importers.join(
323-
', ',
324-
)}, dynamic import will not move module into another chunk.\n`,
325-
)
301+
if (config.command === 'build' && !config.experimental.fullBundleMode) {
302+
if (!options.inlineDynamicImports) {
303+
for (const id of chunk.moduleIds) {
304+
const module = this.getModuleInfo(id)
305+
if (!module) continue
306+
// When a dynamic importer shares a chunk with the imported module,
307+
// warn that the dynamic imported module will not be moved to another chunk (#12850).
308+
if (module.importers.length && module.dynamicImporters.length) {
309+
// Filter out the intersection of dynamic importers and sibling modules in
310+
// the same chunk. The intersecting dynamic importers' dynamic import is not
311+
// expected to work. Note we're only detecting the direct ineffective
312+
// dynamic import here.
313+
const detectedIneffectiveDynamicImport =
314+
module.dynamicImporters.some(
315+
(id) => !isInNodeModules(id) && chunk.moduleIds.includes(id),
316+
)
317+
if (detectedIneffectiveDynamicImport) {
318+
this.warn(
319+
`\n(!) ${
320+
module.id
321+
} is dynamically imported by ${module.dynamicImporters.join(
322+
', ',
323+
)} but also statically imported by ${module.importers.join(
324+
', ',
325+
)}, dynamic import will not move module into another chunk.\n`,
326+
)
327+
}
326328
}
327329
}
328330
}
329-
}
330331

331-
if (config.command === 'build' && !config.experimental.fullBundleMode) {
332332
chunksReporter(this).register()
333333
}
334334
},

0 commit comments

Comments
 (0)