Skip to content

Commit 4429658

Browse files
test(library): read the commonjs-static exports without matchAll
`String.prototype.matchAll` is newer than the Node baseline the harness executes a case under, so the assertion threw on the Node 10 job while passing everywhere else. An `exec` loop reads the same names.
1 parent 9c9c1b9 commit 4429658

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

‎test/configCases/library/entry-merge-exports-commonjs-static/webpack.config.js‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ function expectExportNames() {
1919
const handler = (compilation) => {
2020
compilation.hooks.afterProcessAssets.tap("testcase", (assets) => {
2121
const source = assets["main.js"].source().toString();
22-
const assigned = new Set(
23-
[...source.matchAll(/exports\.(\w+) = __webpack_exports__\./g)].map(
24-
([, name]) => name
25-
)
26-
);
22+
// `matchAll` is newer than the Node baseline the harness runs on.
23+
const regexp = /exports\.(\w+) = __webpack_exports__\./g;
24+
/** @type {Set<string>} */
25+
const assigned = new Set();
26+
let match;
27+
while ((match = regexp.exec(source)) !== null) assigned.add(match[1]);
2728
for (const name of EXPECTED_EXPORTS) expect(assigned).toContain(name);
2829
expect(assigned).not.toContain(CONFLICTING_EXPORT);
2930
});

0 commit comments

Comments
 (0)