From a54645ab5bcaae69eb608ed3876591a58fb45ad2 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 29 Nov 2018 15:45:08 +0100 Subject: [PATCH] fix test cases --- lib/RuntimeModule.js | 8 -------- test/ConfigTestCases.test.js | 9 +++++---- test/configCases/code-generation/use-strict/index.js | 2 ++ test/configCases/dll-plugin-entry/1-use-dll/index.js | 1 - test/configCases/dll-plugin/1-use-dll/index.js | 3 --- .../dll-plugin/2-use-dll-without-scope/index.js | 3 --- .../hash-length/output-filename/webpack.config.js | 8 ++++---- 7 files changed, 11 insertions(+), 23 deletions(-) diff --git a/lib/RuntimeModule.js b/lib/RuntimeModule.js index a4c4d1106..a3a590201 100644 --- a/lib/RuntimeModule.js +++ b/lib/RuntimeModule.js @@ -46,14 +46,6 @@ class RuntimeModule extends Module { return `webpack/runtime/${this.name}`; } - /** - * @param {LibIdentOptions} options options - * @returns {string | null} an identifier for library inclusion - */ - libIdent(options) { - return `webpack/runtime/${this.name}`; - } - /** * @param {NeedBuildContext} context context info * @param {function(WebpackError=, boolean=): void} callback callback function, returns true, if the module needs a rebuild diff --git a/test/ConfigTestCases.test.js b/test/ConfigTestCases.test.js index 48a76f894..c09d7ac30 100644 --- a/test/ConfigTestCases.test.js +++ b/test/ConfigTestCases.test.js @@ -172,7 +172,7 @@ describe("ConfigTestCases", () => { } }; - function _require(currentDirectory, module) { + function _require(currentDirectory, options, module) { if (Array.isArray(module) || /^\.\.?\//.test(module)) { let fn; let content; @@ -194,7 +194,7 @@ describe("ConfigTestCases", () => { options.target === "webworker" ) { fn = vm.runInNewContext( - "(function(require, module, exports, __dirname, __filename, it, beforeEach, afterEach, expect, jest, window) {" + + "(function(require, module, exports, __dirname, __filename, it, beforeEach, afterEach, expect, jest, window, self) {" + 'function nsObj(m) { Object.defineProperty(m, Symbol.toStringTag, { value: "Module" }); return m; }' + content + "\n})", @@ -216,7 +216,7 @@ describe("ConfigTestCases", () => { }; fn.call( m.exports, - _require.bind(null, path.dirname(p)), + _require.bind(null, path.dirname(p), options), m, m.exports, path.dirname(p), @@ -226,6 +226,7 @@ describe("ConfigTestCases", () => { _afterEach, expect, jest, + globalContext, globalContext ); return m.exports; @@ -243,7 +244,7 @@ describe("ConfigTestCases", () => { const bundlePath = testConfig.findBundle(i, optionsArr[i]); if (bundlePath) { filesCount++; - _require(outputDirectory, bundlePath); + _require(outputDirectory, optionsArr[i], bundlePath); } } // give a free pass to compilation that generated an error diff --git a/test/configCases/code-generation/use-strict/index.js b/test/configCases/code-generation/use-strict/index.js index 8f1328206..45c15ccef 100644 --- a/test/configCases/code-generation/use-strict/index.js +++ b/test/configCases/code-generation/use-strict/index.js @@ -19,6 +19,8 @@ it("should include only one use strict per module", function() { expect(matches).toEqual([ "/* unused harmony default export */ var _unused_webpack_default_export = (\"a\");", + "/* webpack/runtime/make namespace object */", + "/******/ \t// The module cache", "__webpack_require__.r(__webpack_exports__);", "__webpack_require__.r(__webpack_exports__);", "__webpack_require__.r(__webpack_exports__);", diff --git a/test/configCases/dll-plugin-entry/1-use-dll/index.js b/test/configCases/dll-plugin-entry/1-use-dll/index.js index 8132136d1..abd0f75aa 100644 --- a/test/configCases/dll-plugin-entry/1-use-dll/index.js +++ b/test/configCases/dll-plugin-entry/1-use-dll/index.js @@ -17,6 +17,5 @@ it("should give modules the correct ids", function() { "./index.js", "dll-reference ../0-create-dll/dll.js", "dll/index.js", - "webpack/runtime/make namespace object", ]); }); diff --git a/test/configCases/dll-plugin/1-use-dll/index.js b/test/configCases/dll-plugin/1-use-dll/index.js index 7695357c6..d18dc03cc 100644 --- a/test/configCases/dll-plugin/1-use-dll/index.js +++ b/test/configCases/dll-plugin/1-use-dll/index.js @@ -44,8 +44,5 @@ it("should give modules the correct ids", function() { "dll/e2.js", "dll/f.jsx", "dll/g.abc.js", - "webpack/runtime/compat get default export", - "webpack/runtime/define property getter", - "webpack/runtime/make namespace object", ]); }); diff --git a/test/configCases/dll-plugin/2-use-dll-without-scope/index.js b/test/configCases/dll-plugin/2-use-dll-without-scope/index.js index 8b8259c8e..4a74d4c16 100644 --- a/test/configCases/dll-plugin/2-use-dll-without-scope/index.js +++ b/test/configCases/dll-plugin/2-use-dll-without-scope/index.js @@ -44,8 +44,5 @@ it("should give modules the correct ids", function() { "../0-create-dll/g.abc.js", "./index.js", "dll-reference ../0-create-dll/dll.js", - "webpack/runtime/compat get default export", - "webpack/runtime/define property getter", - "webpack/runtime/make namespace object", ]); }); diff --git a/test/configCases/hash-length/output-filename/webpack.config.js b/test/configCases/hash-length/output-filename/webpack.config.js index ca75582b2..d9a594f93 100644 --- a/test/configCases/hash-length/output-filename/webpack.config.js +++ b/test/configCases/hash-length/output-filename/webpack.config.js @@ -170,7 +170,7 @@ module.exports = [ output: { filename: "bundle14.[contenthash].js", chunkFilename: "[id].bundle14.[contenthash].js", - globalObject: "this" + globalObject: "window" }, target: "web", amd: { @@ -184,7 +184,7 @@ module.exports = [ output: { filename: "bundle15.[contenthash:7].js", chunkFilename: "[id].bundle15.[contenthash:7].js", - globalObject: "this" + globalObject: "window" }, target: "web", amd: { @@ -198,7 +198,7 @@ module.exports = [ output: { filename: "bundle16.[contenthash].js", chunkFilename: "[id].bundle16.[contenthash].js", - globalObject: "this" + globalObject: "self" }, target: "webworker", amd: { @@ -212,7 +212,7 @@ module.exports = [ output: { filename: "bundle17.[contenthash:7].js", chunkFilename: "[id].bundle17.[contenthash:7].js", - globalObject: "this" + globalObject: "self" }, target: "webworker", amd: {