@depup/webpack 5.110.1-depup.0 → 5.110.3-depup.0
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.
- package/README.md +4 -4
- package/changes.json +3 -3
- package/lib/ChunkGraph.js +20 -18
- package/lib/Compilation.js +1 -1
- package/lib/ConcatenationScope.js +25 -35
- package/lib/DotenvPlugin.js +41 -13
- package/lib/ExportsInfo.js +10 -0
- package/lib/FlagDependencyUsagePlugin.js +8 -2
- package/lib/NormalModule.js +13 -20
- package/lib/RuntimePlugin.js +3 -0
- package/lib/RuntimeTemplate.js +437 -432
- package/lib/async-modules/AsyncModuleHelpers.js +10 -4
- package/lib/config/defaults.js +26 -16
- package/lib/config/normalization.js +18 -8
- package/lib/css/CssLoadingRuntimeModule.js +32 -13
- package/lib/css/CssModulesPlugin.js +9 -17
- package/lib/css/data.js +13 -3
- package/lib/css/syntax.js +78 -10
- package/lib/dependencies/CommonJsRequireDependency.js +18 -4
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +20 -7
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +10 -4
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +2 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +143 -17
- package/lib/dependencies/HarmonyImportDependency.js +94 -41
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +93 -14
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +114 -0
- package/lib/dependencies/HtmlEntryDependency.js +12 -2
- package/lib/dependencies/ImportContextDependency.js +43 -3
- package/lib/dependencies/ImportDependency.js +8 -29
- package/lib/dependencies/ImportParserPlugin.js +24 -14
- package/lib/dependencies/RequireHeaderDependency.js +20 -21
- package/lib/dependencies/WorkerAndWorkletPlugin.js +1 -0
- package/lib/dependencies/WorkerDependency.js +6 -12
- package/lib/dependencies/WorkletDependency.js +7 -11
- package/lib/dependencies/importOptionsCheck.js +47 -0
- package/lib/errors/DotenvFileError.js +29 -0
- package/lib/errors/ImportedBindingAssignmentError.js +30 -0
- package/lib/esm/ModuleChunkLoadingPlugin.js +6 -9
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -1
- package/lib/html/HtmlModulesPlugin.js +84 -38
- package/lib/html/syntax.js +417 -169
- package/lib/javascript/JavascriptModulesPlugin.js +5 -10
- package/lib/loaders/LoaderRunner.js +33 -5
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +8 -15
- package/lib/optimize/ConcatenatedModule.js +46 -7
- package/lib/optimize/ConstExportsPlugin.js +5 -0
- package/lib/optimize/InlineExports.js +121 -0
- package/lib/optimize/RealContentHashPlugin.js +111 -35
- package/lib/prefetch/ResourceHintPlugin.js +12 -13
- package/lib/runtime/AsyncModuleRuntimeModule.js +5 -1
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +11 -1
- package/lib/schemes/HttpUriPlugin.js +22 -5
- package/lib/serialization/FileMiddleware.js +15 -2
- package/lib/typescript/TypeScriptPlugin.js +8 -10
- package/lib/util/ArrayQueue.js +3 -3
- package/lib/util/SourceProcessor.js +24 -8
- package/lib/util/URLAbsoluteSpecifier.js +3 -1
- package/lib/util/conventions.js +5 -1
- package/lib/util/createMappings.js +25 -3
- package/lib/util/internalSerializables.js +2 -0
- package/lib/util/removeBOM.js +82 -1
- package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +5 -3
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +5 -3
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +7 -12
- package/lib/web/FetchCompileAsyncWasmPlugin.js +10 -6
- package/lib/web/FetchCompileWasmPlugin.js +4 -2
- package/package.json +7 -7
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +9 -10
- package/types.d.ts +95 -27
|
@@ -31,7 +31,7 @@ const preloadModuleType = require("../util/preloadModuleType");
|
|
|
31
31
|
const {
|
|
32
32
|
PUBLIC_PATH_AUTO: autoPlaceholder
|
|
33
33
|
} = require("../util/publicPathPlaceholder");
|
|
34
|
-
const
|
|
34
|
+
const { removeBOMFromResult } = require("../util/removeBOM");
|
|
35
35
|
const HtmlModule = require("./HtmlModule");
|
|
36
36
|
|
|
37
37
|
const getMimeTypes = memoize(() => require("../util/mimeTypes"));
|
|
@@ -222,6 +222,9 @@ const isIntegrityEnabled = (integrity) =>
|
|
|
222
222
|
// `\.html`/`\.css` request matchers for the synthetic `output.html` wrapper.
|
|
223
223
|
const HTML_REQUEST_RE = /\.html(\?|$)/i;
|
|
224
224
|
const CSS_REQUEST_RE = /\.css(\?|$)/i;
|
|
225
|
+
// The wrapper's own resource — the media type must end here, so that a
|
|
226
|
+
// `data:text/htmlx,` entry (JavaScript to `DataUriPlugin`) is not one.
|
|
227
|
+
const HTML_DATA_URL_RE = /^data:text\/html[,;]/i;
|
|
225
228
|
|
|
226
229
|
/**
|
|
227
230
|
* Requests an `output.html` page must load for an entry: its `dependOn`
|
|
@@ -238,7 +241,12 @@ const collectHtmlEntryRequests = (name, entries) => {
|
|
|
238
241
|
const seenRequests = new Set();
|
|
239
242
|
/** @type {Set<string>} */
|
|
240
243
|
const visited = new Set();
|
|
241
|
-
|
|
244
|
+
/**
|
|
245
|
+
* Collects an entry's non-html requests, `dependOn` entries included.
|
|
246
|
+
* @param {string} entryName entry to walk
|
|
247
|
+
* @returns {void}
|
|
248
|
+
*/
|
|
249
|
+
const walk = (entryName) => {
|
|
242
250
|
if (visited.has(entryName)) return;
|
|
243
251
|
visited.add(entryName);
|
|
244
252
|
const desc = entries[entryName];
|
|
@@ -610,12 +618,13 @@ class HtmlModulesPlugin {
|
|
|
610
618
|
);
|
|
611
619
|
}
|
|
612
620
|
const { htmlModules } = getState(compilation);
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
621
|
+
/**
|
|
622
|
+
* Records HTML modules as they are built or restored, so `finishMake`
|
|
623
|
+
* creates their entries without scanning the whole module graph.
|
|
624
|
+
* @param {import("../Module")} module built or restored module
|
|
625
|
+
* @returns {void}
|
|
626
|
+
*/
|
|
627
|
+
const trackHtmlModule = (module) => {
|
|
619
628
|
if (module.type !== HTML_MODULE_TYPE) return;
|
|
620
629
|
// enabled here, not on the compilation hook: an integrity build
|
|
621
630
|
// with no html module must not load the generator
|
|
@@ -714,28 +723,64 @@ class HtmlModulesPlugin {
|
|
|
714
723
|
// An inlined chunk file is dead weight once nothing else references
|
|
715
724
|
// it by URL (another page's tag, or the runtime's async chunk map);
|
|
716
725
|
// a content-hashed filename makes a substring hit a real reference.
|
|
726
|
+
/** @type {Set<string>} */
|
|
727
|
+
const deletionCandidates = new Set(inlinedFiles);
|
|
728
|
+
// A wrapper entry's chunk only rebuilds the page's own markup; the
|
|
729
|
+
// page loads the `<script src>` entries the parser split out of it.
|
|
730
|
+
for (const entrypoint of compilation.entrypoints.values()) {
|
|
731
|
+
const chunk = entrypoint.getEntrypointChunk();
|
|
732
|
+
if (!chunk) continue;
|
|
733
|
+
let wrapperOnly = false;
|
|
734
|
+
for (const entryModule of compilation.chunkGraph.getChunkEntryModulesIterable(
|
|
735
|
+
chunk
|
|
736
|
+
)) {
|
|
737
|
+
const { resource } = /** @type {import("../NormalModule")} */ (
|
|
738
|
+
entryModule
|
|
739
|
+
);
|
|
740
|
+
wrapperOnly =
|
|
741
|
+
typeof resource === "string" &&
|
|
742
|
+
HTML_DATA_URL_RE.test(resource);
|
|
743
|
+
if (!wrapperOnly) break;
|
|
744
|
+
}
|
|
745
|
+
if (!wrapperOnly) continue;
|
|
746
|
+
for (const file of chunk.files) deletionCandidates.add(file);
|
|
747
|
+
}
|
|
717
748
|
// Materialize each other asset's source once (it can be expensive to
|
|
718
|
-
// render) and test all
|
|
719
|
-
// re-materializing every asset per
|
|
720
|
-
if (
|
|
749
|
+
// render) and test all candidates against it, rather than
|
|
750
|
+
// re-materializing every asset per candidate.
|
|
751
|
+
if (deletionCandidates.size > 0) {
|
|
721
752
|
/** @type {Set<string>} */
|
|
722
753
|
const stillReferenced = new Set();
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
}
|
|
754
|
+
/** @type {string[]} */
|
|
755
|
+
const pending = [];
|
|
756
|
+
/**
|
|
757
|
+
* @param {string} name asset whose source may name a candidate
|
|
758
|
+
*/
|
|
759
|
+
const markReferenced = (name) => {
|
|
730
760
|
const source = compilation.assets[name].source();
|
|
731
|
-
if (typeof source !== "string")
|
|
732
|
-
for (const file of
|
|
761
|
+
if (typeof source !== "string") return;
|
|
762
|
+
for (const file of deletionCandidates) {
|
|
733
763
|
if (!stillReferenced.has(file) && source.includes(file)) {
|
|
734
764
|
stillReferenced.add(file);
|
|
765
|
+
pending.push(file);
|
|
735
766
|
}
|
|
736
767
|
}
|
|
768
|
+
};
|
|
769
|
+
for (const name of Object.keys(compilation.assets)) {
|
|
770
|
+
if (
|
|
771
|
+
deletionCandidates.has(name) ||
|
|
772
|
+
stillReferenced.size === deletionCandidates.size
|
|
773
|
+
) {
|
|
774
|
+
continue;
|
|
775
|
+
}
|
|
776
|
+
markReferenced(name);
|
|
777
|
+
}
|
|
778
|
+
// A kept candidate can reference another through its async chunk
|
|
779
|
+
// map, so follow each until nothing new is kept.
|
|
780
|
+
while (pending.length > 0) {
|
|
781
|
+
markReferenced(/** @type {string} */ (pending.pop()));
|
|
737
782
|
}
|
|
738
|
-
for (const file of
|
|
783
|
+
for (const file of deletionCandidates) {
|
|
739
784
|
if (!stillReferenced.has(file)) compilation.deleteAsset(file);
|
|
740
785
|
}
|
|
741
786
|
}
|
|
@@ -896,14 +941,14 @@ class HtmlModulesPlugin {
|
|
|
896
941
|
PLUGIN_NAME,
|
|
897
942
|
(result, module) => {
|
|
898
943
|
if (module.type === HTML_MODULE_TYPE) {
|
|
899
|
-
const [source, ...rest] = result;
|
|
944
|
+
const [source, ...rest] = removeBOMFromResult(result);
|
|
900
945
|
// `applyTemplate` is a no-op unless `module.parser.html.template`
|
|
901
946
|
// is set. Running it here (where the returned source becomes the
|
|
902
947
|
// module's stored source) keeps the parser's dependency offsets
|
|
903
948
|
// and the generator's render base in sync.
|
|
904
949
|
const parser = /** @type {HtmlParser} */ (module.parser);
|
|
905
950
|
|
|
906
|
-
return [parser.applyTemplate(
|
|
951
|
+
return [parser.applyTemplate(source, module), ...rest];
|
|
907
952
|
}
|
|
908
953
|
|
|
909
954
|
return result;
|
|
@@ -942,15 +987,15 @@ class HtmlModulesPlugin {
|
|
|
942
987
|
/** @type {WeakMap<import("webpack-sources").Source, { resolvedContent: string, contentHash: string }>} */
|
|
943
988
|
const resolvedSentinelHashCache = new WeakMap();
|
|
944
989
|
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
) => {
|
|
990
|
+
/**
|
|
991
|
+
* Computes an HTML page's emitted filename, chunk-URL-resolved content and
|
|
992
|
+
* content hash. Links to other pages stay sentinels, so a page's filename
|
|
993
|
+
* never depends on the filenames of the pages it links to.
|
|
994
|
+
* @param {NormalModule} module the page's html module
|
|
995
|
+
* @param {import("../Chunk")} chunk chunk the page is emitted from
|
|
996
|
+
* @returns {{ resolvedContent: string, contentHash: string, filename: string, info: import("../Compilation").AssetInfo } | undefined} the page's emit, or `undefined` when it generates no html
|
|
997
|
+
*/
|
|
998
|
+
const computePageEmit = (module, chunk) => {
|
|
954
999
|
const { chunkGraph, outputOptions } = compilation;
|
|
955
1000
|
const codeGenResult =
|
|
956
1001
|
/** @type {import("../CodeGenerationResults")} */ (
|
|
@@ -1027,14 +1072,15 @@ class HtmlModulesPlugin {
|
|
|
1027
1072
|
};
|
|
1028
1073
|
};
|
|
1029
1074
|
|
|
1030
|
-
// Emitted filename of a linked `type: "html"` page, keyed by its entry
|
|
1031
|
-
// name. Looked up from the page's own entry chunk so it's independent of
|
|
1032
|
-
// chunk render order; cached for the compilation.
|
|
1033
1075
|
/** @type {Map<string, string>} */
|
|
1034
1076
|
const htmlPageFilenameCache = new Map();
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1077
|
+
/**
|
|
1078
|
+
* Emitted filename of a linked `type: "html"` page, read from the page's
|
|
1079
|
+
* own entry chunk so chunk render order cannot affect it.
|
|
1080
|
+
* @param {string} entryName entry name of the linked page
|
|
1081
|
+
* @returns {string} the page's emitted filename, `"data:,"` when it has none
|
|
1082
|
+
*/
|
|
1083
|
+
const computePageFilenameByEntry = (entryName) => {
|
|
1038
1084
|
const cached = htmlPageFilenameCache.get(entryName);
|
|
1039
1085
|
if (cached !== undefined) return cached;
|
|
1040
1086
|
let filename = "data:,";
|