Skip to content

Commit 3e147e6

Browse files
authored
Merge pull request #8588 from hulkish/faster-statement-type-check
perf: use faster statement type check
2 parents baf0aa1 + 2a04dee commit 3e147e6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/dependencies/HarmonyDetectionParserPlugin.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ module.exports = class HarmonyDetectionParserPlugin {
1313
const isStrictHarmony = parser.state.module.type === "javascript/esm";
1414
const isHarmony =
1515
isStrictHarmony ||
16-
ast.body.some(statement => {
17-
return /^(Import|Export).*Declaration$/.test(statement.type);
18-
});
16+
ast.body.some(
17+
statement =>
18+
statement.type === "ImportDeclaration" ||
19+
statement.type === "ExportDefaultDeclaration" ||
20+
statement.type === "ExportNamedDeclaration" ||
21+
statement.type === "ExportAllDeclaration"
22+
);
1923
if (isHarmony) {
2024
const module = parser.state.module;
2125
const compatDep = new HarmonyCompatibilityDependency(module);

0 commit comments

Comments
 (0)