mirror of https://github.com/webpack/webpack.git
fix: mangle destruction incorrect with export named default
This commit is contained in:
commit
71ce863569
|
|
@ -343,7 +343,27 @@ HarmonyImportSpecifierDependency.Template = class HarmonyImportSpecifierDependen
|
|||
}
|
||||
|
||||
if (dep.referencedPropertiesInDestructuring) {
|
||||
const prefixedIds = ids[0] === "default" ? ids.slice(1) : ids;
|
||||
let prefixedIds = ids;
|
||||
|
||||
if (ids[0] === "default") {
|
||||
const selfModule = moduleGraph.getParentModule(dep);
|
||||
const importedModule =
|
||||
/** @type {Module} */
|
||||
(moduleGraph.getModule(dep));
|
||||
const exportsType = importedModule.getExportsType(
|
||||
moduleGraph,
|
||||
/** @type {BuildMeta} */
|
||||
(selfModule.buildMeta).strictHarmonyModule
|
||||
);
|
||||
if (
|
||||
(exportsType === "default-only" ||
|
||||
exportsType === "default-with-named") &&
|
||||
ids.length >= 1
|
||||
) {
|
||||
prefixedIds = ids.slice(1);
|
||||
}
|
||||
}
|
||||
|
||||
for (const {
|
||||
id,
|
||||
shorthand,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
import namespace from "./re-exports";
|
||||
|
||||
it("should mangle exports imported", () => {
|
||||
const { foo } = namespace;
|
||||
expect(foo).toBe('foo')
|
||||
});
|
||||
|
|
@ -0,0 +1 @@
|
|||
export const foo = 'foo';
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
import * as namespace from './module';
|
||||
|
||||
export { namespace as default };
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
optimization: {
|
||||
mangleExports: true,
|
||||
usedExports: true,
|
||||
providedExports: true,
|
||||
sideEffects: false // disable reexports optimization
|
||||
}
|
||||
};
|
||||
Loading…
Reference in New Issue