diff options
Diffstat (limited to 'node_modules/webpack/lib/webworker')
3 files changed, 31 insertions, 35 deletions
diff --git a/node_modules/webpack/lib/webworker/WebWorkerChunkTemplatePlugin.js b/node_modules/webpack/lib/webworker/WebWorkerChunkTemplatePlugin.js index 0b7fa525b..3944f3cfc 100644 --- a/node_modules/webpack/lib/webworker/WebWorkerChunkTemplatePlugin.js +++ b/node_modules/webpack/lib/webworker/WebWorkerChunkTemplatePlugin.js @@ -4,8 +4,8 @@ */
"use strict";
-var ConcatSource = require("webpack-sources").ConcatSource;
-var Template = require("../Template");
+const ConcatSource = require("webpack-sources").ConcatSource;
+const Template = require("../Template");
class WebWorkerChunkTemplatePlugin {
diff --git a/node_modules/webpack/lib/webworker/WebWorkerMainTemplate.runtime.js b/node_modules/webpack/lib/webworker/WebWorkerMainTemplate.runtime.js index bcead37e4..9b6c59fea 100644 --- a/node_modules/webpack/lib/webworker/WebWorkerMainTemplate.runtime.js +++ b/node_modules/webpack/lib/webworker/WebWorkerMainTemplate.runtime.js @@ -13,7 +13,8 @@ module.exports = function() { importScripts($require$.p + $hotChunkFilename$);
}
- function hotDownloadManifest(callback) { // eslint-disable-line no-unused-vars
+ function hotDownloadManifest(requestTimeout) { // eslint-disable-line no-unused-vars
+ requestTimeout = requestTimeout || 10000;
return new Promise(function(resolve, reject) {
if(typeof XMLHttpRequest === "undefined")
return reject(new Error("No browser support"));
@@ -21,7 +22,7 @@ module.exports = function() { var request = new XMLHttpRequest();
var requestPath = $require$.p + $hotMainFilename$;
request.open("GET", requestPath, true);
- request.timeout = 10000;
+ request.timeout = requestTimeout;
request.send(null);
} catch(err) {
return reject(err);
diff --git a/node_modules/webpack/lib/webworker/WebWorkerMainTemplatePlugin.js b/node_modules/webpack/lib/webworker/WebWorkerMainTemplatePlugin.js index 429e2c3d4..cc7615497 100644 --- a/node_modules/webpack/lib/webworker/WebWorkerMainTemplatePlugin.js +++ b/node_modules/webpack/lib/webworker/WebWorkerMainTemplatePlugin.js @@ -17,13 +17,9 @@ class WebWorkerMainTemplatePlugin { "// \"1\" means \"already loaded\"",
"var installedChunks = {",
this.indent(
- chunk.ids.map(function(id) {
- return id + ": 1";
- }).join(",\n")
+ chunk.ids.map((id) => `${id}: 1`).join(",\n")
),
- "};",
- "",
- "var resolvedPromise = new Promise(function(resolve) { resolve(); });"
+ "};"
]);
}
return source;
@@ -31,22 +27,24 @@ class WebWorkerMainTemplatePlugin { mainTemplate.plugin("require-ensure", function(_, chunk, hash) {
const chunkFilename = this.outputOptions.chunkFilename;
return this.asString([
- "// \"1\" is the signal for \"already loaded\"",
- "if(!installedChunks[chunkId]) {",
+ "return new Promise(function(resolve) {",
this.indent([
- "importScripts(" +
- this.applyPluginsWaterfall("asset-path", JSON.stringify(chunkFilename), {
- hash: "\" + " + this.renderCurrentHashCode(hash) + " + \"",
- hashWithLength: function(length) {
- return "\" + " + this.renderCurrentHashCode(hash, length) + " + \"";
- }.bind(this),
- chunk: {
- id: "\" + chunkId + \""
- }
- }) + ");"
+ "// \"1\" is the signal for \"already loaded\"",
+ "if(!installedChunks[chunkId]) {",
+ this.indent([
+ "importScripts(" +
+ this.applyPluginsWaterfall("asset-path", JSON.stringify(chunkFilename), {
+ hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
+ hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`,
+ chunk: {
+ id: "\" + chunkId + \""
+ }
+ }) + ");"
+ ]),
+ "}",
+ "resolve();"
]),
- "}",
- "return resolvedPromise;"
+ "});"
]);
});
mainTemplate.plugin("bootstrap", function(source, chunk, hash) {
@@ -54,7 +52,7 @@ class WebWorkerMainTemplatePlugin { const chunkCallbackName = this.outputOptions.chunkCallbackName || Template.toIdentifier("webpackChunk" + (this.outputOptions.library || ""));
return this.asString([
source,
- "this[" + JSON.stringify(chunkCallbackName) + "] = function webpackChunkCallback(chunkIds, moreModules) {",
+ `this[${JSON.stringify(chunkCallbackName)}] = function webpackChunkCallback(chunkIds, moreModules) {`,
this.indent([
"for(var moduleId in moreModules) {",
this.indent(this.renderAddModule(hash, chunk, "moduleId", "moreModules[moduleId]")),
@@ -72,24 +70,21 @@ class WebWorkerMainTemplatePlugin { const hotUpdateMainFilename = this.outputOptions.hotUpdateMainFilename;
const hotUpdateFunction = this.outputOptions.hotUpdateFunction || Template.toIdentifier("webpackHotUpdate" + (this.outputOptions.library || ""));
const currentHotUpdateChunkFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateChunkFilename), {
- hash: "\" + " + this.renderCurrentHashCode(hash) + " + \"",
- hashWithLength: function(length) {
- return "\" + " + this.renderCurrentHashCode(hash, length) + " + \"";
- }.bind(this),
+ hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
+ hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`,
chunk: {
id: "\" + chunkId + \""
}
});
const currentHotUpdateMainFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateMainFilename), {
- hash: "\" + " + this.renderCurrentHashCode(hash) + " + \"",
- hashWithLength: function(length) {
- return "\" + " + this.renderCurrentHashCode(hash, length) + " + \"";
- }.bind(this)
+ hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
+ hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`,
});
return source + "\n" +
- "var parentHotUpdateCallback = this[" + JSON.stringify(hotUpdateFunction) + "];\n" +
- "this[" + JSON.stringify(hotUpdateFunction) + "] = " + Template.getFunctionContent(require("./WebWorkerMainTemplate.runtime.js"))
+ `var parentHotUpdateCallback = this[${JSON.stringify(hotUpdateFunction)}];\n` +
+ `this[${JSON.stringify(hotUpdateFunction)}] = ` +
+ Template.getFunctionContent(require("./WebWorkerMainTemplate.runtime.js"))
.replace(/\/\/\$semicolon/g, ";")
.replace(/\$require\$/g, this.requireFn)
.replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename)
|