From af470a504e53c173661a41517ad45d755b5aea12 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 4 Sep 2017 14:09:55 +0200 Subject: [PATCH] handle inner non-harmony dependencies correctly in ConcatenatedModule add async as keyword fixes #5604 fixes #5615 --- lib/optimize/ConcatenatedModule.js | 6 +++--- test/cases/scope-hoisting/async-keyword-5615/async.js | 1 + test/cases/scope-hoisting/async-keyword-5615/index.js | 5 +++++ test/cases/scope-hoisting/require-root-5604/index.js | 8 ++++++++ test/cases/scope-hoisting/require-root-5604/module.js | 2 ++ 5 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 test/cases/scope-hoisting/async-keyword-5615/async.js create mode 100644 test/cases/scope-hoisting/async-keyword-5615/index.js create mode 100644 test/cases/scope-hoisting/require-root-5604/index.js create mode 100644 test/cases/scope-hoisting/require-root-5604/module.js diff --git a/lib/optimize/ConcatenatedModule.js b/lib/optimize/ConcatenatedModule.js index ec3b5d7cb..b09cb6b8f 100644 --- a/lib/optimize/ConcatenatedModule.js +++ b/lib/optimize/ConcatenatedModule.js @@ -172,7 +172,7 @@ class ConcatenatedModule extends Module { this.built = modules.some(m => m.built); this.cacheable = modules.every(m => m.cacheable); const modulesSet = new Set(modules); - this.reasons = rootModule.reasons.filter(reason => !modulesSet.has(reason.module)); + this.reasons = rootModule.reasons.filter(reason => !(reason.dependency instanceof HarmonyImportDependency) || !modulesSet.has(reason.module)); this.meta = rootModule.meta; this.moduleArgument = rootModule.moduleArgument; this.exportsArgument = rootModule.exportsArgument; @@ -193,7 +193,7 @@ class ConcatenatedModule extends Module { const m = info.module; // populate dependencies - m.dependencies.filter(dep => !modulesSet.has(dep.module)) + m.dependencies.filter(dep => !(dep instanceof HarmonyImportDependency) || !modulesSet.has(dep.module)) .forEach(d => this.dependencies.push(d)); // populate dep warning m.dependenciesWarnings.forEach(depWarning => this.dependenciesWarnings.push(depWarning)); @@ -450,7 +450,7 @@ class ConcatenatedModule extends Module { const allUsedNames = new Set([ "__WEBPACK_MODULE_DEFAULT_EXPORT__", // avoid using this internal name - "abstract", "arguments", "await", "boolean", "break", "byte", "case", "catch", "char", "class", + "abstract", "arguments", "async", "await", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "debugger", "default", "delete", "do", "double", "else", "enum", "eval", "export", "extends", "false", "final", "finally", "float", "for", "function", "goto", "if", "implements", "import", "in", "instanceof", "int", "interface", "let", "long", "native", "new", diff --git a/test/cases/scope-hoisting/async-keyword-5615/async.js b/test/cases/scope-hoisting/async-keyword-5615/async.js new file mode 100644 index 000000000..17e060e96 --- /dev/null +++ b/test/cases/scope-hoisting/async-keyword-5615/async.js @@ -0,0 +1 @@ +export default "default"; diff --git a/test/cases/scope-hoisting/async-keyword-5615/index.js b/test/cases/scope-hoisting/async-keyword-5615/index.js new file mode 100644 index 000000000..b2e73311b --- /dev/null +++ b/test/cases/scope-hoisting/async-keyword-5615/index.js @@ -0,0 +1,5 @@ +import value from "./async"; + +it("should have the correct values", function() { + value.should.be.eql("default"); +}); diff --git a/test/cases/scope-hoisting/require-root-5604/index.js b/test/cases/scope-hoisting/require-root-5604/index.js new file mode 100644 index 000000000..0aeb495bb --- /dev/null +++ b/test/cases/scope-hoisting/require-root-5604/index.js @@ -0,0 +1,8 @@ +import value, { self as moduleSelf } from "./module"; +export var self = require("./"); + +it("should have the correct values", function() { + value.should.be.eql("default"); + moduleSelf.should.be.eql(self); + self.self.should.be.eql(self); +}); diff --git a/test/cases/scope-hoisting/require-root-5604/module.js b/test/cases/scope-hoisting/require-root-5604/module.js new file mode 100644 index 000000000..4041ca54c --- /dev/null +++ b/test/cases/scope-hoisting/require-root-5604/module.js @@ -0,0 +1,2 @@ +export default "default"; +export var self = require("./");