Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix crash when using inlineDynamicImports with no-treeshake (#4104)
- Loading branch information
1 parent
df3b2a5
commit 27d560e
Showing
4 changed files
with
40 additions
and
8 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
29 changes: 29 additions & 0 deletions
29
test/function/samples/inline-dynamic-no-treeshake/_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,29 @@ | ||
const MAGIC_ENTRY = 'main'; | ||
|
||
module.exports = { | ||
description: 'handles inlining dynamic imports when treeshaking is disabled for modules (#4098)', | ||
options: { | ||
input: MAGIC_ENTRY, | ||
output: { | ||
inlineDynamicImports: true | ||
}, | ||
plugins: [ | ||
{ | ||
name: 'magic-modules', | ||
buildStart() { | ||
this.emitFile({ type: 'chunk', id: './dep.js' }); | ||
}, | ||
async resolveId(source) { | ||
if (source === MAGIC_ENTRY) { | ||
return { id: source, moduleSideEffects: 'no-treeshake' }; | ||
} | ||
return null; | ||
}, | ||
async load(id) { | ||
if (id !== MAGIC_ENTRY) return null; | ||
return `import {foo} from './reexport.js';assert.strictEqual(foo, 1);`; | ||
} | ||
} | ||
] | ||
} | ||
}; |
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 @@ | ||
export const foo = 1; |
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 @@ | ||
export * from './dep.js'; |