Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve and fix cross-chunk-reexport warning (#4829)
* Improve and fix cross-chunk-reexport warning * Show warning also for namespace imports
- Loading branch information
1 parent
7c50c18
commit ef25721
Showing
14 changed files
with
175 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
test/function/samples/circular-namespace-reexport-manual-chunks/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
const path = require('node:path'); | ||
|
||
const ID_INDEX = path.join(__dirname, 'index.js'); | ||
const ID_TYPES = path.join(__dirname, 'types.js'); | ||
const ID_FORMATTERS = path.join(__dirname, 'formatters.js'); | ||
const ID_MAIN = path.join(__dirname, 'main.js'); | ||
|
||
module.exports = { | ||
description: | ||
'correctly handles namespace reexports with circular dependencies when using manual chunks', | ||
options: { | ||
output: { | ||
manualChunks(id) { | ||
return path.basename(id); | ||
} | ||
} | ||
}, | ||
warnings: [ | ||
{ | ||
code: 'CIRCULAR_DEPENDENCY', | ||
ids: [ID_INDEX, ID_TYPES, ID_INDEX], | ||
message: 'Circular dependency: index.js -> types.js -> index.js' | ||
}, | ||
{ | ||
code: 'CIRCULAR_DEPENDENCY', | ||
ids: [ID_INDEX, ID_FORMATTERS, ID_INDEX], | ||
message: 'Circular dependency: index.js -> formatters.js -> index.js' | ||
}, | ||
{ | ||
code: 'CYCLIC_CROSS_CHUNK_REEXPORT', | ||
exporter: ID_TYPES, | ||
id: ID_FORMATTERS, | ||
message: | ||
'Export "LANGUAGES" of module "types.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 "formatters.js" to point directly to the exporting module or reconfigure "output.manualChunks" 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 reconfigure "output.manualChunks" 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 reconfigure "output.manualChunks" 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 reconfigure "output.manualChunks" to ensure these modules end up in the same chunk.', | ||
reexporter: ID_INDEX | ||
}, | ||
{ | ||
code: 'EMPTY_BUNDLE', | ||
message: 'Generated an empty chunk: "index.js".', | ||
names: ['index.js'] | ||
} | ||
] | ||
}; |
3 changes: 3 additions & 0 deletions
3
test/function/samples/circular-namespace-reexport-manual-chunks/formatters.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { LANGUAGES } from './index.js'; | ||
|
||
export const format = () => LANGUAGES; |
2 changes: 2 additions & 0 deletions
2
test/function/samples/circular-namespace-reexport-manual-chunks/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { LANGUAGES } from './types.js'; | ||
export * as formatters from './formatters.js'; |
2 changes: 2 additions & 0 deletions
2
test/function/samples/circular-namespace-reexport-manual-chunks/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import { formatters } from './index.js' | ||
export default formatters; |
2 changes: 2 additions & 0 deletions
2
test/function/samples/circular-namespace-reexport-manual-chunks/types.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import { formatters } from './index.js' | ||
export const LANGUAGES = () => formatters; |
60 changes: 60 additions & 0 deletions
60
test/function/samples/circular-namespace-reexport-preserve-modules/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const path = require('node:path'); | ||
|
||
const ID_INDEX = path.join(__dirname, 'index.js'); | ||
const ID_TYPES = path.join(__dirname, 'types.js'); | ||
const ID_FORMATTERS = path.join(__dirname, 'formatters.js'); | ||
const ID_MAIN = path.join(__dirname, 'main.js'); | ||
|
||
module.exports = { | ||
description: | ||
'correctly handles namespace reexports with circular dependencies when preserving modules', | ||
options: { | ||
output: { | ||
preserveModules: true | ||
} | ||
}, | ||
warnings: [ | ||
{ | ||
code: 'CIRCULAR_DEPENDENCY', | ||
ids: [ID_INDEX, ID_TYPES, ID_INDEX], | ||
message: 'Circular dependency: index.js -> types.js -> index.js' | ||
}, | ||
{ | ||
code: 'CIRCULAR_DEPENDENCY', | ||
ids: [ID_INDEX, ID_FORMATTERS, ID_INDEX], | ||
message: 'Circular dependency: index.js -> formatters.js -> index.js' | ||
}, | ||
{ | ||
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_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, | ||
id: ID_FORMATTERS, | ||
message: | ||
'Export "LANGUAGES" of module "types.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 "formatters.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 | ||
} | ||
] | ||
}; |
3 changes: 3 additions & 0 deletions
3
test/function/samples/circular-namespace-reexport-preserve-modules/formatters.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { LANGUAGES } from './index.js'; | ||
|
||
export const format = () => LANGUAGES; |
2 changes: 2 additions & 0 deletions
2
test/function/samples/circular-namespace-reexport-preserve-modules/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { LANGUAGES } from './types.js'; | ||
export * as formatters from './formatters.js'; |
2 changes: 2 additions & 0 deletions
2
test/function/samples/circular-namespace-reexport-preserve-modules/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import { formatters } from './index.js' | ||
export default formatters; |
2 changes: 2 additions & 0 deletions
2
test/function/samples/circular-namespace-reexport-preserve-modules/types.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import { formatters } from './index.js' | ||
export const LANGUAGES = () => formatters; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters