webpack 5.64.0 → 5.64.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/README.md +0 -6
- package/lib/CleanPlugin.js +16 -1
- package/lib/FileSystemInfo.js +45 -13
- package/lib/WatchIgnorePlugin.js +14 -1
- package/lib/Watching.js +31 -17
- package/lib/config/defaults.js +1 -1
- package/lib/container/ContainerEntryModule.js +3 -0
- package/lib/dependencies/CommonJsImportsParserPlugin.js +2 -2
- package/lib/dependencies/URLPlugin.js +1 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +74 -49
- package/lib/javascript/ChunkHelpers.js +33 -0
- package/lib/javascript/JavascriptParser.js +9 -8
- package/lib/javascript/StartupHelpers.js +1 -25
- package/lib/node/NodeWatchFileSystem.js +85 -31
- package/lib/sharing/ConsumeSharedRuntimeModule.js +4 -4
- package/lib/util/create-schema-validation.js +9 -2
- package/lib/util/fs.js +11 -0
- package/lib/util/hash/md4.js +2 -2
- package/lib/util/hash/xxhash64.js +1 -1
- package/lib/webpack.js +9 -1
- package/module.d.ts +1 -1
- package/package.json +4 -4
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/plugins/DllReferencePlugin.check.js +1 -1
- package/schemas/plugins/HashedModuleIdsPlugin.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/asset/AssetParserOptions.check.js +1 -1
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +1 -1
- package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +1 -1
- package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +1 -1
- package/types.d.ts +30 -0
package/README.md
CHANGED
@@ -9,8 +9,6 @@
|
|
9
9
|
|
10
10
|
[![node][node]][node-url]
|
11
11
|
[![deps][deps]][deps-url]
|
12
|
-
[![tests][tests]][tests-url]
|
13
|
-
[![builds][builds]][builds-url]
|
14
12
|
[![builds2][builds2]][builds2-url]
|
15
13
|
[![coverage][cover]][cover-url]
|
16
14
|
[![licenses][licenses]][licenses-url]
|
@@ -703,12 +701,8 @@ src="https://static.monei.net/monei-logo.svg" height="30" alt="MONEI"></a>
|
|
703
701
|
[node-url]: https://nodejs.org
|
704
702
|
[deps]: https://img.shields.io/david/webpack/webpack.svg
|
705
703
|
[deps-url]: https://david-dm.org/webpack/webpack
|
706
|
-
[tests]: https://img.shields.io/travis/webpack/webpack/main.svg
|
707
|
-
[tests-url]: https://travis-ci.org/webpack/webpack
|
708
704
|
[prs]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg
|
709
705
|
[prs-url]: https://webpack.js.org/contribute/
|
710
|
-
[builds-url]: https://ci.appveyor.com/project/sokra/webpack/branch/main
|
711
|
-
[builds]: https://ci.appveyor.com/api/projects/status/github/webpack/webpack?svg=true
|
712
706
|
[builds2]: https://dev.azure.com/webpack/webpack/_apis/build/status/webpack.webpack
|
713
707
|
[builds2-url]: https://dev.azure.com/webpack/webpack/_build/latest?definitionId=3
|
714
708
|
[licenses-url]: https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fwebpack%2Fwebpack?ref=badge_shield
|
package/lib/CleanPlugin.js
CHANGED
@@ -16,6 +16,7 @@ const processAsyncTree = require("./util/processAsyncTree");
|
|
16
16
|
/** @typedef {import("./Compiler")} Compiler */
|
17
17
|
/** @typedef {import("./logging/Logger").Logger} Logger */
|
18
18
|
/** @typedef {import("./util/fs").OutputFileSystem} OutputFileSystem */
|
19
|
+
/** @typedef {import("./util/fs").StatsCallback} StatsCallback */
|
19
20
|
|
20
21
|
/** @typedef {(function(string):boolean)|RegExp} IgnoreItem */
|
21
22
|
/** @typedef {function(IgnoreItem): void} AddToIgnoreCallback */
|
@@ -102,6 +103,20 @@ const getDiffToOldAssets = (currentAssets, oldAssets) => {
|
|
102
103
|
return diff;
|
103
104
|
};
|
104
105
|
|
106
|
+
/**
|
107
|
+
* @param {OutputFileSystem} fs filesystem
|
108
|
+
* @param {string} filename path to file
|
109
|
+
* @param {StatsCallback} callback callback for provided filename
|
110
|
+
* @returns {void}
|
111
|
+
*/
|
112
|
+
const doStat = (fs, filename, callback) => {
|
113
|
+
if ("lstat" in fs) {
|
114
|
+
fs.lstat(filename, callback);
|
115
|
+
} else {
|
116
|
+
fs.stat(filename, callback);
|
117
|
+
}
|
118
|
+
};
|
119
|
+
|
105
120
|
/**
|
106
121
|
* @param {OutputFileSystem} fs filesystem
|
107
122
|
* @param {string} outputPath output path
|
@@ -150,7 +165,7 @@ const applyDiff = (fs, outputPath, dry, logger, diff, isKept, callback) => {
|
|
150
165
|
log(`${filename} will be kept`);
|
151
166
|
return process.nextTick(callback);
|
152
167
|
}
|
153
|
-
fs
|
168
|
+
doStat(fs, path, (err, stats) => {
|
154
169
|
if (err) return handleError(err);
|
155
170
|
if (!stats.isDirectory()) {
|
156
171
|
push({
|
package/lib/FileSystemInfo.js
CHANGED
@@ -2016,8 +2016,7 @@ class FileSystemInfo {
|
|
2016
2016
|
}
|
2017
2017
|
return capturedItems;
|
2018
2018
|
};
|
2019
|
-
|
2020
|
-
const capturedFiles = captureNonManaged(files, managedFiles);
|
2019
|
+
const processCapturedFiles = capturedFiles => {
|
2021
2020
|
switch (mode) {
|
2022
2021
|
case 3:
|
2023
2022
|
this._fileTshsOptimization.optimize(snapshot, capturedFiles);
|
@@ -2094,12 +2093,11 @@ class FileSystemInfo {
|
|
2094
2093
|
}
|
2095
2094
|
break;
|
2096
2095
|
}
|
2096
|
+
};
|
2097
|
+
if (files) {
|
2098
|
+
processCapturedFiles(captureNonManaged(files, managedFiles));
|
2097
2099
|
}
|
2098
|
-
|
2099
|
-
const capturedDirectories = captureNonManaged(
|
2100
|
-
directories,
|
2101
|
-
managedContexts
|
2102
|
-
);
|
2100
|
+
const processCapturedDirectories = capturedDirectories => {
|
2103
2101
|
switch (mode) {
|
2104
2102
|
case 3:
|
2105
2103
|
this._contextTshsOptimization.optimize(snapshot, capturedDirectories);
|
@@ -2219,9 +2217,13 @@ class FileSystemInfo {
|
|
2219
2217
|
}
|
2220
2218
|
break;
|
2221
2219
|
}
|
2220
|
+
};
|
2221
|
+
if (directories) {
|
2222
|
+
processCapturedDirectories(
|
2223
|
+
captureNonManaged(directories, managedContexts)
|
2224
|
+
);
|
2222
2225
|
}
|
2223
|
-
|
2224
|
-
const capturedMissing = captureNonManaged(missing, managedMissing);
|
2226
|
+
const processCapturedMissing = capturedMissing => {
|
2225
2227
|
this._missingExistenceOptimization.optimize(snapshot, capturedMissing);
|
2226
2228
|
for (const path of capturedMissing) {
|
2227
2229
|
const cache = this._fileTimestamps.get(path);
|
@@ -2246,11 +2248,17 @@ class FileSystemInfo {
|
|
2246
2248
|
});
|
2247
2249
|
}
|
2248
2250
|
}
|
2251
|
+
};
|
2252
|
+
if (missing) {
|
2253
|
+
processCapturedMissing(captureNonManaged(missing, managedMissing));
|
2249
2254
|
}
|
2250
2255
|
this._managedItemInfoOptimization.optimize(snapshot, managedItems);
|
2251
2256
|
for (const path of managedItems) {
|
2252
2257
|
const cache = this._managedItems.get(path);
|
2253
2258
|
if (cache !== undefined) {
|
2259
|
+
if (cache !== "missing") {
|
2260
|
+
managedFiles.add(join(this.fs, path, "package.json"));
|
2261
|
+
}
|
2254
2262
|
managedItemInfo.set(path, cache);
|
2255
2263
|
} else {
|
2256
2264
|
jobs++;
|
@@ -2262,9 +2270,26 @@ class FileSystemInfo {
|
|
2262
2270
|
);
|
2263
2271
|
}
|
2264
2272
|
jobError();
|
2265
|
-
} else {
|
2273
|
+
} else if (entry) {
|
2274
|
+
if (entry !== "missing") {
|
2275
|
+
managedFiles.add(join(this.fs, path, "package.json"));
|
2276
|
+
}
|
2266
2277
|
managedItemInfo.set(path, entry);
|
2267
2278
|
jobDone();
|
2279
|
+
} else {
|
2280
|
+
// Fallback to normal snapshotting
|
2281
|
+
const process = (set, fn) => {
|
2282
|
+
if (set.size === 0) return;
|
2283
|
+
const captured = new Set();
|
2284
|
+
for (const file of set) {
|
2285
|
+
if (file.startsWith(path)) captured.add(file);
|
2286
|
+
}
|
2287
|
+
if (captured.size > 0) fn(captured);
|
2288
|
+
};
|
2289
|
+
process(managedFiles, processCapturedFiles);
|
2290
|
+
process(managedContexts, processCapturedDirectories);
|
2291
|
+
process(managedMissing, processCapturedMissing);
|
2292
|
+
jobDone();
|
2268
2293
|
}
|
2269
2294
|
});
|
2270
2295
|
}
|
@@ -3477,9 +3502,10 @@ class FileSystemInfo {
|
|
3477
3502
|
this._managedItems.set(path, "nested");
|
3478
3503
|
return callback(null, "nested");
|
3479
3504
|
}
|
3480
|
-
|
3481
|
-
|
3482
|
-
|
3505
|
+
this.logger.warn(
|
3506
|
+
`Managed item ${path} isn't a directory or doesn't contain a package.json (see snapshot.managedPaths option)`
|
3507
|
+
);
|
3508
|
+
return callback();
|
3483
3509
|
});
|
3484
3510
|
return;
|
3485
3511
|
}
|
@@ -3491,6 +3517,12 @@ class FileSystemInfo {
|
|
3491
3517
|
} catch (e) {
|
3492
3518
|
return callback(e);
|
3493
3519
|
}
|
3520
|
+
if (!data.name) {
|
3521
|
+
this.logger.warn(
|
3522
|
+
`${packageJsonPath} doesn't contain a "name" property (see snapshot.managedPaths option)`
|
3523
|
+
);
|
3524
|
+
return callback();
|
3525
|
+
}
|
3494
3526
|
const info = `${data.name || ""}@${data.version || ""}`;
|
3495
3527
|
this._managedItems.set(path, info);
|
3496
3528
|
callback(null, info);
|
package/lib/WatchIgnorePlugin.js
CHANGED
@@ -87,7 +87,20 @@ class IgnoringWatchFileSystem {
|
|
87
87
|
fileTimestamps.set(path, IGNORE_TIME_ENTRY);
|
88
88
|
}
|
89
89
|
return fileTimestamps;
|
90
|
-
}
|
90
|
+
},
|
91
|
+
getInfo:
|
92
|
+
watcher.getInfo &&
|
93
|
+
(() => {
|
94
|
+
const info = watcher.getInfo();
|
95
|
+
const { fileTimeInfoEntries, contextTimeInfoEntries } = info;
|
96
|
+
for (const path of ignoredFiles) {
|
97
|
+
fileTimeInfoEntries.set(path, IGNORE_TIME_ENTRY);
|
98
|
+
}
|
99
|
+
for (const path of ignoredDirs) {
|
100
|
+
contextTimeInfoEntries.set(path, IGNORE_TIME_ENTRY);
|
101
|
+
}
|
102
|
+
return info;
|
103
|
+
})
|
91
104
|
};
|
92
105
|
}
|
93
106
|
}
|
package/lib/Watching.js
CHANGED
@@ -109,30 +109,44 @@ class Watching {
|
|
109
109
|
this.lastWatcherStartTime = Date.now();
|
110
110
|
}
|
111
111
|
this.compiler.fsStartTime = Date.now();
|
112
|
-
|
113
|
-
changedFiles
|
114
|
-
|
112
|
+
if (
|
113
|
+
changedFiles &&
|
114
|
+
removedFiles &&
|
115
|
+
fileTimeInfoEntries &&
|
116
|
+
contextTimeInfoEntries
|
117
|
+
) {
|
118
|
+
this._mergeWithCollected(changedFiles, removedFiles);
|
119
|
+
this.compiler.fileTimestamps = fileTimeInfoEntries;
|
120
|
+
this.compiler.contextTimestamps = contextTimeInfoEntries;
|
121
|
+
} else if (this.pausedWatcher) {
|
122
|
+
if (this.pausedWatcher.getInfo) {
|
123
|
+
const {
|
124
|
+
changes,
|
125
|
+
removals,
|
126
|
+
fileTimeInfoEntries,
|
127
|
+
contextTimeInfoEntries
|
128
|
+
} = this.pausedWatcher.getInfo();
|
129
|
+
this._mergeWithCollected(changes, removals);
|
130
|
+
this.compiler.fileTimestamps = fileTimeInfoEntries;
|
131
|
+
this.compiler.contextTimestamps = contextTimeInfoEntries;
|
132
|
+
} else {
|
133
|
+
this._mergeWithCollected(
|
115
134
|
this.pausedWatcher.getAggregatedChanges &&
|
116
|
-
|
117
|
-
(this.compiler.removedFiles =
|
118
|
-
removedFiles ||
|
119
|
-
(this.pausedWatcher &&
|
135
|
+
this.pausedWatcher.getAggregatedChanges(),
|
120
136
|
this.pausedWatcher.getAggregatedRemovals &&
|
121
|
-
|
122
|
-
|
123
|
-
|
137
|
+
this.pausedWatcher.getAggregatedRemovals()
|
138
|
+
);
|
139
|
+
this.compiler.fileTimestamps =
|
140
|
+
this.pausedWatcher.getFileTimeInfoEntries();
|
141
|
+
this.compiler.contextTimestamps =
|
142
|
+
this.pausedWatcher.getContextTimeInfoEntries();
|
143
|
+
}
|
144
|
+
}
|
124
145
|
this.compiler.modifiedFiles = this._collectedChangedFiles;
|
125
146
|
this._collectedChangedFiles = undefined;
|
126
147
|
this.compiler.removedFiles = this._collectedRemovedFiles;
|
127
148
|
this._collectedRemovedFiles = undefined;
|
128
149
|
|
129
|
-
this.compiler.fileTimestamps =
|
130
|
-
fileTimeInfoEntries ||
|
131
|
-
(this.pausedWatcher && this.pausedWatcher.getFileTimeInfoEntries());
|
132
|
-
this.compiler.contextTimestamps =
|
133
|
-
contextTimeInfoEntries ||
|
134
|
-
(this.pausedWatcher && this.pausedWatcher.getContextTimeInfoEntries());
|
135
|
-
|
136
150
|
const run = () => {
|
137
151
|
if (this.compiler.idle) {
|
138
152
|
return this.compiler.cache.endIdle(err => {
|
package/lib/config/defaults.js
CHANGED
@@ -383,7 +383,7 @@ const applySnapshotDefaults = (snapshot, { production, futureDefaults }) => {
|
|
383
383
|
return [path.resolve(match[1], "unplugged")];
|
384
384
|
}
|
385
385
|
} else {
|
386
|
-
const match = /^(.+?[\\/]node_modules
|
386
|
+
const match = /^(.+?[\\/]node_modules[\\/])/.exec(
|
387
387
|
// eslint-disable-next-line node/no-extraneous-require
|
388
388
|
require.resolve("watchpack")
|
389
389
|
);
|
@@ -10,6 +10,7 @@ const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
|
|
10
10
|
const Module = require("../Module");
|
11
11
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
12
12
|
const Template = require("../Template");
|
13
|
+
const StaticExportsDependency = require("../dependencies/StaticExportsDependency");
|
13
14
|
const makeSerializable = require("../util/makeSerializable");
|
14
15
|
const ContainerExposedDependency = require("./ContainerExposedDependency");
|
15
16
|
|
@@ -104,6 +105,7 @@ class ContainerEntryModule extends Module {
|
|
104
105
|
strict: true,
|
105
106
|
topLevelDeclarations: new Set(["moduleMap", "get", "init"])
|
106
107
|
};
|
108
|
+
this.buildMeta.exportsType = "namespace";
|
107
109
|
|
108
110
|
this.clearDependenciesAndBlocks();
|
109
111
|
|
@@ -127,6 +129,7 @@ class ContainerEntryModule extends Module {
|
|
127
129
|
}
|
128
130
|
this.addBlock(block);
|
129
131
|
}
|
132
|
+
this.addDependency(new StaticExportsDependency(["get", "init"], false));
|
130
133
|
|
131
134
|
callback();
|
132
135
|
}
|
@@ -282,7 +282,7 @@ class CommonJsImportsParserPlugin {
|
|
282
282
|
dep.asiSafe = !parser.isAsiPosition(expr.range[0]);
|
283
283
|
dep.optional = !!parser.scope.inTry;
|
284
284
|
dep.loc = expr.loc;
|
285
|
-
parser.state.
|
285
|
+
parser.state.current.addDependency(dep);
|
286
286
|
return true;
|
287
287
|
}
|
288
288
|
};
|
@@ -299,7 +299,7 @@ class CommonJsImportsParserPlugin {
|
|
299
299
|
dep.asiSafe = !parser.isAsiPosition(expr.range[0]);
|
300
300
|
dep.optional = !!parser.scope.inTry;
|
301
301
|
dep.loc = expr.callee.loc;
|
302
|
-
parser.state.
|
302
|
+
parser.state.current.addDependency(dep);
|
303
303
|
parser.walkExpressions(expr.arguments);
|
304
304
|
return true;
|
305
305
|
}
|
@@ -5,18 +5,16 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
-
const { ConcatSource
|
8
|
+
const { ConcatSource } = require("webpack-sources");
|
9
9
|
const { RuntimeGlobals } = require("..");
|
10
10
|
const HotUpdateChunk = require("../HotUpdateChunk");
|
11
11
|
const Template = require("../Template");
|
12
|
+
const { getAllChunks } = require("../javascript/ChunkHelpers");
|
12
13
|
const {
|
13
14
|
getCompilationHooks,
|
14
15
|
getChunkFilenameTemplate
|
15
16
|
} = require("../javascript/JavascriptModulesPlugin");
|
16
|
-
const {
|
17
|
-
generateEntryStartup,
|
18
|
-
updateHashForEntryStartup
|
19
|
-
} = require("../javascript/StartupHelpers");
|
17
|
+
const { updateHashForEntryStartup } = require("../javascript/StartupHelpers");
|
20
18
|
|
21
19
|
/** @typedef {import("../Compiler")} Compiler */
|
22
20
|
|
@@ -84,63 +82,90 @@ class ModuleChunkFormatPlugin {
|
|
84
82
|
}
|
85
83
|
)
|
86
84
|
.split("/");
|
87
|
-
const runtimeOutputName = compilation
|
88
|
-
.getPath(
|
89
|
-
getChunkFilenameTemplate(
|
90
|
-
runtimeChunk,
|
91
|
-
compilation.outputOptions
|
92
|
-
),
|
93
|
-
{
|
94
|
-
chunk: runtimeChunk,
|
95
|
-
contentHashType: "javascript"
|
96
|
-
}
|
97
|
-
)
|
98
|
-
.split("/");
|
99
85
|
|
100
86
|
// remove filename, we only need the directory
|
101
|
-
|
87
|
+
currentOutputName.pop();
|
102
88
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
89
|
+
const getRelativePath = chunk => {
|
90
|
+
const baseOutputName = currentOutputName.slice();
|
91
|
+
const chunkOutputName = compilation
|
92
|
+
.getPath(
|
93
|
+
getChunkFilenameTemplate(
|
94
|
+
chunk,
|
95
|
+
compilation.outputOptions
|
96
|
+
),
|
97
|
+
{
|
98
|
+
chunk: chunk,
|
99
|
+
contentHashType: "javascript"
|
100
|
+
}
|
101
|
+
)
|
102
|
+
.split("/");
|
112
103
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
104
|
+
// remove common parts
|
105
|
+
while (
|
106
|
+
baseOutputName.length > 0 &&
|
107
|
+
chunkOutputName.length > 0 &&
|
108
|
+
baseOutputName[0] === chunkOutputName[0]
|
109
|
+
) {
|
110
|
+
baseOutputName.shift();
|
111
|
+
chunkOutputName.shift();
|
112
|
+
}
|
113
|
+
// create final path
|
114
|
+
return (
|
115
|
+
(baseOutputName.length > 0
|
116
|
+
? "../".repeat(baseOutputName.length)
|
117
|
+
: "./") + chunkOutputName.join("/")
|
118
|
+
);
|
119
|
+
};
|
118
120
|
|
119
121
|
const entrySource = new ConcatSource();
|
120
122
|
entrySource.add(source);
|
121
123
|
entrySource.add(";\n\n// load runtime\n");
|
122
124
|
entrySource.add(
|
123
125
|
`import __webpack_require__ from ${JSON.stringify(
|
124
|
-
|
125
|
-
)};\n`
|
126
|
-
);
|
127
|
-
entrySource.add(
|
128
|
-
`import * as __webpack_self_exports__ from ${JSON.stringify(
|
129
|
-
"./" + outputFilename
|
126
|
+
getRelativePath(runtimeChunk)
|
130
127
|
)};\n`
|
131
128
|
);
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
entries,
|
140
|
-
chunk,
|
141
|
-
false
|
142
|
-
)
|
129
|
+
|
130
|
+
const startupSource = new ConcatSource();
|
131
|
+
startupSource.add(
|
132
|
+
`var __webpack_exec__ = ${runtimeTemplate.returningFunction(
|
133
|
+
`__webpack_require__(${RuntimeGlobals.entryModuleId} = moduleId)`,
|
134
|
+
"moduleId"
|
135
|
+
)}\n`
|
143
136
|
);
|
137
|
+
|
138
|
+
const loadedChunks = new Set();
|
139
|
+
let index = 0;
|
140
|
+
for (let i = 0; i < entries.length; i++) {
|
141
|
+
const [module, entrypoint] = entries[i];
|
142
|
+
const final = i + 1 === entries.length;
|
143
|
+
const moduleId = chunkGraph.getModuleId(module);
|
144
|
+
const chunks = getAllChunks(
|
145
|
+
entrypoint,
|
146
|
+
runtimeChunk,
|
147
|
+
undefined
|
148
|
+
);
|
149
|
+
for (const chunk of chunks) {
|
150
|
+
if (loadedChunks.has(chunk)) continue;
|
151
|
+
loadedChunks.add(chunk);
|
152
|
+
startupSource.add(
|
153
|
+
`import * as __webpack_chunk_${index}__ from ${JSON.stringify(
|
154
|
+
getRelativePath(chunk)
|
155
|
+
)};\n`
|
156
|
+
);
|
157
|
+
startupSource.add(
|
158
|
+
`${RuntimeGlobals.externalInstallChunk}(__webpack_chunk_${index}__);\n`
|
159
|
+
);
|
160
|
+
index++;
|
161
|
+
}
|
162
|
+
startupSource.add(
|
163
|
+
`${
|
164
|
+
final ? "var __webpack_exports__ = " : ""
|
165
|
+
}__webpack_exec__(${JSON.stringify(moduleId)});\n`
|
166
|
+
);
|
167
|
+
}
|
168
|
+
|
144
169
|
entrySource.add(
|
145
170
|
hooks.renderStartup.call(
|
146
171
|
startupSource,
|
@@ -0,0 +1,33 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
const Entrypoint = require("../Entrypoint");
|
9
|
+
|
10
|
+
/** @typedef {import("../Chunk")} Chunk */
|
11
|
+
|
12
|
+
/**
|
13
|
+
* @param {Entrypoint} entrypoint a chunk group
|
14
|
+
* @param {Chunk} excludedChunk1 current chunk which is excluded
|
15
|
+
* @param {Chunk} excludedChunk2 runtime chunk which is excluded
|
16
|
+
* @returns {Set<Chunk>} chunks
|
17
|
+
*/
|
18
|
+
const getAllChunks = (entrypoint, excludedChunk1, excludedChunk2) => {
|
19
|
+
const queue = new Set([entrypoint]);
|
20
|
+
const chunks = new Set();
|
21
|
+
for (const entrypoint of queue) {
|
22
|
+
for (const chunk of entrypoint.chunks) {
|
23
|
+
if (chunk === excludedChunk1) continue;
|
24
|
+
if (chunk === excludedChunk2) continue;
|
25
|
+
chunks.add(chunk);
|
26
|
+
}
|
27
|
+
for (const parent of entrypoint.parentsIterable) {
|
28
|
+
if (parent instanceof Entrypoint) queue.add(parent);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
return chunks;
|
32
|
+
};
|
33
|
+
exports.getAllChunks = getAllChunks;
|
@@ -1189,14 +1189,15 @@ class JavascriptParser extends Parser {
|
|
1189
1189
|
const node = /** @type {TaggedTemplateExpressionNode} */ (_node);
|
1190
1190
|
const tag = this.evaluateExpression(node.tag);
|
1191
1191
|
|
1192
|
-
if (tag.isIdentifier() && tag.identifier
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1192
|
+
if (tag.isIdentifier() && tag.identifier === "String.raw") {
|
1193
|
+
const { quasis, parts } = getSimplifiedTemplateResult(
|
1194
|
+
"raw",
|
1195
|
+
node.quasi
|
1196
|
+
);
|
1197
|
+
return new BasicEvaluatedExpression()
|
1198
|
+
.setTemplateString(quasis, parts, "raw")
|
1199
|
+
.setRange(node.range);
|
1200
|
+
}
|
1200
1201
|
});
|
1201
1202
|
|
1202
1203
|
this.hooks.evaluateCallExpressionMember
|
@@ -5,10 +5,10 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
-
const Entrypoint = require("../Entrypoint");
|
9
8
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
10
9
|
const Template = require("../Template");
|
11
10
|
const { isSubset } = require("../util/SetHelpers");
|
11
|
+
const { getAllChunks } = require("./ChunkHelpers");
|
12
12
|
const { chunkHasJs } = require("./JavascriptModulesPlugin");
|
13
13
|
|
14
14
|
/** @typedef {import("../util/Hash")} Hash */
|
@@ -19,30 +19,6 @@ const { chunkHasJs } = require("./JavascriptModulesPlugin");
|
|
19
19
|
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
20
20
|
/** @typedef {(string|number)[]} EntryItem */
|
21
21
|
|
22
|
-
// TODO move to this file to ../javascript/ChunkHelpers.js
|
23
|
-
|
24
|
-
/**
|
25
|
-
* @param {Entrypoint} entrypoint a chunk group
|
26
|
-
* @param {Chunk} excludedChunk1 current chunk which is excluded
|
27
|
-
* @param {Chunk} excludedChunk2 runtime chunk which is excluded
|
28
|
-
* @returns {Set<Chunk>} chunks
|
29
|
-
*/
|
30
|
-
const getAllChunks = (entrypoint, excludedChunk1, excludedChunk2) => {
|
31
|
-
const queue = new Set([entrypoint]);
|
32
|
-
const chunks = new Set();
|
33
|
-
for (const entrypoint of queue) {
|
34
|
-
for (const chunk of entrypoint.chunks) {
|
35
|
-
if (chunk === excludedChunk1) continue;
|
36
|
-
if (chunk === excludedChunk2) continue;
|
37
|
-
chunks.add(chunk);
|
38
|
-
}
|
39
|
-
for (const parent of entrypoint.parentsIterable) {
|
40
|
-
if (parent instanceof Entrypoint) queue.add(parent);
|
41
|
-
}
|
42
|
-
}
|
43
|
-
return chunks;
|
44
|
-
};
|
45
|
-
|
46
22
|
const EXPORT_PREFIX = "var __webpack_exports__ = ";
|
47
23
|
|
48
24
|
/**
|