Skip to content

Commit 41b6887

Browse files
author
Steven Hargrove
committed
use faster statement type check
1 parent ccc7db7 commit 41b6887

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/dependencies/HarmonyDetectionParserPlugin.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ 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(statement => statement =>
17+
statement.type === "ImportDeclaration" ||
18+
statement.type === "ExportDefaultDeclaration" ||
19+
statement.type === "ExportNamedDeclaration"
20+
);
1921
if (isHarmony) {
2022
const module = parser.state.module;
2123
const compatDep = new HarmonyCompatibilityDependency(module);

0 commit comments

Comments
 (0)