Skip to content

Commit

Permalink
Merge pull request webpack#15760 from IronLu233/main
Browse files Browse the repository at this point in the history
Fix `return"field"in Module` evaluated as `returntrue` webpack#15759
  • Loading branch information
sokra authored May 10, 2022
2 parents 08ecfbb + 2d661fa commit dea44b6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ HarmonyEvaluatedImportSpecifierDependency.Template = class HarmonyEvaluatedImpor
}

if (typeof value === "boolean") {
source.replace(dep.range[0], dep.range[1] - 1, `${value}`);
source.replace(dep.range[0], dep.range[1] - 1, ` ${value}`);
} else {
const usedName = exportsInfo.getUsedName(ids, runtime);

Expand Down
11 changes: 10 additions & 1 deletion test/cases/parsing/harmony-export-import-specifier/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { b1, usedB1, usedB2, usedB3, usedB4 } from "./b.js";
import { usedE1, usedE2 } from "./e.js";
import { h } from "./h.js";
import * as m from "./m";
import {object as obj} from "./m";
import { object as obj } from "./m";
import cjs from "./cjs2";
import * as o from "./o";
import * as p from "./p";
Expand Down Expand Up @@ -79,3 +79,12 @@ it("should handle 'm in n' case", () => {
expect(m.canMangleA).toBe(true);
}
});

it("issue-15759", () => {
function foo() {
// PLEASE CONFIRM there is no space after return
// prettier-ignore
return"usedA"in m;
}
expect(foo.call()).toBe(true);
});

0 comments on commit dea44b6

Please sign in to comment.