Skip to content

Commit

Permalink
Merge pull request #8588 from hulkish/faster-statement-type-check
Browse files Browse the repository at this point in the history
perf: use faster statement type check
  • Loading branch information
sokra committed Jan 4, 2019
2 parents baf0aa1 + 2a04dee commit 3e147e6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/dependencies/HarmonyDetectionParserPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ module.exports = class HarmonyDetectionParserPlugin {
const isStrictHarmony = parser.state.module.type === "javascript/esm";
const isHarmony =
isStrictHarmony ||
ast.body.some(statement => {
return /^(Import|Export).*Declaration$/.test(statement.type);
});
ast.body.some(
statement =>
statement.type === "ImportDeclaration" ||
statement.type === "ExportDefaultDeclaration" ||
statement.type === "ExportNamedDeclaration" ||
statement.type === "ExportAllDeclaration"
);
if (isHarmony) {
const module = parser.state.module;
const compatDep = new HarmonyCompatibilityDependency(module);
Expand Down

0 comments on commit 3e147e6

Please sign in to comment.