Skip to content

Commit

Permalink
Show warning also for namespace imports
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Feb 1, 2023
1 parent 95aa3b1 commit e440b4d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Chunk.ts
Expand Up @@ -1378,12 +1378,13 @@ export default class Chunk {
const chunk = this.chunkByModule.get(variable.module as Module);
if (chunk !== this) {
this.imports.add(variable);
if (
!(variable instanceof NamespaceVariable && this.outputOptions.preserveModules) &&
variable.module instanceof Module
) {
chunk!.exports.add(variable);
if (variable.module instanceof Module) {
this.checkCircularDependencyImport(variable, module);
// When preserving modules, we do not create namespace objects but directly
// use the actual namespaces, which would be broken by this logic.
if (!(variable instanceof NamespaceVariable && this.outputOptions.preserveModules)) {
chunk!.exports.add(variable);
}
}
}
}
Expand Down
Expand Up @@ -32,6 +32,22 @@ module.exports = {
'Export "*" of module "formatters.js" was reexported through module "index.js" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in "main.js" to point directly to the exporting module or do not use "output.preserveModules" to ensure these modules end up in the same chunk.',
reexporter: ID_INDEX
},
{
code: 'CYCLIC_CROSS_CHUNK_REEXPORT',
exporter: ID_FORMATTERS,
id: ID_MAIN,
message:
'Export "*" of module "formatters.js" was reexported through module "index.js" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in "main.js" to point directly to the exporting module or do not use "output.preserveModules" to ensure these modules end up in the same chunk.',
reexporter: ID_INDEX
},
{
code: 'CYCLIC_CROSS_CHUNK_REEXPORT',
exporter: ID_FORMATTERS,
id: ID_TYPES,
message:
'Export "*" of module "formatters.js" was reexported through module "index.js" while both modules are dependencies of each other and will end up in different chunks by current Rollup settings. This scenario is not well supported at the moment as it will produce a circular dependency between chunks and will likely lead to broken execution order.\nEither change the import in "types.js" to point directly to the exporting module or do not use "output.preserveModules" to ensure these modules end up in the same chunk.',
reexporter: ID_INDEX
},
{
code: 'CYCLIC_CROSS_CHUNK_REEXPORT',
exporter: ID_TYPES,
Expand Down

0 comments on commit e440b4d

Please sign in to comment.