@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
|
@@ -32,16 +32,22 @@ const getOutgoingAsyncModules = (moduleGraph, module) => {
|
|
|
32
32
|
const outgoingConnectionMap =
|
|
33
33
|
moduleGraph.getOutgoingConnectionsByModule(module);
|
|
34
34
|
if (outgoingConnectionMap) {
|
|
35
|
-
|
|
35
|
+
// Walk the imports in source order: the spec gathers these from
|
|
36
|
+
// `[[RequestedModules]]`, and their evaluation order is observable.
|
|
37
|
+
for (const dependency of module.dependencies) {
|
|
38
|
+
if (!(dependency instanceof HarmonyImportDependency)) continue;
|
|
39
|
+
const referenced = moduleGraph.getModule(dependency);
|
|
40
|
+
if (!referenced || seen.has(referenced)) continue;
|
|
41
|
+
const connections = outgoingConnectionMap.get(referenced);
|
|
36
42
|
if (
|
|
43
|
+
connections &&
|
|
37
44
|
connections.some(
|
|
38
45
|
(c) =>
|
|
39
46
|
c.dependency instanceof HarmonyImportDependency &&
|
|
40
47
|
c.isTargetActive(undefined)
|
|
41
|
-
)
|
|
42
|
-
module
|
|
48
|
+
)
|
|
43
49
|
) {
|
|
44
|
-
g(
|
|
50
|
+
g(referenced);
|
|
45
51
|
}
|
|
46
52
|
}
|
|
47
53
|
}
|
package/lib/config/defaults.js
CHANGED
|
@@ -179,6 +179,7 @@ const {
|
|
|
179
179
|
* portableRecords: NonNullable<Optimization["portableRecords"]>,
|
|
180
180
|
* realContentHash: NonNullable<Optimization["realContentHash"]>,
|
|
181
181
|
* minimize: NonNullable<Optimization["minimize"]>,
|
|
182
|
+
* minimizeOptions: NonNullable<Optimization["minimizeOptions"]>,
|
|
182
183
|
* minimizer: NonNullable<Exclude<Optimization["minimizer"], "...">>,
|
|
183
184
|
* nodeEnv: NonNullable<Optimization["nodeEnv"]>,
|
|
184
185
|
* }} OptimizationNormalizedWithDefaults
|
|
@@ -1747,6 +1748,8 @@ const applyOutputDefaults = (
|
|
|
1747
1748
|
"generator",
|
|
1748
1749
|
() => tp && optimistic(/** @type {boolean | undefined} */ (tp.generator))
|
|
1749
1750
|
);
|
|
1751
|
+
// No `topLevelAwait` here: the option is held back from the patch release,
|
|
1752
|
+
// so nothing derives it from `tp` yet. Reapply by reverting #21881.
|
|
1750
1753
|
F(
|
|
1751
1754
|
environment,
|
|
1752
1755
|
"forOf",
|
|
@@ -2463,20 +2466,28 @@ const applyOptimizationDefaults = (
|
|
|
2463
2466
|
D(optimization, "mangleWasmImports", false);
|
|
2464
2467
|
D(optimization, "portableRecords", records);
|
|
2465
2468
|
D(optimization, "realContentHash", production);
|
|
2466
|
-
|
|
2467
|
-
//
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2469
|
+
// A plugin assigning the object shorthand in `apply()` runs after
|
|
2470
|
+
// normalization: it replaces `minimizeOptions`, keeping `minimize` boolean.
|
|
2471
|
+
const minimizeAssignedInApply = /** @type {unknown} */ (
|
|
2472
|
+
optimization.minimize
|
|
2473
|
+
);
|
|
2474
|
+
if (typeof minimizeAssignedInApply === "object") {
|
|
2475
|
+
optimization.minimizeOptions = /** @type {OptimizationMinimizeOptions} */ (
|
|
2476
|
+
minimizeAssignedInApply
|
|
2477
|
+
);
|
|
2478
|
+
optimization.minimize = true;
|
|
2472
2479
|
}
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
+
D(optimization, "minimize", production);
|
|
2481
|
+
F(optimization, "minimizeOptions", () => ({}));
|
|
2482
|
+
const minimizeOptions =
|
|
2483
|
+
/** @type {NonNullable<Optimization["minimizeOptions"]>} */
|
|
2484
|
+
(optimization.minimizeOptions);
|
|
2485
|
+
if (optimization.minimize) {
|
|
2486
|
+
// Canonicalize the per-asset-type options: the JS minimizer's defaults
|
|
2487
|
+
// become visible in the resolved config rather than hidden in the wiring.
|
|
2488
|
+
F(minimizeOptions, "javascript", () => ({ compress: { passes: 2 } }));
|
|
2489
|
+
F(minimizeOptions, "css", () => ({}));
|
|
2490
|
+
F(minimizeOptions, "html", () => ({}));
|
|
2480
2491
|
}
|
|
2481
2492
|
A(optimization, "minimizer", () => [
|
|
2482
2493
|
{
|
|
@@ -2501,10 +2512,9 @@ const applyOptimizationDefaults = (
|
|
|
2501
2512
|
compiler
|
|
2502
2513
|
);
|
|
2503
2514
|
|
|
2504
|
-
//
|
|
2505
|
-
// object here: `false` disables a type, an object is its options.
|
|
2515
|
+
// Per asset type: `false` disables that type, an object is its options.
|
|
2506
2516
|
const minimizeByType = /** @type {OptimizationMinimizeOptions} */ (
|
|
2507
|
-
compiler.options.optimization.
|
|
2517
|
+
compiler.options.optimization.minimizeOptions
|
|
2508
2518
|
);
|
|
2509
2519
|
const terserOptions = minimizeByType.javascript || {
|
|
2510
2520
|
compress: { passes: 2 }
|
|
@@ -331,7 +331,14 @@ const getNormalizedWebpackOptions = (config) => ({
|
|
|
331
331
|
cacheGroups: cloneObject(splitChunks.cacheGroups)
|
|
332
332
|
}
|
|
333
333
|
),
|
|
334
|
-
|
|
334
|
+
// TODO webpack 6: normalize `minimize` to the per-asset-type object and
|
|
335
|
+
// drop `minimizeOptions` — a breaking change for what plugins read back.
|
|
336
|
+
minimize:
|
|
337
|
+
typeof optimization.minimize === "object" ? true : optimization.minimize,
|
|
338
|
+
minimizeOptions: getNormalizedOptimizationMinimizeOptions(
|
|
339
|
+
optimization.minimize,
|
|
340
|
+
optimization.minimizeOptions
|
|
341
|
+
),
|
|
335
342
|
minimizer:
|
|
336
343
|
optimization.minimizer !== undefined
|
|
337
344
|
? /** @type {OptimizationNormalized["minimizer"]} */ (
|
|
@@ -612,15 +619,18 @@ const getNormalizedEntryStatic = (entry) => {
|
|
|
612
619
|
};
|
|
613
620
|
|
|
614
621
|
/**
|
|
615
|
-
* Gets
|
|
616
|
-
*
|
|
622
|
+
* Gets the per-asset-type minimize options. `minimize` itself stays a boolean,
|
|
623
|
+
* and its object form is a shorthand an explicit `minimizeOptions` overrides.
|
|
617
624
|
* @param {Optimization["minimize"]} minimize minimize option
|
|
618
|
-
* @
|
|
625
|
+
* @param {Optimization["minimizeOptions"]} minimizeOptions minimizeOptions option
|
|
626
|
+
* @returns {OptimizationNormalized["minimizeOptions"]} normalized minimize options
|
|
619
627
|
*/
|
|
620
|
-
const
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
628
|
+
const getNormalizedOptimizationMinimizeOptions = (
|
|
629
|
+
minimize,
|
|
630
|
+
minimizeOptions
|
|
631
|
+
) => {
|
|
632
|
+
if (minimizeOptions !== undefined) return cloneObject(minimizeOptions);
|
|
633
|
+
if (typeof minimize !== "object") return;
|
|
624
634
|
return cloneObject(minimize);
|
|
625
635
|
};
|
|
626
636
|
|
|
@@ -76,10 +76,26 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
|
|
76
76
|
} = compilation;
|
|
77
77
|
const dedupePrefetch = Boolean(resourceHints && resourceHints.dedupe);
|
|
78
78
|
const fn = RuntimeGlobals.ensureChunkHandlers;
|
|
79
|
+
/** @type {Set<ChunkId>} */
|
|
80
|
+
const initialChunkIds = new Set();
|
|
81
|
+
for (const c of chunk.getAllInitialChunks()) {
|
|
82
|
+
if (chunkHasCss(c, chunkGraph)) {
|
|
83
|
+
initialChunkIds.add(/** @type {ChunkId} */ (c.id));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
79
86
|
// The predicate the stylesheet is emitted from: an `@import` external gives a
|
|
80
87
|
// chunk a css asset without a `CSS_TYPE` module, and it still has to load.
|
|
81
88
|
const conditionMap = chunkGraph.getChunkConditionMap(chunk, chunkHasCss);
|
|
82
|
-
|
|
89
|
+
// An initial chunk is installed before the handler can run, so it never
|
|
90
|
+
// reaches the loading path — with no other one there is nothing to load.
|
|
91
|
+
const loadableConditionMap = { ...conditionMap };
|
|
92
|
+
for (const id of initialChunkIds) {
|
|
93
|
+
loadableConditionMap[id] = false;
|
|
94
|
+
}
|
|
95
|
+
const hasCssMatcher =
|
|
96
|
+
compileBooleanMatcher(loadableConditionMap) === false
|
|
97
|
+
? false
|
|
98
|
+
: compileBooleanMatcher(conditionMap);
|
|
83
99
|
|
|
84
100
|
const withLoading =
|
|
85
101
|
_runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers) &&
|
|
@@ -88,13 +104,6 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
|
|
88
104
|
const withHmr = _runtimeRequirements.has(
|
|
89
105
|
RuntimeGlobals.hmrDownloadUpdateHandlers
|
|
90
106
|
);
|
|
91
|
-
/** @type {Set<ChunkId>} */
|
|
92
|
-
const initialChunkIds = new Set();
|
|
93
|
-
for (const c of chunk.getAllInitialChunks()) {
|
|
94
|
-
if (chunkHasCss(c, chunkGraph)) {
|
|
95
|
-
initialChunkIds.add(/** @type {ChunkId} */ (c.id));
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
107
|
|
|
99
108
|
if (!withLoading && !withHmr) {
|
|
100
109
|
return null;
|
|
@@ -176,22 +185,32 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
|
|
176
185
|
",\n"
|
|
177
186
|
)
|
|
178
187
|
)}\n}`;
|
|
188
|
+
/**
|
|
189
|
+
* @param {string} id expression naming the chunk whose stylesheet is wanted
|
|
190
|
+
* @returns {string} expression building its url at runtime
|
|
191
|
+
*/
|
|
192
|
+
const runtimeCssUrl = (id) =>
|
|
193
|
+
`${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkCssFilename}(${id})`;
|
|
179
194
|
// The url is read through a thunk so a runtime carrying many stylesheets builds
|
|
180
195
|
// only the one it loads.
|
|
181
196
|
/**
|
|
182
197
|
* @param {string} id expression naming the chunk whose stylesheet is wanted
|
|
183
198
|
* @returns {string} expression evaluating to its url
|
|
184
199
|
*/
|
|
185
|
-
const cssUrl = (id) =>
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
200
|
+
const cssUrl = (id) => {
|
|
201
|
+
if (!cssUrls) return runtimeCssUrl(id);
|
|
202
|
+
// An id the incomplete map lacks still resolves through the runtime lookup,
|
|
203
|
+
// which the plugin kept required for exactly this case.
|
|
204
|
+
return cssUrls.complete
|
|
205
|
+
? `cssUrls[${id}]()`
|
|
206
|
+
: `(cssUrls[${id}] ? cssUrls[${id}]() : ${runtimeCssUrl(id)})`;
|
|
207
|
+
};
|
|
189
208
|
return Template.asString([
|
|
190
209
|
...(cssUrls
|
|
191
210
|
? [
|
|
192
211
|
`${cst} cssUrls = {\n${Template.indent(
|
|
193
212
|
Array.from(
|
|
194
|
-
cssUrls,
|
|
213
|
+
cssUrls.urls,
|
|
195
214
|
([id, url]) =>
|
|
196
215
|
`${JSON.stringify(String(id))}: ${runtimeTemplate.returningFunction(url)}`
|
|
197
216
|
).join(",\n")
|
|
@@ -43,7 +43,7 @@ const {
|
|
|
43
43
|
PUBLIC_PATH_AUTO,
|
|
44
44
|
walkFullHashPlaceholders
|
|
45
45
|
} = require("../util/publicPathPlaceholder");
|
|
46
|
-
const
|
|
46
|
+
const { removeBOMFromResult } = require("../util/removeBOM");
|
|
47
47
|
const CssModule = require("./CssModule");
|
|
48
48
|
|
|
49
49
|
/** @import { Source } from "webpack-sources" */
|
|
@@ -516,15 +516,8 @@ class CssModulesPlugin {
|
|
|
516
516
|
|
|
517
517
|
NormalModule.getCompilationHooks(compilation).processResult.tap(
|
|
518
518
|
PLUGIN_NAME,
|
|
519
|
-
(result, module) =>
|
|
520
|
-
|
|
521
|
-
const [source, ...rest] = result;
|
|
522
|
-
|
|
523
|
-
return [removeBOM(source), ...rest];
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
return result;
|
|
527
|
-
}
|
|
519
|
+
(result, module) =>
|
|
520
|
+
module.type === type ? removeBOMFromResult(result) : result
|
|
528
521
|
);
|
|
529
522
|
}
|
|
530
523
|
|
|
@@ -779,13 +772,12 @@ class CssModulesPlugin {
|
|
|
779
772
|
// A baked url carries where the stylesheet is, so neither the public
|
|
780
773
|
// path nor the name lookup is read for it. Asked exactly as the
|
|
781
774
|
// loading runtime module asks, so the two always agree.
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
) {
|
|
775
|
+
const baked = compilation.runtimeTemplate.analyzableCssChunkUrls(
|
|
776
|
+
chunk,
|
|
777
|
+
chunkGraph,
|
|
778
|
+
set
|
|
779
|
+
);
|
|
780
|
+
if (baked === null || !baked.complete) {
|
|
789
781
|
set.add(RuntimeGlobals.publicPath);
|
|
790
782
|
set.add(RuntimeGlobals.getChunkCssFilename);
|
|
791
783
|
}
|
package/lib/css/data.js
CHANGED
|
@@ -517,7 +517,7 @@ const UNSHARED_LONGHAND_KEYWORDS = new Map([
|
|
|
517
517
|
// appearing once, in grammar order. A merge emits every value, so the only
|
|
518
518
|
// question is whether each parses back into the longhand it was authored on.
|
|
519
519
|
// prettier-ignore
|
|
520
|
-
const FAMILY_LONGHANDS = new Map([["border-bottom", ["border-bottom-width","border-bottom-style","border-bottom-color"]], ["border-left", ["border-left-width","border-left-style","border-left-color"]], ["border-right", ["border-right-width","border-right-style","border-right-color"]], ["border-top", ["border-top-width","border-top-style","border-top-color"]], ["column-rule", ["column-rule-width","column-rule-style","column-rule-color"]], ["flex-flow", ["flex-direction","flex-wrap"]], ["list-style", ["list-style-type","list-style-position","list-style-image"]], ["outline", ["outline-width","outline-style","outline-color"]], ["text-decoration", ["text-decoration-line","text-decoration-style","text-decoration-color","text-decoration-thickness"]], ["text-emphasis", ["text-emphasis-style","text-emphasis-color"]], ["text-wrap", ["text-wrap-mode","text-wrap-style"]]]);
|
|
520
|
+
const FAMILY_LONGHANDS = new Map([["border-block-end", ["border-block-end-width","border-block-end-style","border-block-end-color"]], ["border-block-start", ["border-block-start-width","border-block-start-style","border-block-start-color"]], ["border-bottom", ["border-bottom-width","border-bottom-style","border-bottom-color"]], ["border-inline-end", ["border-inline-end-width","border-inline-end-style","border-inline-end-color"]], ["border-inline-start", ["border-inline-start-width","border-inline-start-style","border-inline-start-color"]], ["border-left", ["border-left-width","border-left-style","border-left-color"]], ["border-right", ["border-right-width","border-right-style","border-right-color"]], ["border-top", ["border-top-width","border-top-style","border-top-color"]], ["column-rule", ["column-rule-width","column-rule-style","column-rule-color"]], ["flex-flow", ["flex-direction","flex-wrap"]], ["list-style", ["list-style-type","list-style-position","list-style-image"]], ["outline", ["outline-width","outline-style","outline-color"]], ["text-decoration", ["text-decoration-line","text-decoration-style","text-decoration-color","text-decoration-thickness"]], ["text-emphasis", ["text-emphasis-style","text-emphasis-color"]], ["text-wrap", ["text-wrap-mode","text-wrap-style"]]]);
|
|
521
521
|
|
|
522
522
|
// The properties whose comma-separated items take a `<custom-ident>`, where a
|
|
523
523
|
// vendor spelling is a name the engine parses rather than one it may drop — so a
|
|
@@ -537,6 +537,12 @@ const CUSTOM_IDENT_LIST_PROPERTIES = new Set([
|
|
|
537
537
|
"will-change"
|
|
538
538
|
]);
|
|
539
539
|
|
|
540
|
+
// The shorthands whose grammar juxtaposes its longhands in a fixed order, so a
|
|
541
|
+
// merge writes every value by position rather than reading which slot takes it.
|
|
542
|
+
const ORDERED_LONGHANDS = new Map([
|
|
543
|
+
["flex", ["flex-grow", "flex-shrink", "flex-basis"]]
|
|
544
|
+
]);
|
|
545
|
+
|
|
540
546
|
const SLASH_LONGHANDS = new Map([
|
|
541
547
|
[
|
|
542
548
|
"grid-area",
|
|
@@ -597,7 +603,10 @@ const MERGE_LONGHANDS = new Set([
|
|
|
597
603
|
"corner-start-start-shape",
|
|
598
604
|
"corner-top-left-shape",
|
|
599
605
|
"corner-top-right-shape",
|
|
606
|
+
"flex-basis",
|
|
600
607
|
"flex-direction",
|
|
608
|
+
"flex-grow",
|
|
609
|
+
"flex-shrink",
|
|
601
610
|
"flex-wrap",
|
|
602
611
|
"grid-column-end",
|
|
603
612
|
"grid-column-start",
|
|
@@ -682,10 +691,10 @@ const OMITTABLE_INITIAL_KEYWORDS = new Map([["grid-auto-flow", ["row", ["column"
|
|
|
682
691
|
// makes the merge ambiguous, and `FAMILY_SLOT_CLASSES` names a type the printer
|
|
683
692
|
// cannot classify as readily as one it can, so an unknown one declines.
|
|
684
693
|
// prettier-ignore
|
|
685
|
-
const FAMILY_SLOT_KEYWORDS = new Map([["border-bottom-width", ["medium","thick","thin"]], ["border-bottom-style", ["dashed","dotted","double","groove","hidden","inset","none","outset","ridge","solid"]], ["border-bottom-color", []], ["border-left-width", ["medium","thick","thin"]], ["border-left-style", ["dashed","dotted","double","groove","hidden","inset","none","outset","ridge","solid"]], ["border-left-color", []], ["border-right-width", ["medium","thick","thin"]], ["border-right-style", ["dashed","dotted","double","groove","hidden","inset","none","outset","ridge","solid"]], ["border-right-color", []], ["border-top-width", ["medium","thick","thin"]], ["border-top-style", ["dashed","dotted","double","groove","hidden","inset","none","outset","ridge","solid"]], ["border-top-color", []], ["column-rule-width", ["medium","thick","thin"]], ["column-rule-style", ["dashed","dotted","double","groove","hidden","inset","none","outset","ridge","solid"]], ["column-rule-color", []], ["flex-direction", ["column","column-reverse","row","row-reverse"]], ["flex-wrap", ["nowrap","wrap","wrap-reverse"]], ["list-style-type", ["none"]], ["list-style-position", ["inside","outside"]], ["list-style-image", ["none"]], ["outline-width", ["medium","thick","thin"]], ["outline-style", ["auto","dashed","dotted","double","groove","inset","none","outset","ridge","solid"]], ["outline-color", ["auto"]], ["text-decoration-line", ["blink","grammar-error","line-through","none","overline","spelling-error","underline"]], ["text-decoration-style", ["dashed","dotted","double","solid","wavy"]], ["text-decoration-color", []], ["text-decoration-thickness", ["auto","from-font"]], ["text-emphasis-style", ["circle","dot","double-circle","filled","none","open","sesame","triangle"]], ["text-emphasis-color", []], ["text-wrap-mode", ["nowrap","wrap"]], ["text-wrap-style", ["auto","balance","pretty","stable"]]]);
|
|
694
|
+
const FAMILY_SLOT_KEYWORDS = new Map([["border-block-end-width", ["medium","thick","thin"]], ["border-block-end-style", ["dashed","dotted","double","groove","hidden","inset","none","outset","ridge","solid"]], ["border-block-end-color", []], ["border-block-start-width", ["medium","thick","thin"]], ["border-block-start-style", ["dashed","dotted","double","groove","hidden","inset","none","outset","ridge","solid"]], ["border-block-start-color", []], ["border-bottom-width", ["medium","thick","thin"]], ["border-bottom-style", ["dashed","dotted","double","groove","hidden","inset","none","outset","ridge","solid"]], ["border-bottom-color", []], ["border-inline-end-width", ["medium","thick","thin"]], ["border-inline-end-style", ["dashed","dotted","double","groove","hidden","inset","none","outset","ridge","solid"]], ["border-inline-end-color", []], ["border-inline-start-width", ["medium","thick","thin"]], ["border-inline-start-style", ["dashed","dotted","double","groove","hidden","inset","none","outset","ridge","solid"]], ["border-inline-start-color", []], ["border-left-width", ["medium","thick","thin"]], ["border-left-style", ["dashed","dotted","double","groove","hidden","inset","none","outset","ridge","solid"]], ["border-left-color", []], ["border-right-width", ["medium","thick","thin"]], ["border-right-style", ["dashed","dotted","double","groove","hidden","inset","none","outset","ridge","solid"]], ["border-right-color", []], ["border-top-width", ["medium","thick","thin"]], ["border-top-style", ["dashed","dotted","double","groove","hidden","inset","none","outset","ridge","solid"]], ["border-top-color", []], ["column-rule-width", ["medium","thick","thin"]], ["column-rule-style", ["dashed","dotted","double","groove","hidden","inset","none","outset","ridge","solid"]], ["column-rule-color", []], ["flex-direction", ["column","column-reverse","row","row-reverse"]], ["flex-wrap", ["nowrap","wrap","wrap-reverse"]], ["list-style-type", ["none"]], ["list-style-position", ["inside","outside"]], ["list-style-image", ["none"]], ["outline-width", ["medium","thick","thin"]], ["outline-style", ["auto","dashed","dotted","double","groove","inset","none","outset","ridge","solid"]], ["outline-color", ["auto"]], ["text-decoration-line", ["blink","grammar-error","line-through","none","overline","spelling-error","underline"]], ["text-decoration-style", ["dashed","dotted","double","solid","wavy"]], ["text-decoration-color", []], ["text-decoration-thickness", ["auto","from-font"]], ["text-emphasis-style", ["circle","dot","double-circle","filled","none","open","sesame","triangle"]], ["text-emphasis-color", []], ["text-wrap-mode", ["nowrap","wrap"]], ["text-wrap-style", ["auto","balance","pretty","stable"]]]);
|
|
686
695
|
|
|
687
696
|
// prettier-ignore
|
|
688
|
-
const FAMILY_SLOT_CLASSES = new Map([["border-bottom-width", ["length"]], ["border-bottom-style", []], ["border-bottom-color", ["color"]], ["border-left-width", ["length"]], ["border-left-style", []], ["border-left-color", ["color"]], ["border-right-width", ["length"]], ["border-right-style", []], ["border-right-color", ["color"]], ["border-top-width", ["length"]], ["border-top-style", []], ["border-top-color", ["color"]], ["column-rule-width", ["length"]], ["column-rule-style", []], ["column-rule-color", ["color"]], ["flex-direction", []], ["flex-wrap", []], ["list-style-type", ["custom-ident","string"]], ["list-style-position", []], ["list-style-image", ["image"]], ["outline-width", ["length"]], ["outline-style", []], ["outline-color", ["color"]], ["text-decoration-line", []], ["text-decoration-style", []], ["text-decoration-color", ["color"]], ["text-decoration-thickness", ["length","percentage"]], ["text-emphasis-style", ["string"]], ["text-emphasis-color", ["color"]], ["text-wrap-mode", []], ["text-wrap-style", []]]);
|
|
697
|
+
const FAMILY_SLOT_CLASSES = new Map([["border-block-end-width", ["length"]], ["border-block-end-style", []], ["border-block-end-color", ["color"]], ["border-block-start-width", ["length"]], ["border-block-start-style", []], ["border-block-start-color", ["color"]], ["border-bottom-width", ["length"]], ["border-bottom-style", []], ["border-bottom-color", ["color"]], ["border-inline-end-width", ["length"]], ["border-inline-end-style", []], ["border-inline-end-color", ["color"]], ["border-inline-start-width", ["length"]], ["border-inline-start-style", []], ["border-inline-start-color", ["color"]], ["border-left-width", ["length"]], ["border-left-style", []], ["border-left-color", ["color"]], ["border-right-width", ["length"]], ["border-right-style", []], ["border-right-color", ["color"]], ["border-top-width", ["length"]], ["border-top-style", []], ["border-top-color", ["color"]], ["column-rule-width", ["length"]], ["column-rule-style", []], ["column-rule-color", ["color"]], ["flex-direction", []], ["flex-wrap", []], ["list-style-type", ["custom-ident","string"]], ["list-style-position", []], ["list-style-image", ["image"]], ["outline-width", ["length"]], ["outline-style", []], ["outline-color", ["color"]], ["text-decoration-line", []], ["text-decoration-style", []], ["text-decoration-color", ["color"]], ["text-decoration-thickness", ["length","percentage"]], ["text-emphasis-style", ["string"]], ["text-emphasis-color", ["color"]], ["text-wrap-mode", []], ["text-wrap-style", []]]);
|
|
689
698
|
|
|
690
699
|
// The identifiers that are a `<color>` on their own — named, system and the two
|
|
691
700
|
// context-dependent ones. Read off the `<color>` grammar outside any function,
|
|
@@ -5282,6 +5291,7 @@ module.exports.NTH_NAMED_EQUIVALENTS = NTH_NAMED_EQUIVALENTS;
|
|
|
5282
5291
|
module.exports.NTH_PSEUDO_FUNCTIONS = NTH_PSEUDO_FUNCTIONS;
|
|
5283
5292
|
module.exports.OMITTABLE_INITIAL_KEYWORDS = OMITTABLE_INITIAL_KEYWORDS;
|
|
5284
5293
|
module.exports.ONE_VALUE_PAIR_SHORTHANDS = ONE_VALUE_PAIR_SHORTHANDS;
|
|
5294
|
+
module.exports.ORDERED_LONGHANDS = ORDERED_LONGHANDS;
|
|
5285
5295
|
module.exports.PAIR_LONGHANDS = PAIR_LONGHANDS;
|
|
5286
5296
|
module.exports.PLACE_SHORTHANDS = PLACE_SHORTHANDS;
|
|
5287
5297
|
module.exports.POSITION_PROPERTIES = POSITION_PROPERTIES;
|
package/lib/css/syntax.js
CHANGED
|
@@ -88,6 +88,7 @@ const {
|
|
|
88
88
|
NTH_PSEUDO_FUNCTIONS,
|
|
89
89
|
OMITTABLE_INITIAL_KEYWORDS,
|
|
90
90
|
ONE_VALUE_PAIR_SHORTHANDS,
|
|
91
|
+
ORDERED_LONGHANDS,
|
|
91
92
|
PAIR_LONGHANDS,
|
|
92
93
|
PLACE_SHORTHANDS,
|
|
93
94
|
POSITION_PROPERTIES,
|
|
@@ -5268,8 +5269,13 @@ const _emitTopLevel = (writer, node, offset, line, column, text, own) => {
|
|
|
5268
5269
|
// Folding two named layer blocks into one, and taking back a rule an
|
|
5269
5270
|
// identical later one makes dead, each answer to their own option.
|
|
5270
5271
|
const minify = printing && _transforms.removeDeadRules;
|
|
5272
|
+
// The node type first: only an at-rule can be a named layer block, and
|
|
5273
|
+
// reading the text asks the rope this node printed to flatten — a copy of
|
|
5274
|
+
// the whole rule, for every rule.
|
|
5271
5275
|
const opener =
|
|
5272
|
-
printing && _transforms.mergeRules
|
|
5276
|
+
printing && _transforms.mergeRules && _types[_nodeIndex(node)] === T_AT_RULE
|
|
5277
|
+
? _namedLayerOpener(text)
|
|
5278
|
+
: null;
|
|
5273
5279
|
// Nothing folds back over a kept comment — it was written above what follows
|
|
5274
5280
|
// it — nor over a sibling naming a layer any other way, since it writes into
|
|
5275
5281
|
// one of these and the order within a layer is the cascade's.
|
|
@@ -9582,15 +9588,31 @@ const _BARE_NUMBER_RE = /^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i;
|
|
|
9582
9588
|
* @param {PrintContext} writer the print context (children's printed text)
|
|
9583
9589
|
* @returns {string[] | null} the fragments to join, or `null` to keep the value as it is
|
|
9584
9590
|
*/
|
|
9585
|
-
const _collapseFlexShorthand = (path, node, writer) =>
|
|
9586
|
-
|
|
9591
|
+
const _collapseFlexShorthand = (path, node, writer) =>
|
|
9592
|
+
_shortestFlexValue(_valueComponents(path, node, writer));
|
|
9593
|
+
|
|
9594
|
+
/**
|
|
9595
|
+
* The shortest spelling of a three-factor `flex` value, or `null` when it is
|
|
9596
|
+
* already the shortest. Shared with the merge, which arrives at the same three
|
|
9597
|
+
* factors from the longhands rather than from an authored shorthand.
|
|
9598
|
+
* @param {string[]} components the value's components, in grammar order
|
|
9599
|
+
* @returns {string[] | null} the fragments to join, or `null` to keep them as they are
|
|
9600
|
+
*/
|
|
9601
|
+
const _shortestFlexValue = (components) => {
|
|
9587
9602
|
if (components.length !== 3) return null;
|
|
9588
9603
|
const keyword = FLEX_KEYWORDS.get(components.join(" ").toLowerCase());
|
|
9589
9604
|
if (keyword !== undefined) return [keyword];
|
|
9605
|
+
// CSS Flexbox 1 §7.1.1 reads an omitted basis as `0%`, so one spelt that way
|
|
9606
|
+
// says nothing — and an omitted shrink as `1`, so that says nothing either.
|
|
9607
|
+
if (components[2] === "0%") {
|
|
9608
|
+
return components[1] === "1"
|
|
9609
|
+
? [components[0]]
|
|
9610
|
+
: [components[0], components[1]];
|
|
9611
|
+
}
|
|
9590
9612
|
// `<'flex-shrink'>` follows the grow factor and defaults to 1, so a `1` there
|
|
9591
9613
|
// says nothing — but only over a basis that cannot be read as a factor
|
|
9592
|
-
// itself:
|
|
9593
|
-
//
|
|
9614
|
+
// itself: §7.1.1 reads a unitless zero not preceded by two factors as a
|
|
9615
|
+
// factor, so `1 1 0` is not `1 0`.
|
|
9594
9616
|
return components[1] === "1" && !_BARE_NUMBER_RE.test(components[2])
|
|
9595
9617
|
? [components[0], components[2]]
|
|
9596
9618
|
: null;
|
|
@@ -10655,13 +10677,32 @@ const _mergeBoxLonghands = (
|
|
|
10655
10677
|
// A bare number is no length, so one written beside a length is a value the
|
|
10656
10678
|
// property never read — the engine dropped that declaration and kept the
|
|
10657
10679
|
// others. Merging them writes it into a shorthand the engine drops whole,
|
|
10658
|
-
// which loses the slots that were fine.
|
|
10659
|
-
|
|
10680
|
+
// which loses the slots that were fine. Not asked of an ordered grammar,
|
|
10681
|
+
// whose slots take different types by position (`flex:1 1 0px`).
|
|
10682
|
+
if (mode !== MERGE_ORDERED && _mixesBareNumberWithLength(values)) continue;
|
|
10660
10683
|
/** @type {string | null} */
|
|
10661
10684
|
let value;
|
|
10662
10685
|
if (mode === MERGE_FAMILY) {
|
|
10663
10686
|
value = _familyValue(longhands, values);
|
|
10664
10687
|
if (value === null) continue;
|
|
10688
|
+
} else if (mode === MERGE_ORDERED) {
|
|
10689
|
+
// The same two refusals every other mode makes: a `var()` may expand
|
|
10690
|
+
// across a slot boundary, and a CSS-wide keyword beside another value is
|
|
10691
|
+
// a shorthand the engine drops whole.
|
|
10692
|
+
let refused = false;
|
|
10693
|
+
for (const slot of values) {
|
|
10694
|
+
if (
|
|
10695
|
+
_hasSubstitution(slot) ||
|
|
10696
|
+
CSS_WIDE_KEYWORDS.has(toLowerCaseIfNeeded(slot))
|
|
10697
|
+
) {
|
|
10698
|
+
refused = true;
|
|
10699
|
+
break;
|
|
10700
|
+
}
|
|
10701
|
+
}
|
|
10702
|
+
if (refused) continue;
|
|
10703
|
+
// Written by position, then shortened the way an authored one would be.
|
|
10704
|
+
const shortest = _shortestFlexValue(values);
|
|
10705
|
+
value = (shortest === null ? values : shortest).join(" ");
|
|
10665
10706
|
} else if (mode === MERGE_SLASH) {
|
|
10666
10707
|
// The same two refusals a box makes: a `var()` may expand across the `/`
|
|
10667
10708
|
// into another slot, and a CSS-wide keyword beside another value is a
|
|
@@ -10728,12 +10769,14 @@ const _mergeBoxLonghands = (
|
|
|
10728
10769
|
const MERGE_BOX = 0;
|
|
10729
10770
|
const MERGE_FAMILY = 1;
|
|
10730
10771
|
const MERGE_SLASH = 2;
|
|
10772
|
+
const MERGE_ORDERED = 3;
|
|
10731
10773
|
|
|
10732
10774
|
/** @type {[Map<string, string[]>, number][]} */
|
|
10733
10775
|
const MERGE_TABLES = [
|
|
10734
10776
|
[BOX_LONGHANDS, MERGE_BOX],
|
|
10735
10777
|
[PAIR_LONGHANDS, MERGE_BOX],
|
|
10736
10778
|
[FAMILY_LONGHANDS, MERGE_FAMILY],
|
|
10779
|
+
[ORDERED_LONGHANDS, MERGE_ORDERED],
|
|
10737
10780
|
[SLASH_LONGHANDS, MERGE_SLASH]
|
|
10738
10781
|
];
|
|
10739
10782
|
|
|
@@ -11243,6 +11286,21 @@ const _opensNestedLayer = (text, opener) =>
|
|
|
11243
11286
|
// is never dropped as a repeat, wherever in its text it sits.
|
|
11244
11287
|
const POSITIONAL_AT_RULE_RE = /@(?:charset|import|layer|namespace)\b/i;
|
|
11245
11288
|
|
|
11289
|
+
/**
|
|
11290
|
+
* Whether a node is an `@layer` at-rule carrying a name — the only shape a
|
|
11291
|
+
* named layer block can have, answered from the node rather than from the text
|
|
11292
|
+
* it printed.
|
|
11293
|
+
* @param {Node} node a block item
|
|
11294
|
+
* @returns {boolean} true for `@layer <name>`
|
|
11295
|
+
*/
|
|
11296
|
+
const _isNamedLayerAtRule = (node) => {
|
|
11297
|
+
const i = _nodeIndex(node);
|
|
11298
|
+
return (
|
|
11299
|
+
_types[i] === T_AT_RULE &&
|
|
11300
|
+
rangeEqualsLowerCase(_input, _starts[i] + 1, _aux0[i], "layer")
|
|
11301
|
+
);
|
|
11302
|
+
};
|
|
11303
|
+
|
|
11246
11304
|
/**
|
|
11247
11305
|
* Gather each named `@layer` block into the first sibling block of that name.
|
|
11248
11306
|
* They are one layer however far apart they stand, and what separates them is in
|
|
@@ -11250,16 +11308,26 @@ const POSITIONAL_AT_RULE_RE = /@(?:charset|import|layer|namespace)\b/i;
|
|
|
11250
11308
|
* rather than by where they sit, so moving the later body up is not a move the
|
|
11251
11309
|
* cascade can see. An anonymous `@layer {` is a layer of its own and is left
|
|
11252
11310
|
* alone (see `ANONYMOUS_LAYER_RE`).
|
|
11311
|
+
* @param {Node[]} items the siblings, in the order their texts stand in
|
|
11253
11312
|
* @param {string[]} texts the siblings' printed texts, rewritten in place
|
|
11254
11313
|
* @returns {void}
|
|
11255
11314
|
*/
|
|
11256
|
-
const _mergeNamedLayerBlocks = (texts) => {
|
|
11315
|
+
const _mergeNamedLayerBlocks = (items, texts) => {
|
|
11257
11316
|
if (!_transforms.mergeRules) return;
|
|
11317
|
+
// Which siblings could be one at all, read off the nodes: asking a text
|
|
11318
|
+
// makes the rope that node printed flatten, and this runs for every block.
|
|
11319
|
+
let named = false;
|
|
11320
|
+
for (let i = 0; i < items.length && !named; i++) {
|
|
11321
|
+
named = _isNamedLayerAtRule(items[i]);
|
|
11322
|
+
}
|
|
11323
|
+
if (!named) return;
|
|
11258
11324
|
/** @type {Map<string, SeenLayer> | null} */
|
|
11259
11325
|
let first = null;
|
|
11260
11326
|
for (let i = 0; i < texts.length; i++) {
|
|
11261
11327
|
const text = texts[i];
|
|
11262
|
-
const prelude =
|
|
11328
|
+
const prelude = _isNamedLayerAtRule(items[i])
|
|
11329
|
+
? _namedLayerOpener(text)
|
|
11330
|
+
: null;
|
|
11263
11331
|
if (prelude === null) {
|
|
11264
11332
|
// A sibling naming a layer any other way writes into one of these, and
|
|
11265
11333
|
// the order within a layer is the cascade's, so nothing folds over it.
|
|
@@ -11754,7 +11822,7 @@ const _composeBlockBody = (path, decls, rules, writer, minify, nl, owner) => {
|
|
|
11754
11822
|
? null
|
|
11755
11823
|
: new Set(childScope.pending.values())
|
|
11756
11824
|
);
|
|
11757
|
-
_mergeNamedLayerBlocks(texts);
|
|
11825
|
+
_mergeNamedLayerBlocks(items, texts);
|
|
11758
11826
|
}
|
|
11759
11827
|
// Only the last of a set of declarations of one property can be read, so
|
|
11760
11828
|
// the earlier ones carry nothing — whatever stands between them. Identical
|
|
@@ -20,6 +20,7 @@ const HarmonyImportGuard = require("./HarmonyImportGuard");
|
|
|
20
20
|
const ModuleDependency = require("./ModuleDependency");
|
|
21
21
|
|
|
22
22
|
/** @import { ReplaceSource } from "webpack-sources" */
|
|
23
|
+
/** @import ConcatenationScope from "../ConcatenationScope" */
|
|
23
24
|
/**
|
|
24
25
|
* @import {
|
|
25
26
|
* GetConditionFn,
|
|
@@ -30,6 +31,7 @@ const ModuleDependency = require("./ModuleDependency");
|
|
|
30
31
|
/** @import { DependencyTemplateContext } from "../DependencyTemplate" */
|
|
31
32
|
/** @import Module from "../Module" */
|
|
32
33
|
/** @import ModuleGraph from "../ModuleGraph" */
|
|
34
|
+
/** @import ModuleGraphConnection from "../ModuleGraphConnection" */
|
|
33
35
|
/** @import { Range } from "../javascript/JavascriptParser" */
|
|
34
36
|
/** @import { UsedByExports } from "../optimize/InnerGraph" */
|
|
35
37
|
/** @import { RuntimeSpec } from "../util/runtime" */
|
|
@@ -200,6 +202,19 @@ class CommonJsRequireDependency extends ModuleDependency {
|
|
|
200
202
|
return concatenateCommonJsModules && this._canConcatenate;
|
|
201
203
|
}
|
|
202
204
|
|
|
205
|
+
/**
|
|
206
|
+
* @param {ModuleGraphConnection} connection the active connection of this dependency
|
|
207
|
+
* @param {ConcatenationScope} concatenationScope the concatenation scope
|
|
208
|
+
* @returns {boolean} true when the call becomes a module reference
|
|
209
|
+
*/
|
|
210
|
+
rendersAsConcatenatedReference(connection, concatenationScope) {
|
|
211
|
+
return (
|
|
212
|
+
this._canConcatenate &&
|
|
213
|
+
this.valueRange !== undefined &&
|
|
214
|
+
concatenationScope.isModuleInScope(connection.module)
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
203
218
|
/**
|
|
204
219
|
* Serializes this instance into the provided serializer context.
|
|
205
220
|
* @param {ObjectSerializerContext} context context
|
|
@@ -278,9 +293,9 @@ CommonJsRequireDependency.Template = class CommonJsRequireDependencyTemplate ext
|
|
|
278
293
|
if (
|
|
279
294
|
connection &&
|
|
280
295
|
concatenationScope !== undefined &&
|
|
281
|
-
dep.
|
|
282
|
-
concatenationScope.isModuleInScope(connection.module)
|
|
296
|
+
dep.rendersAsConcatenatedReference(connection, concatenationScope)
|
|
283
297
|
) {
|
|
298
|
+
const valueRange = /** @type {Range} */ (dep.valueRange);
|
|
284
299
|
let content = concatenationScope.createModuleReference(
|
|
285
300
|
connection.module,
|
|
286
301
|
{
|
|
@@ -300,8 +315,7 @@ CommonJsRequireDependency.Template = class CommonJsRequireDependencyTemplate ext
|
|
|
300
315
|
);
|
|
301
316
|
content = `${RuntimeGlobals.constructRequire}(${content})`;
|
|
302
317
|
}
|
|
303
|
-
source.replace(
|
|
304
|
-
concatenationScope.registerReplacedRequire(dep.valueRange);
|
|
318
|
+
source.replace(valueRange[0], valueRange[1] - 1, content);
|
|
305
319
|
return;
|
|
306
320
|
}
|
|
307
321
|
const importedModule = /** @type {Module} */ (moduleGraph.getModule(dep));
|
|
@@ -22,11 +22,9 @@ class ContextDependencyTemplateAsRequireCall
|
|
|
22
22
|
* @param {DependencyTemplateContext} templateContext the context object
|
|
23
23
|
* @returns {void}
|
|
24
24
|
*/
|
|
25
|
-
apply(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
{ runtimeTemplate, moduleGraph, chunkGraph, runtimeRequirements }
|
|
29
|
-
) {
|
|
25
|
+
apply(dependency, source, templateContext) {
|
|
26
|
+
const { runtimeTemplate, moduleGraph, chunkGraph, runtimeRequirements } =
|
|
27
|
+
templateContext;
|
|
30
28
|
const dep = /** @type {ContextDependency} */ (dependency);
|
|
31
29
|
let moduleExports = runtimeTemplate.moduleExports({
|
|
32
30
|
module: moduleGraph.getModule(dep),
|
|
@@ -49,8 +47,7 @@ class ContextDependencyTemplateAsRequireCall
|
|
|
49
47
|
source.replace(rep.range[0], rep.range[1] - 1, rep.value);
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
|
-
|
|
53
|
-
source.replace(range[0], dep.valueRange[0] - 1, `${moduleExports}(`);
|
|
50
|
+
this.replaceCall(dep, source, moduleExports, templateContext);
|
|
54
51
|
} else {
|
|
55
52
|
source.replace(range[0], range[1] - 1, moduleExports);
|
|
56
53
|
}
|
|
@@ -58,6 +55,22 @@ class ContextDependencyTemplateAsRequireCall
|
|
|
58
55
|
source.replace(range[0], range[1] - 1, moduleExports);
|
|
59
56
|
}
|
|
60
57
|
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Rewrites the call around its request, dropping anything the original one
|
|
61
|
+
* carried after it. Overridden where a later argument must be kept.
|
|
62
|
+
* @param {ContextDependency} dep the dependency
|
|
63
|
+
* @param {ReplaceSource} source the current replace source which can be modified
|
|
64
|
+
* @param {string} moduleExports the expression the request is passed to
|
|
65
|
+
* @param {DependencyTemplateContext} templateContext the context object
|
|
66
|
+
* @returns {void}
|
|
67
|
+
*/
|
|
68
|
+
replaceCall(dep, source, moduleExports, templateContext) {
|
|
69
|
+
const range = /** @type {Range} */ (dep.range);
|
|
70
|
+
const valueRange = /** @type {Range} */ (dep.valueRange);
|
|
71
|
+
source.replace(valueRange[1], range[1] - 1, ")");
|
|
72
|
+
source.replace(range[0], valueRange[0] - 1, `${moduleExports}(`);
|
|
73
|
+
}
|
|
61
74
|
}
|
|
62
75
|
|
|
63
76
|
module.exports = ContextDependencyTemplateAsRequireCall;
|
|
@@ -150,10 +150,16 @@ HarmonyEvaluatedImportSpecifierDependency.Template = class HarmonyEvaluatedImpor
|
|
|
150
150
|
break;
|
|
151
151
|
}
|
|
152
152
|
case "namespace": {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
153
|
+
// Empty ids are an `export * as ns` hop skipped as side-effect free,
|
|
154
|
+
// leaving the target's own namespace, which always exists.
|
|
155
|
+
if (ids.length === 0) {
|
|
156
|
+
value = true;
|
|
157
|
+
} else {
|
|
158
|
+
value =
|
|
159
|
+
ids[0] === "__esModule"
|
|
160
|
+
? ids.length === 1 || undefined
|
|
161
|
+
: exportsInfo.isExportProvided(ids);
|
|
162
|
+
}
|
|
157
163
|
break;
|
|
158
164
|
}
|
|
159
165
|
case "dynamic": {
|