aboutsummaryrefslogtreecommitdiff
path: root/node_modules/webpack/lib/webworker
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
committerFlorian Dold <florian.dold@gmail.com>2018-09-20 02:56:13 +0200
commitbbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch)
treec58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/webpack/lib/webworker
parent003fb34971cf63466184351b4db5f7c67df4f444 (diff)
update packages
Diffstat (limited to 'node_modules/webpack/lib/webworker')
-rw-r--r--node_modules/webpack/lib/webworker/WebWorkerChunkTemplatePlugin.js64
-rw-r--r--node_modules/webpack/lib/webworker/WebWorkerHotUpdateChunkTemplatePlugin.js68
-rw-r--r--node_modules/webpack/lib/webworker/WebWorkerMainTemplate.runtime.js123
-rw-r--r--node_modules/webpack/lib/webworker/WebWorkerMainTemplatePlugin.js296
-rw-r--r--node_modules/webpack/lib/webworker/WebWorkerTemplatePlugin.js45
5 files changed, 356 insertions, 240 deletions
diff --git a/node_modules/webpack/lib/webworker/WebWorkerChunkTemplatePlugin.js b/node_modules/webpack/lib/webworker/WebWorkerChunkTemplatePlugin.js
index 3944f3cfc..f44ca26cd 100644
--- a/node_modules/webpack/lib/webworker/WebWorkerChunkTemplatePlugin.js
+++ b/node_modules/webpack/lib/webworker/WebWorkerChunkTemplatePlugin.js
@@ -1,29 +1,35 @@
-/*
- MIT License http://www.opensource.org/licenses/mit-license.php
- Author Tobias Koppers @sokra
-*/
-"use strict";
-
-const ConcatSource = require("webpack-sources").ConcatSource;
-const Template = require("../Template");
-
-class WebWorkerChunkTemplatePlugin {
-
- apply(chunkTemplate) {
- chunkTemplate.plugin("render", function(modules, chunk) {
- const chunkCallbackName = this.outputOptions.chunkCallbackName || Template.toIdentifier("webpackChunk" + (this.outputOptions.library || ""));
- const source = new ConcatSource();
- source.add(`${chunkCallbackName}(${JSON.stringify(chunk.ids)},`);
- source.add(modules);
- source.add(")");
- return source;
- });
- chunkTemplate.plugin("hash", function(hash) {
- hash.update("webworker");
- hash.update("3");
- hash.update(`${this.outputOptions.chunkCallbackName}`);
- hash.update(`${this.outputOptions.library}`);
- });
- }
-}
-module.exports = WebWorkerChunkTemplatePlugin;
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+"use strict";
+
+const { ConcatSource } = require("webpack-sources");
+
+class WebWorkerChunkTemplatePlugin {
+ apply(chunkTemplate) {
+ chunkTemplate.hooks.render.tap(
+ "WebWorkerChunkTemplatePlugin",
+ (modules, chunk) => {
+ const chunkCallbackName = chunkTemplate.outputOptions.chunkCallbackName;
+ const globalObject = chunkTemplate.outputOptions.globalObject;
+ const source = new ConcatSource();
+ source.add(
+ `${globalObject}[${JSON.stringify(
+ chunkCallbackName
+ )}](${JSON.stringify(chunk.ids)},`
+ );
+ source.add(modules);
+ source.add(")");
+ return source;
+ }
+ );
+ chunkTemplate.hooks.hash.tap("WebWorkerChunkTemplatePlugin", hash => {
+ hash.update("webworker");
+ hash.update("3");
+ hash.update(`${chunkTemplate.outputOptions.chunkCallbackName}`);
+ hash.update(`${chunkTemplate.outputOptions.globalObject}`);
+ });
+ }
+}
+module.exports = WebWorkerChunkTemplatePlugin;
diff --git a/node_modules/webpack/lib/webworker/WebWorkerHotUpdateChunkTemplatePlugin.js b/node_modules/webpack/lib/webworker/WebWorkerHotUpdateChunkTemplatePlugin.js
index c128be7c7..8b0261194 100644
--- a/node_modules/webpack/lib/webworker/WebWorkerHotUpdateChunkTemplatePlugin.js
+++ b/node_modules/webpack/lib/webworker/WebWorkerHotUpdateChunkTemplatePlugin.js
@@ -1,28 +1,40 @@
-/*
- MIT License http://www.opensource.org/licenses/mit-license.php
- Author Tobias Koppers @sokra
-*/
-"use strict";
-const ConcatSource = require("webpack-sources").ConcatSource;
-const Template = require("../Template");
-
-class WebWorkerHotUpdateChunkTemplatePlugin {
-
- apply(hotUpdateChunkTemplate) {
- hotUpdateChunkTemplate.plugin("render", function(modulesSource, modules, removedModules, hash, id) {
- const chunkCallbackName = this.outputOptions.hotUpdateFunction || Template.toIdentifier("webpackHotUpdate" + (this.outputOptions.library || ""));
- const source = new ConcatSource();
- source.add(chunkCallbackName + "(" + JSON.stringify(id) + ",");
- source.add(modulesSource);
- source.add(")");
- return source;
- });
- hotUpdateChunkTemplate.plugin("hash", function(hash) {
- hash.update("WebWorkerHotUpdateChunkTemplatePlugin");
- hash.update("3");
- hash.update(this.outputOptions.hotUpdateFunction + "");
- hash.update(this.outputOptions.library + "");
- });
- }
-}
-module.exports = WebWorkerHotUpdateChunkTemplatePlugin;
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+"use strict";
+const { ConcatSource } = require("webpack-sources");
+
+class WebWorkerHotUpdateChunkTemplatePlugin {
+ apply(hotUpdateChunkTemplate) {
+ hotUpdateChunkTemplate.hooks.render.tap(
+ "WebWorkerHotUpdateChunkTemplatePlugin",
+ (modulesSource, modules, removedModules, hash, id) => {
+ const hotUpdateFunction =
+ hotUpdateChunkTemplate.outputOptions.hotUpdateFunction;
+ const globalObject = hotUpdateChunkTemplate.outputOptions.globalObject;
+ const source = new ConcatSource();
+ source.add(
+ `${globalObject}[${JSON.stringify(
+ hotUpdateFunction
+ )}](${JSON.stringify(id)},`
+ );
+ source.add(modulesSource);
+ source.add(")");
+ return source;
+ }
+ );
+ hotUpdateChunkTemplate.hooks.hash.tap(
+ "WebWorkerHotUpdateChunkTemplatePlugin",
+ hash => {
+ hash.update("WebWorkerHotUpdateChunkTemplatePlugin");
+ hash.update("3");
+ hash.update(
+ hotUpdateChunkTemplate.outputOptions.hotUpdateFunction + ""
+ );
+ hash.update(hotUpdateChunkTemplate.outputOptions.globalObject + "");
+ }
+ );
+ }
+}
+module.exports = WebWorkerHotUpdateChunkTemplatePlugin;
diff --git a/node_modules/webpack/lib/webworker/WebWorkerMainTemplate.runtime.js b/node_modules/webpack/lib/webworker/WebWorkerMainTemplate.runtime.js
index 9b6c59fea..8c63f7729 100644
--- a/node_modules/webpack/lib/webworker/WebWorkerMainTemplate.runtime.js
+++ b/node_modules/webpack/lib/webworker/WebWorkerMainTemplate.runtime.js
@@ -1,58 +1,65 @@
-/*
- MIT License http://www.opensource.org/licenses/mit-license.php
- Author Tobias Koppers @sokra
-*/
-/*globals installedChunks hotAddUpdateChunk parentHotUpdateCallback importScripts XMLHttpRequest $require$ $hotChunkFilename$ $hotMainFilename$ */
-module.exports = function() {
- function webpackHotUpdateCallback(chunkId, moreModules) { // eslint-disable-line no-unused-vars
- hotAddUpdateChunk(chunkId, moreModules);
- if(parentHotUpdateCallback) parentHotUpdateCallback(chunkId, moreModules);
- } //$semicolon
-
- function hotDownloadUpdateChunk(chunkId) { // eslint-disable-line no-unused-vars
- importScripts($require$.p + $hotChunkFilename$);
- }
-
- 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"));
- try {
- var request = new XMLHttpRequest();
- var requestPath = $require$.p + $hotMainFilename$;
- request.open("GET", requestPath, true);
- request.timeout = requestTimeout;
- request.send(null);
- } catch(err) {
- return reject(err);
- }
- request.onreadystatechange = function() {
- if(request.readyState !== 4) return;
- if(request.status === 0) {
- // timeout
- reject(new Error("Manifest request to " + requestPath + " timed out."));
- } else if(request.status === 404) {
- // no update available
- resolve();
- } else if(request.status !== 200 && request.status !== 304) {
- // other failure
- reject(new Error("Manifest request to " + requestPath + " failed."));
- } else {
- // success
- try {
- var update = JSON.parse(request.responseText);
- } catch(e) {
- reject(e);
- return;
- }
- resolve(update);
- }
- };
- });
- }
-
- function hotDisposeChunk(chunkId) { //eslint-disable-line no-unused-vars
- delete installedChunks[chunkId];
- }
-};
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+/*globals installedChunks hotAddUpdateChunk parentHotUpdateCallback importScripts XMLHttpRequest $require$ $hotChunkFilename$ $hotMainFilename$ */
+module.exports = function() {
+ // eslint-disable-next-line no-unused-vars
+ function webpackHotUpdateCallback(chunkId, moreModules) {
+ hotAddUpdateChunk(chunkId, moreModules);
+ if (parentHotUpdateCallback) parentHotUpdateCallback(chunkId, moreModules);
+ } //$semicolon
+
+ // eslint-disable-next-line no-unused-vars
+ function hotDownloadUpdateChunk(chunkId) {
+ importScripts($require$.p + $hotChunkFilename$);
+ }
+
+ // eslint-disable-next-line no-unused-vars
+ function hotDownloadManifest(requestTimeout) {
+ requestTimeout = requestTimeout || 10000;
+ return new Promise(function(resolve, reject) {
+ if (typeof XMLHttpRequest === "undefined") {
+ return reject(new Error("No browser support"));
+ }
+ try {
+ var request = new XMLHttpRequest();
+ var requestPath = $require$.p + $hotMainFilename$;
+ request.open("GET", requestPath, true);
+ request.timeout = requestTimeout;
+ request.send(null);
+ } catch (err) {
+ return reject(err);
+ }
+ request.onreadystatechange = function() {
+ if (request.readyState !== 4) return;
+ if (request.status === 0) {
+ // timeout
+ reject(
+ new Error("Manifest request to " + requestPath + " timed out.")
+ );
+ } else if (request.status === 404) {
+ // no update available
+ resolve();
+ } else if (request.status !== 200 && request.status !== 304) {
+ // other failure
+ reject(new Error("Manifest request to " + requestPath + " failed."));
+ } else {
+ // success
+ try {
+ var update = JSON.parse(request.responseText);
+ } catch (e) {
+ reject(e);
+ return;
+ }
+ resolve(update);
+ }
+ };
+ });
+ }
+
+ //eslint-disable-next-line no-unused-vars
+ function hotDisposeChunk(chunkId) {
+ delete installedChunks[chunkId];
+ }
+};
diff --git a/node_modules/webpack/lib/webworker/WebWorkerMainTemplatePlugin.js b/node_modules/webpack/lib/webworker/WebWorkerMainTemplatePlugin.js
index ff2d6c2f5..39f7dabbd 100644
--- a/node_modules/webpack/lib/webworker/WebWorkerMainTemplatePlugin.js
+++ b/node_modules/webpack/lib/webworker/WebWorkerMainTemplatePlugin.js
@@ -1,105 +1,191 @@
-/*
- MIT License http://www.opensource.org/licenses/mit-license.php
- Author Tobias Koppers @sokra
-*/
-"use strict";
-
-const Template = require("../Template");
-
-class WebWorkerMainTemplatePlugin {
- apply(mainTemplate) {
- mainTemplate.plugin("local-vars", function(source, chunk) {
- if(chunk.chunks.length > 0) {
- return this.asString([
- source,
- "",
- "// object to store loaded chunks",
- "// \"1\" means \"already loaded\"",
- "var installedChunks = {",
- this.indent(
- chunk.ids.map((id) => `${id}: 1`).join(",\n")
- ),
- "};"
- ]);
- }
- return source;
- });
- mainTemplate.plugin("require-ensure", function(_, chunk, hash) {
- const chunkFilename = this.outputOptions.chunkFilename;
- return this.asString([
- "return new Promise(function(resolve) {",
- this.indent([
- "// \"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();"
- ]),
- "});"
- ]);
- });
- mainTemplate.plugin("bootstrap", function(source, chunk, hash) {
- if(chunk.chunks.length > 0) {
- const chunkCallbackName = this.outputOptions.chunkCallbackName || Template.toIdentifier("webpackChunk" + (this.outputOptions.library || ""));
- return this.asString([
- source,
- `this[${JSON.stringify(chunkCallbackName)}] = function webpackChunkCallback(chunkIds, moreModules) {`,
- this.indent([
- "for(var moduleId in moreModules) {",
- this.indent(this.renderAddModule(hash, chunk, "moduleId", "moreModules[moduleId]")),
- "}",
- "while(chunkIds.length)",
- this.indent("installedChunks[chunkIds.pop()] = 1;")
- ]),
- "};"
- ]);
- }
- return source;
- });
- mainTemplate.plugin("hot-bootstrap", function(source, chunk, hash) {
- const hotUpdateChunkFilename = this.outputOptions.hotUpdateChunkFilename;
- 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: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`,
- chunk: {
- id: "\" + chunkId + \""
- }
- });
- const currentHotUpdateMainFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateMainFilename), {
- hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
- hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`,
- });
-
- return source + "\n" +
- `var parentHotUpdateCallback = self[${JSON.stringify(hotUpdateFunction)}];\n` +
- `self[${JSON.stringify(hotUpdateFunction)}] = ` +
- Template.getFunctionContent(require("./WebWorkerMainTemplate.runtime.js"))
- .replace(/\/\/\$semicolon/g, ";")
- .replace(/\$require\$/g, this.requireFn)
- .replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename)
- .replace(/\$hotChunkFilename\$/g, currentHotUpdateChunkFilename)
- .replace(/\$hash\$/g, JSON.stringify(hash));
- });
- mainTemplate.plugin("hash", function(hash) {
- hash.update("webworker");
- hash.update("3");
- hash.update(`${this.outputOptions.publicPath}`);
- hash.update(`${this.outputOptions.filename}`);
- hash.update(`${this.outputOptions.chunkFilename}`);
- hash.update(`${this.outputOptions.chunkCallbackName}`);
- hash.update(`${this.outputOptions.library}`);
- });
- }
-}
-module.exports = WebWorkerMainTemplatePlugin;
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+"use strict";
+
+const Template = require("../Template");
+
+class WebWorkerMainTemplatePlugin {
+ apply(mainTemplate) {
+ const needChunkOnDemandLoadingCode = chunk => {
+ for (const chunkGroup of chunk.groupsIterable) {
+ if (chunkGroup.getNumberOfChildren() > 0) return true;
+ }
+ return false;
+ };
+ mainTemplate.hooks.localVars.tap(
+ "WebWorkerMainTemplatePlugin",
+ (source, chunk) => {
+ if (needChunkOnDemandLoadingCode(chunk)) {
+ return Template.asString([
+ source,
+ "",
+ "// object to store loaded chunks",
+ '// "1" means "already loaded"',
+ "var installedChunks = {",
+ Template.indent(
+ chunk.ids.map(id => `${JSON.stringify(id)}: 1`).join(",\n")
+ ),
+ "};"
+ ]);
+ }
+ return source;
+ }
+ );
+ mainTemplate.hooks.requireEnsure.tap(
+ "WebWorkerMainTemplatePlugin",
+ (_, chunk, hash) => {
+ const chunkFilename = mainTemplate.outputOptions.chunkFilename;
+ const chunkMaps = chunk.getChunkMaps();
+ return Template.asString([
+ "promises.push(Promise.resolve().then(function() {",
+ Template.indent([
+ '// "1" is the signal for "already loaded"',
+ "if(!installedChunks[chunkId]) {",
+ Template.indent([
+ "importScripts(" +
+ mainTemplate.getAssetPath(JSON.stringify(chunkFilename), {
+ hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`,
+ hashWithLength: length =>
+ `" + ${mainTemplate.renderCurrentHashCode(
+ hash,
+ length
+ )} + "`,
+ chunk: {
+ id: '" + chunkId + "',
+ hash: `" + ${JSON.stringify(chunkMaps.hash)}[chunkId] + "`,
+ hashWithLength(length) {
+ const shortChunkHashMap = Object.create(null);
+ for (const chunkId of Object.keys(chunkMaps.hash)) {
+ if (typeof chunkMaps.hash[chunkId] === "string") {
+ shortChunkHashMap[chunkId] = chunkMaps.hash[
+ chunkId
+ ].substr(0, length);
+ }
+ }
+ return `" + ${JSON.stringify(
+ shortChunkHashMap
+ )}[chunkId] + "`;
+ },
+ contentHash: {
+ javascript: `" + ${JSON.stringify(
+ chunkMaps.contentHash.javascript
+ )}[chunkId] + "`
+ },
+ contentHashWithLength: {
+ javascript: length => {
+ const shortContentHashMap = {};
+ const contentHash = chunkMaps.contentHash.javascript;
+ for (const chunkId of Object.keys(contentHash)) {
+ if (typeof contentHash[chunkId] === "string") {
+ shortContentHashMap[chunkId] = contentHash[
+ chunkId
+ ].substr(0, length);
+ }
+ }
+ return `" + ${JSON.stringify(
+ shortContentHashMap
+ )}[chunkId] + "`;
+ }
+ },
+ name: `" + (${JSON.stringify(
+ chunkMaps.name
+ )}[chunkId]||chunkId) + "`
+ },
+ contentHashType: "javascript"
+ }) +
+ ");"
+ ]),
+ "}"
+ ]),
+ "}));"
+ ]);
+ }
+ );
+ mainTemplate.hooks.bootstrap.tap(
+ "WebWorkerMainTemplatePlugin",
+ (source, chunk, hash) => {
+ if (needChunkOnDemandLoadingCode(chunk)) {
+ const chunkCallbackName =
+ mainTemplate.outputOptions.chunkCallbackName;
+ const globalObject = mainTemplate.outputOptions.globalObject;
+ return Template.asString([
+ source,
+ `${globalObject}[${JSON.stringify(
+ chunkCallbackName
+ )}] = function webpackChunkCallback(chunkIds, moreModules) {`,
+ Template.indent([
+ "for(var moduleId in moreModules) {",
+ Template.indent(
+ mainTemplate.renderAddModule(
+ hash,
+ chunk,
+ "moduleId",
+ "moreModules[moduleId]"
+ )
+ ),
+ "}",
+ "while(chunkIds.length)",
+ Template.indent("installedChunks[chunkIds.pop()] = 1;")
+ ]),
+ "};"
+ ]);
+ }
+ return source;
+ }
+ );
+ mainTemplate.hooks.hotBootstrap.tap(
+ "WebWorkerMainTemplatePlugin",
+ (source, chunk, hash) => {
+ const hotUpdateChunkFilename =
+ mainTemplate.outputOptions.hotUpdateChunkFilename;
+ const hotUpdateMainFilename =
+ mainTemplate.outputOptions.hotUpdateMainFilename;
+ const hotUpdateFunction = mainTemplate.outputOptions.hotUpdateFunction;
+ const globalObject = mainTemplate.outputOptions.globalObject;
+ const currentHotUpdateChunkFilename = mainTemplate.getAssetPath(
+ JSON.stringify(hotUpdateChunkFilename),
+ {
+ hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`,
+ hashWithLength: length =>
+ `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`,
+ chunk: {
+ id: '" + chunkId + "'
+ }
+ }
+ );
+ const currentHotUpdateMainFilename = mainTemplate.getAssetPath(
+ JSON.stringify(hotUpdateMainFilename),
+ {
+ hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`,
+ hashWithLength: length =>
+ `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`
+ }
+ );
+
+ return (
+ source +
+ "\n" +
+ `var parentHotUpdateCallback = ${globalObject}[${JSON.stringify(
+ hotUpdateFunction
+ )}];\n` +
+ `${globalObject}[${JSON.stringify(hotUpdateFunction)}] = ` +
+ Template.getFunctionContent(
+ require("./WebWorkerMainTemplate.runtime")
+ )
+ .replace(/\/\/\$semicolon/g, ";")
+ .replace(/\$require\$/g, mainTemplate.requireFn)
+ .replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename)
+ .replace(/\$hotChunkFilename\$/g, currentHotUpdateChunkFilename)
+ .replace(/\$hash\$/g, JSON.stringify(hash))
+ );
+ }
+ );
+ mainTemplate.hooks.hash.tap("WebWorkerMainTemplatePlugin", hash => {
+ hash.update("webworker");
+ hash.update("4");
+ });
+ }
+}
+module.exports = WebWorkerMainTemplatePlugin;
diff --git a/node_modules/webpack/lib/webworker/WebWorkerTemplatePlugin.js b/node_modules/webpack/lib/webworker/WebWorkerTemplatePlugin.js
index 64f1e00f5..5ad89f37a 100644
--- a/node_modules/webpack/lib/webworker/WebWorkerTemplatePlugin.js
+++ b/node_modules/webpack/lib/webworker/WebWorkerTemplatePlugin.js
@@ -1,20 +1,25 @@
-/*
- MIT License http://www.opensource.org/licenses/mit-license.php
- Author Tobias Koppers @sokra
-*/
-"use strict";
-
-const WebWorkerMainTemplatePlugin = require("./WebWorkerMainTemplatePlugin");
-const WebWorkerChunkTemplatePlugin = require("./WebWorkerChunkTemplatePlugin");
-const WebWorkerHotUpdateChunkTemplatePlugin = require("./WebWorkerHotUpdateChunkTemplatePlugin");
-
-class WebWorkerTemplatePlugin {
- apply(compiler) {
- compiler.plugin("this-compilation", compilation => {
- compilation.mainTemplate.apply(new WebWorkerMainTemplatePlugin());
- compilation.chunkTemplate.apply(new WebWorkerChunkTemplatePlugin());
- compilation.hotUpdateChunkTemplate.apply(new WebWorkerHotUpdateChunkTemplatePlugin());
- });
- }
-}
-module.exports = WebWorkerTemplatePlugin;
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+"use strict";
+
+const WebWorkerMainTemplatePlugin = require("./WebWorkerMainTemplatePlugin");
+const WebWorkerChunkTemplatePlugin = require("./WebWorkerChunkTemplatePlugin");
+const WebWorkerHotUpdateChunkTemplatePlugin = require("./WebWorkerHotUpdateChunkTemplatePlugin");
+
+class WebWorkerTemplatePlugin {
+ apply(compiler) {
+ compiler.hooks.thisCompilation.tap(
+ "WebWorkerTemplatePlugin",
+ compilation => {
+ new WebWorkerMainTemplatePlugin().apply(compilation.mainTemplate);
+ new WebWorkerChunkTemplatePlugin().apply(compilation.chunkTemplate);
+ new WebWorkerHotUpdateChunkTemplatePlugin().apply(
+ compilation.hotUpdateChunkTemplate
+ );
+ }
+ );
+ }
+}
+module.exports = WebWorkerTemplatePlugin;