1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = runAsChild;
|
7 |
|
8 | var _utils = require("./utils");
|
9 |
|
10 | function runAsChild(loaderContext, workerContext, options, callback) {
|
11 | workerContext.compiler.runAsChild((error, entries, compilation) => {
|
12 | if (error) {
|
13 | return callback(error);
|
14 | }
|
15 |
|
16 | if (entries[0]) {
|
17 |
|
18 | const workerFilename = entries[0].files[0];
|
19 | let workerSource = compilation.assets[workerFilename].source();
|
20 |
|
21 | if (options.inline === "no-fallback") {
|
22 |
|
23 | delete loaderContext._compilation.assets[workerFilename];
|
24 |
|
25 |
|
26 | if (loaderContext._compilation.assets[`${workerFilename}.map`]) {
|
27 |
|
28 | delete loaderContext._compilation.assets[`${workerFilename}.map`];
|
29 | }
|
30 |
|
31 |
|
32 | workerSource = workerSource.replace(_utils.sourceMappingURLRegex, "");
|
33 |
|
34 | workerSource = workerSource.replace(_utils.sourceURLWebpackRegex, "");
|
35 | }
|
36 |
|
37 | const workerCode = (0, _utils.workerGenerator)(loaderContext, workerFilename, workerSource, options);
|
38 | return callback(null, workerCode);
|
39 | }
|
40 |
|
41 | return callback(new Error(`Failed to compile web worker "${workerContext.request}" request`));
|
42 | });
|
43 | } |
\ | No newline at end of file |