@rspack/core 1.0.0-alpha.5 → 1.0.0-beta.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/compiled/zod/index.d.ts +138 -52
- package/compiled/zod/index.js +300 -103
- package/compiled/zod/package.json +1 -1
- package/compiled/zod-validation-error/index.js +6 -6
- package/dist/Compilation.d.ts +21 -3
- package/dist/Compilation.js +64 -49
- package/dist/Compiler.js +28 -28
- package/dist/ErrorHelpers.js +2 -4
- package/dist/Module.js +2 -6
- package/dist/ModuleTypeConstants.d.ts +45 -69
- package/dist/ModuleTypeConstants.js +24 -77
- package/dist/Stats.js +4 -6
- package/dist/Template.d.ts +31 -147
- package/dist/Template.js +40 -236
- package/dist/builtin-loader/lightningcss/index.d.ts +89 -0
- package/dist/builtin-loader/lightningcss/index.js +175 -0
- package/dist/builtin-plugin/BannerPlugin.d.ts +24 -48
- package/dist/builtin-plugin/DefinePlugin.js +9 -13
- package/dist/builtin-plugin/EntryPlugin.d.ts +2 -2
- package/dist/builtin-plugin/ExternalsPlugin.d.ts +24 -0
- package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +8 -8
- package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +2 -2
- package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +10 -3
- package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +4 -1
- package/dist/builtin-plugin/SplitChunksPlugin.js +5 -15
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +15 -23
- package/dist/builtin-plugin/base.js +1 -3
- package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.d.ts +3 -3
- package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +17 -66
- package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +2 -0
- package/dist/builtin-plugin/css-extract/hmr/{normalize-url.js → normalizeUrl.js} +15 -24
- package/dist/builtin-plugin/css-extract/loader.js +5 -5
- package/dist/config/adapter.d.ts +1 -1
- package/dist/config/adapter.js +24 -23
- package/dist/config/adapterRuleUse.d.ts +5 -5
- package/dist/config/adapterRuleUse.js +23 -1
- package/dist/config/browserslistTargetHandler.d.ts +17 -15
- package/dist/config/browserslistTargetHandler.js +27 -33
- package/dist/config/defaults.js +20 -21
- package/dist/config/normalization.d.ts +2 -0
- package/dist/config/normalization.js +5 -5
- package/dist/config/target.d.ts +48 -109
- package/dist/config/target.js +50 -86
- package/dist/config/zod.d.ts +2391 -2205
- package/dist/config/zod.js +28 -18
- package/dist/container/ContainerPlugin.d.ts +7 -7
- package/dist/container/options.js +1 -1
- package/dist/exports.d.ts +4 -4
- package/dist/exports.js +2 -2
- package/dist/lib/CacheFacade.js +1 -0
- package/dist/lib/ModuleFilenameHelpers.js +1 -3
- package/dist/lib/cache/mergeEtags.js +5 -11
- package/dist/lib/formatLocation.js +3 -5
- package/dist/loader-runner/LoaderLoadingError.d.ts +11 -1
- package/dist/loader-runner/LoaderLoadingError.js +3 -5
- package/dist/loader-runner/index.js +7 -9
- package/dist/loader-runner/loadLoader.d.ts +11 -2
- package/dist/loader-runner/loadLoader.js +17 -19
- package/dist/logging/createConsoleLogger.js +2 -6
- package/dist/logging/truncateArgs.js +5 -9
- package/dist/node/nodeConsole.js +1 -3
- package/dist/stats/DefaultStatsFactoryPlugin.js +17 -7
- package/dist/stats/DefaultStatsPresetPlugin.js +4 -4
- package/dist/stats/DefaultStatsPrinterPlugin.js +11 -16
- package/dist/stats/StatsFactory.js +13 -17
- package/dist/stats/StatsPrinter.js +7 -9
- package/dist/util/AssetInfo.js +11 -7
- package/dist/util/SplitChunkSize.js +1 -1
- package/dist/util/cleverMerge.d.ts +33 -57
- package/dist/util/cleverMerge.js +89 -145
- package/dist/util/comparators.js +3 -5
- package/dist/util/createHash.d.ts +4 -3
- package/dist/util/createHash.js +31 -45
- package/dist/util/fs.js +9 -13
- package/dist/util/hash/BatchedHash.d.ts +24 -9
- package/dist/util/hash/BatchedHash.js +16 -13
- package/dist/util/hash/index.d.ts +9 -9
- package/dist/util/hash/index.js +14 -11
- package/dist/util/hash/md4.d.ts +29 -2
- package/dist/util/hash/md4.js +7 -3
- package/dist/util/hash/wasm-hash.d.ts +52 -5
- package/dist/util/hash/wasm-hash.js +19 -22
- package/dist/util/hash/xxhash64.d.ts +29 -2
- package/dist/util/hash/xxhash64.js +7 -3
- package/dist/util/identifier.js +9 -15
- package/dist/util/index.js +1 -1
- package/dist/util/memoize.js +7 -9
- package/package.json +9 -8
- package/dist/builtin-plugin/css-extract/hmr/normalize-url.d.ts +0 -2
package/dist/Template.js
CHANGED
|
@@ -1,40 +1,15 @@
|
|
|
1
|
-
/*
|
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
-
Author Tobias Koppers @sokra
|
|
4
|
-
*/
|
|
5
1
|
"use strict";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/** @typedef {any} CodeGenerationResults */
|
|
18
|
-
// /** @typedef {import("./Compilation").AssetInfo} AssetInfo */
|
|
19
|
-
/** @typedef {any} AssetInfo */
|
|
20
|
-
// /** @typedef {import("./Compilation").PathData} PathData */
|
|
21
|
-
/** @typedef {any} PathData */
|
|
22
|
-
// /** @typedef {import("./DependencyTemplates")} DependencyTemplates */
|
|
23
|
-
/** @typedef {any} DependencyTemplates */
|
|
24
|
-
// /** @typedef {import("./Module")} Module */
|
|
25
|
-
/** @typedef {any} Module */
|
|
26
|
-
// /** @typedef {import("./ModuleGraph")} ModuleGraph */
|
|
27
|
-
/** @typedef {any} ModuleGraph */
|
|
28
|
-
// /** @typedef {import("./ModuleTemplate")} ModuleTemplate */
|
|
29
|
-
/** @typedef {any} ModuleTemplate */
|
|
30
|
-
// /** @typedef {import("./RuntimeModule")} RuntimeModule */
|
|
31
|
-
/** @typedef {any} RuntimeModule */
|
|
32
|
-
// /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
|
33
|
-
/** @typedef {any} RuntimeTemplate */
|
|
34
|
-
// /** @typedef {import("./javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */
|
|
35
|
-
/** @typedef {any} ChunkRenderContext */
|
|
36
|
-
// /** @typedef {import("./javascript/JavascriptModulesPlugin").RenderContext} RenderContext */
|
|
37
|
-
/** @typedef {any} RenderContext */
|
|
2
|
+
/**
|
|
3
|
+
* The following code is modified based on
|
|
4
|
+
* https://github.com/webpack/webpack/blob/4b4ca3b/lib/Template.js
|
|
5
|
+
*
|
|
6
|
+
* MIT Licensed
|
|
7
|
+
* Author Tobias Koppers @sokra
|
|
8
|
+
* Copyright (c) JS Foundation and other contributors
|
|
9
|
+
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Template = void 0;
|
|
38
13
|
const START_LOWERCASE_ALPHABET_CODE = "a".charCodeAt(0);
|
|
39
14
|
const START_UPPERCASE_ALPHABET_CODE = "A".charCodeAt(0);
|
|
40
15
|
const DELTA_A_TO_Z = "z".charCodeAt(0) - START_LOWERCASE_ALPHABET_CODE + 1;
|
|
@@ -48,51 +23,11 @@ const IDENTIFIER_ALPHA_NUMERIC_NAME_REPLACE_REGEX = /[^a-zA-Z0-9$]+/g;
|
|
|
48
23
|
const COMMENT_END_REGEX = /\*\//g;
|
|
49
24
|
const PATH_NAME_NORMALIZE_REPLACE_REGEX = /[^a-zA-Z0-9_!§$()=\-^°]+/g;
|
|
50
25
|
const MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g;
|
|
51
|
-
/**
|
|
52
|
-
* @typedef {Object} RenderManifestOptions
|
|
53
|
-
* @property {Chunk} chunk the chunk used to render
|
|
54
|
-
* @property {string} hash
|
|
55
|
-
* @property {string} fullHash
|
|
56
|
-
* @property {OutputOptions} outputOptions
|
|
57
|
-
* @property {CodeGenerationResults} codeGenerationResults
|
|
58
|
-
* @property {{javascript: ModuleTemplate}} moduleTemplates
|
|
59
|
-
* @property {DependencyTemplates} dependencyTemplates
|
|
60
|
-
* @property {RuntimeTemplate} runtimeTemplate
|
|
61
|
-
* @property {ModuleGraph} moduleGraph
|
|
62
|
-
* @property {ChunkGraph} chunkGraph
|
|
63
|
-
*/
|
|
64
|
-
/** @typedef {RenderManifestEntryTemplated | RenderManifestEntryStatic} RenderManifestEntry */
|
|
65
|
-
/**
|
|
66
|
-
* @typedef {Object} RenderManifestEntryTemplated
|
|
67
|
-
* @property {function(): Source} render
|
|
68
|
-
* @property {string | function(PathData, AssetInfo=): string} filenameTemplate
|
|
69
|
-
* @property {PathData=} pathOptions
|
|
70
|
-
* @property {AssetInfo=} info
|
|
71
|
-
* @property {string} identifier
|
|
72
|
-
* @property {string=} hash
|
|
73
|
-
* @property {boolean=} auxiliary
|
|
74
|
-
*/
|
|
75
|
-
/**
|
|
76
|
-
* @typedef {Object} RenderManifestEntryStatic
|
|
77
|
-
* @property {function(): Source} render
|
|
78
|
-
* @property {string} filename
|
|
79
|
-
* @property {AssetInfo} info
|
|
80
|
-
* @property {string} identifier
|
|
81
|
-
* @property {string=} hash
|
|
82
|
-
* @property {boolean=} auxiliary
|
|
83
|
-
*/
|
|
84
|
-
/**
|
|
85
|
-
* @typedef {Object} HasId
|
|
86
|
-
* @property {number | string} id
|
|
87
|
-
*/
|
|
88
|
-
/**
|
|
89
|
-
* @typedef {function(Module, number): boolean} ModuleFilterPredicate
|
|
90
|
-
*/
|
|
91
26
|
class Template {
|
|
92
27
|
/**
|
|
93
28
|
*
|
|
94
|
-
* @param
|
|
95
|
-
* @returns
|
|
29
|
+
* @param fn a runtime function (.runtime.js) "template"
|
|
30
|
+
* @returns the updated and normalized function string
|
|
96
31
|
*/
|
|
97
32
|
static getFunctionContent(fn) {
|
|
98
33
|
return fn
|
|
@@ -102,8 +37,8 @@ class Template {
|
|
|
102
37
|
.replace(LINE_SEPARATOR_REGEX, "\n");
|
|
103
38
|
}
|
|
104
39
|
/**
|
|
105
|
-
* @param
|
|
106
|
-
* @returns
|
|
40
|
+
* @param str the string converted to identifier
|
|
41
|
+
* @returns created identifier
|
|
107
42
|
*/
|
|
108
43
|
static toIdentifier(str) {
|
|
109
44
|
if (typeof str !== "string")
|
|
@@ -114,8 +49,8 @@ class Template {
|
|
|
114
49
|
}
|
|
115
50
|
/**
|
|
116
51
|
*
|
|
117
|
-
* @param
|
|
118
|
-
* @returns
|
|
52
|
+
* @param str string to be converted to commented in bundle code
|
|
53
|
+
* @returns returns a commented version of string
|
|
119
54
|
*/
|
|
120
55
|
static toComment(str) {
|
|
121
56
|
if (!str)
|
|
@@ -124,8 +59,8 @@ class Template {
|
|
|
124
59
|
}
|
|
125
60
|
/**
|
|
126
61
|
*
|
|
127
|
-
* @param
|
|
128
|
-
* @returns
|
|
62
|
+
* @param str string to be converted to "normal comment"
|
|
63
|
+
* @returns returns a commented version of string
|
|
129
64
|
*/
|
|
130
65
|
static toNormalComment(str) {
|
|
131
66
|
if (!str)
|
|
@@ -133,8 +68,8 @@ class Template {
|
|
|
133
68
|
return `/* ${str.replace(COMMENT_END_REGEX, "* /")} */`;
|
|
134
69
|
}
|
|
135
70
|
/**
|
|
136
|
-
* @param
|
|
137
|
-
* @returns
|
|
71
|
+
* @param str string path to be normalized
|
|
72
|
+
* @returns normalized bundle-safe path
|
|
138
73
|
*/
|
|
139
74
|
static toPath(str) {
|
|
140
75
|
if (typeof str !== "string")
|
|
@@ -145,8 +80,8 @@ class Template {
|
|
|
145
80
|
}
|
|
146
81
|
// map number to a single character a-z, A-Z or multiple characters if number is too big
|
|
147
82
|
/**
|
|
148
|
-
* @param
|
|
149
|
-
* @returns
|
|
83
|
+
* @param n number to convert to ident
|
|
84
|
+
* @returns returns single character ident
|
|
150
85
|
*/
|
|
151
86
|
static numberToIdentifier(n) {
|
|
152
87
|
if (n >= NUMBER_OF_IDENTIFIER_START_CHARS) {
|
|
@@ -168,8 +103,8 @@ class Template {
|
|
|
168
103
|
return "$";
|
|
169
104
|
}
|
|
170
105
|
/**
|
|
171
|
-
* @param
|
|
172
|
-
* @returns
|
|
106
|
+
* @param n number to convert to ident
|
|
107
|
+
* @returns returns single character ident
|
|
173
108
|
*/
|
|
174
109
|
static numberToIdentifierContinuation(n) {
|
|
175
110
|
if (n >= NUMBER_OF_IDENTIFIER_CONTINUATION_CHARS) {
|
|
@@ -197,26 +132,24 @@ class Template {
|
|
|
197
132
|
}
|
|
198
133
|
/**
|
|
199
134
|
*
|
|
200
|
-
* @param
|
|
201
|
-
* @returns
|
|
135
|
+
* @param s string to convert to identity
|
|
136
|
+
* @returns converted identity
|
|
202
137
|
*/
|
|
203
138
|
static indent(s) {
|
|
204
139
|
if (Array.isArray(s)) {
|
|
205
140
|
return s.map(Template.indent).join("\n");
|
|
206
141
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
return ind + str.replace(/\n([^\n])/g, "\n\t$1");
|
|
213
|
-
}
|
|
142
|
+
const str = s.trimEnd();
|
|
143
|
+
if (!str)
|
|
144
|
+
return "";
|
|
145
|
+
const ind = str[0] === "\n" ? "" : "\t";
|
|
146
|
+
return ind + str.replace(/\n([^\n])/g, "\n\t$1");
|
|
214
147
|
}
|
|
215
148
|
/**
|
|
216
149
|
*
|
|
217
|
-
* @param
|
|
218
|
-
* @param
|
|
219
|
-
* @returns
|
|
150
|
+
* @param s string to create prefix for
|
|
151
|
+
* @param prefix prefix to compose
|
|
152
|
+
* @returns returns new prefix string
|
|
220
153
|
*/
|
|
221
154
|
static prefix(s, prefix) {
|
|
222
155
|
const str = Template.asString(s).trim();
|
|
@@ -227,8 +160,8 @@ class Template {
|
|
|
227
160
|
}
|
|
228
161
|
/**
|
|
229
162
|
*
|
|
230
|
-
* @param
|
|
231
|
-
* @returns
|
|
163
|
+
* @param str string or string collection
|
|
164
|
+
* @returns returns a single string from array
|
|
232
165
|
*/
|
|
233
166
|
static asString(str) {
|
|
234
167
|
if (Array.isArray(str)) {
|
|
@@ -237,12 +170,8 @@ class Template {
|
|
|
237
170
|
return str;
|
|
238
171
|
}
|
|
239
172
|
/**
|
|
240
|
-
* @
|
|
241
|
-
* @
|
|
242
|
-
*/
|
|
243
|
-
/**
|
|
244
|
-
* @param {WithId[]} modules a collection of modules to get array bounds for
|
|
245
|
-
* @returns {[number, number] | false} returns the upper and lower array bounds
|
|
173
|
+
* @param modules a collection of modules to get array bounds for
|
|
174
|
+
* @returns returns the upper and lower array bounds
|
|
246
175
|
* or false if not every module has a number based id
|
|
247
176
|
*/
|
|
248
177
|
static getModulesArrayBounds(modules) {
|
|
@@ -271,130 +200,5 @@ class Template {
|
|
|
271
200
|
const arrayOverhead = minId === 0 ? maxId : 16 + `${minId}`.length + maxId;
|
|
272
201
|
return arrayOverhead < objectOverhead ? [minId, maxId] : false;
|
|
273
202
|
}
|
|
274
|
-
/**
|
|
275
|
-
* @param {ChunkRenderContext} renderContext render context
|
|
276
|
-
* @param {Module[]} modules modules to render (should be ordered by identifier)
|
|
277
|
-
* @param {function(Module): Source} renderModule function to render a module
|
|
278
|
-
* @param {string=} prefix applying prefix strings
|
|
279
|
-
* @returns {Source | null} rendered chunk modules in a Source object or null if no modules
|
|
280
|
-
*/
|
|
281
|
-
static renderChunkModules(renderContext, modules, renderModule, prefix = "") {
|
|
282
|
-
const { chunkGraph } = renderContext;
|
|
283
|
-
var source = new ConcatSource();
|
|
284
|
-
if (modules.length === 0) {
|
|
285
|
-
return null;
|
|
286
|
-
}
|
|
287
|
-
/** @type {{id: string|number, source: Source|string}[]} */
|
|
288
|
-
const allModules = modules.map(module => {
|
|
289
|
-
return {
|
|
290
|
-
id: chunkGraph.getModuleId(module),
|
|
291
|
-
source: renderModule(module) || "false"
|
|
292
|
-
};
|
|
293
|
-
});
|
|
294
|
-
const bounds = Template.getModulesArrayBounds(allModules);
|
|
295
|
-
if (bounds) {
|
|
296
|
-
// Render a spare array
|
|
297
|
-
const minId = bounds[0];
|
|
298
|
-
const maxId = bounds[1];
|
|
299
|
-
if (minId !== 0) {
|
|
300
|
-
source.add(`Array(${minId}).concat(`);
|
|
301
|
-
}
|
|
302
|
-
source.add("[\n");
|
|
303
|
-
/** @type {Map<string|number, {id: string|number, source: Source|string}>} */
|
|
304
|
-
const modules = new Map();
|
|
305
|
-
for (const module of allModules) {
|
|
306
|
-
modules.set(module.id, module);
|
|
307
|
-
}
|
|
308
|
-
for (let idx = minId; idx <= maxId; idx++) {
|
|
309
|
-
const module = modules.get(idx);
|
|
310
|
-
if (idx !== minId) {
|
|
311
|
-
source.add(",\n");
|
|
312
|
-
}
|
|
313
|
-
source.add(`/* ${idx} */`);
|
|
314
|
-
if (module) {
|
|
315
|
-
source.add("\n");
|
|
316
|
-
source.add(module.source);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
source.add("\n" + prefix + "]");
|
|
320
|
-
if (minId !== 0) {
|
|
321
|
-
source.add(")");
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
else {
|
|
325
|
-
// Render an object
|
|
326
|
-
source.add("{\n");
|
|
327
|
-
for (let i = 0; i < allModules.length; i++) {
|
|
328
|
-
const module = allModules[i];
|
|
329
|
-
if (i !== 0) {
|
|
330
|
-
source.add(",\n");
|
|
331
|
-
}
|
|
332
|
-
source.add(`\n/***/ ${JSON.stringify(module.id)}:\n`);
|
|
333
|
-
source.add(module.source);
|
|
334
|
-
}
|
|
335
|
-
source.add(`\n\n${prefix}}`);
|
|
336
|
-
}
|
|
337
|
-
return source;
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* @param {RuntimeModule[]} runtimeModules array of runtime modules in order
|
|
341
|
-
* @param {RenderContext & { codeGenerationResults?: CodeGenerationResults }} renderContext render context
|
|
342
|
-
* @returns {Source} rendered runtime modules in a Source object
|
|
343
|
-
*/
|
|
344
|
-
static renderRuntimeModules(runtimeModules, renderContext) {
|
|
345
|
-
const source = new ConcatSource();
|
|
346
|
-
for (const module of runtimeModules) {
|
|
347
|
-
const codeGenerationResults = renderContext.codeGenerationResults;
|
|
348
|
-
let runtimeSource;
|
|
349
|
-
if (codeGenerationResults) {
|
|
350
|
-
runtimeSource = codeGenerationResults.getSource(module, renderContext.chunk.runtime, WEBPACK_MODULE_TYPE_RUNTIME);
|
|
351
|
-
}
|
|
352
|
-
else {
|
|
353
|
-
const codeGenResult = module.codeGeneration({
|
|
354
|
-
chunkGraph: renderContext.chunkGraph,
|
|
355
|
-
dependencyTemplates: renderContext.dependencyTemplates,
|
|
356
|
-
moduleGraph: renderContext.moduleGraph,
|
|
357
|
-
runtimeTemplate: renderContext.runtimeTemplate,
|
|
358
|
-
runtime: renderContext.chunk.runtime,
|
|
359
|
-
codeGenerationResults
|
|
360
|
-
});
|
|
361
|
-
if (!codeGenResult)
|
|
362
|
-
continue;
|
|
363
|
-
runtimeSource = codeGenResult.sources.get("runtime");
|
|
364
|
-
}
|
|
365
|
-
if (runtimeSource) {
|
|
366
|
-
source.add(Template.toNormalComment(module.identifier()) + "\n");
|
|
367
|
-
if (!module.shouldIsolate()) {
|
|
368
|
-
source.add(runtimeSource);
|
|
369
|
-
source.add("\n\n");
|
|
370
|
-
}
|
|
371
|
-
else if (renderContext.runtimeTemplate.supportsArrowFunction()) {
|
|
372
|
-
source.add("(() => {\n");
|
|
373
|
-
source.add(new PrefixSource("\t", runtimeSource));
|
|
374
|
-
source.add("\n})();\n\n");
|
|
375
|
-
}
|
|
376
|
-
else {
|
|
377
|
-
source.add("!function() {\n");
|
|
378
|
-
source.add(new PrefixSource("\t", runtimeSource));
|
|
379
|
-
source.add("\n}();\n\n");
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
return source;
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* @param {RuntimeModule[]} runtimeModules array of runtime modules in order
|
|
387
|
-
* @param {RenderContext} renderContext render context
|
|
388
|
-
* @returns {Source} rendered chunk runtime modules in a Source object
|
|
389
|
-
*/
|
|
390
|
-
static renderChunkRuntimeModules(runtimeModules, renderContext) {
|
|
391
|
-
return new PrefixSource("/******/ ", new ConcatSource(
|
|
392
|
-
// @ts-expect-error
|
|
393
|
-
`function(${RuntimeGlobals.require}) { // webpackRuntimeModules\n`, this.renderRuntimeModules(runtimeModules, renderContext), "}\n"));
|
|
394
|
-
}
|
|
395
203
|
}
|
|
396
|
-
|
|
397
|
-
module.exports.NUMBER_OF_IDENTIFIER_START_CHARS =
|
|
398
|
-
NUMBER_OF_IDENTIFIER_START_CHARS;
|
|
399
|
-
module.exports.NUMBER_OF_IDENTIFIER_CONTINUATION_CHARS =
|
|
400
|
-
NUMBER_OF_IDENTIFIER_CONTINUATION_CHARS;
|
|
204
|
+
exports.Template = Template;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export declare function browserslistToTargets(browserslist: string[]): Record<string, number>;
|
|
2
|
+
export declare function toFeatures(featureOptions: FeatureOptions): Features;
|
|
3
|
+
export declare enum Features {
|
|
4
|
+
Empty = 0,
|
|
5
|
+
Nesting = 1,
|
|
6
|
+
NotSelectorList = 2,
|
|
7
|
+
DirSelector = 4,
|
|
8
|
+
LangSelectorList = 8,
|
|
9
|
+
IsSelector = 16,
|
|
10
|
+
TextDecorationThicknessPercent = 32,
|
|
11
|
+
MediaIntervalSyntax = 64,
|
|
12
|
+
MediaRangeSyntax = 128,
|
|
13
|
+
CustomMediaQueries = 256,
|
|
14
|
+
ClampFunction = 512,
|
|
15
|
+
ColorFunction = 1024,
|
|
16
|
+
OklabColors = 2048,
|
|
17
|
+
LabColors = 4096,
|
|
18
|
+
P3Colors = 8192,
|
|
19
|
+
HexAlphaColors = 16384,
|
|
20
|
+
SpaceSeparatedColorNotation = 32768,
|
|
21
|
+
FontFamilySystemUi = 65536,
|
|
22
|
+
DoublePositionGradients = 131072,
|
|
23
|
+
VendorPrefixes = 262144,
|
|
24
|
+
LogicalProperties = 524288,
|
|
25
|
+
Selectors = 31,
|
|
26
|
+
MediaQueries = 448,
|
|
27
|
+
Color = 64512
|
|
28
|
+
}
|
|
29
|
+
export interface Targets {
|
|
30
|
+
android?: number;
|
|
31
|
+
chrome?: number;
|
|
32
|
+
edge?: number;
|
|
33
|
+
firefox?: number;
|
|
34
|
+
ie?: number;
|
|
35
|
+
ios_saf?: number;
|
|
36
|
+
opera?: number;
|
|
37
|
+
safari?: number;
|
|
38
|
+
samsung?: number;
|
|
39
|
+
}
|
|
40
|
+
export interface Drafts {
|
|
41
|
+
/** Whether to enable @custom-media rules. */
|
|
42
|
+
customMedia?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface NonStandard {
|
|
45
|
+
/** Whether to enable the non-standard >>> and /deep/ selector combinators used by Angular and Vue. */
|
|
46
|
+
deepSelectorCombinator?: boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface PseudoClasses {
|
|
49
|
+
hover?: string;
|
|
50
|
+
active?: string;
|
|
51
|
+
focus?: string;
|
|
52
|
+
focusVisible?: string;
|
|
53
|
+
focusWithin?: string;
|
|
54
|
+
}
|
|
55
|
+
export type FeatureOptions = {
|
|
56
|
+
nesting?: boolean;
|
|
57
|
+
notSelectorList?: boolean;
|
|
58
|
+
dirSelector?: boolean;
|
|
59
|
+
langSelectorList?: boolean;
|
|
60
|
+
isSelector?: boolean;
|
|
61
|
+
textDecorationThicknessPercent?: boolean;
|
|
62
|
+
mediaIntervalSyntax?: boolean;
|
|
63
|
+
mediaRangeSyntax?: boolean;
|
|
64
|
+
customMediaQueries?: boolean;
|
|
65
|
+
clampFunction?: boolean;
|
|
66
|
+
colorFunction?: boolean;
|
|
67
|
+
oklabColors?: boolean;
|
|
68
|
+
labColors?: boolean;
|
|
69
|
+
p3Colors?: boolean;
|
|
70
|
+
hexAlphaColors?: boolean;
|
|
71
|
+
spaceSeparatedColorNotation?: boolean;
|
|
72
|
+
fontFamilySystemUi?: boolean;
|
|
73
|
+
doublePositionGradients?: boolean;
|
|
74
|
+
vendorPrefixes?: boolean;
|
|
75
|
+
logicalProperties?: boolean;
|
|
76
|
+
selectors?: boolean;
|
|
77
|
+
mediaQueries?: boolean;
|
|
78
|
+
color?: boolean;
|
|
79
|
+
};
|
|
80
|
+
export type LoaderOptions = {
|
|
81
|
+
errorRecovery?: boolean;
|
|
82
|
+
targets?: Targets | string[] | string;
|
|
83
|
+
include?: FeatureOptions;
|
|
84
|
+
exclude?: FeatureOptions;
|
|
85
|
+
draft?: Drafts;
|
|
86
|
+
nonStandard?: NonStandard;
|
|
87
|
+
pseudoClasses?: PseudoClasses;
|
|
88
|
+
unusedSymbols?: string[];
|
|
89
|
+
};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// code modified based on https://github.com/parcel-bundler/lightningcss/blob/34b67a431c043fda5d4979bcdccb3008d082e243/node/browserslistToTargets.js
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Features = exports.toFeatures = exports.browserslistToTargets = void 0;
|
|
5
|
+
/**
|
|
6
|
+
MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2021-present Devon Govett
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
*/
|
|
28
|
+
const BROWSER_MAPPING = {
|
|
29
|
+
and_chr: "chrome",
|
|
30
|
+
and_ff: "firefox",
|
|
31
|
+
ie_mob: "ie",
|
|
32
|
+
op_mob: "opera",
|
|
33
|
+
and_qq: null,
|
|
34
|
+
and_uc: null,
|
|
35
|
+
baidu: null,
|
|
36
|
+
bb: null,
|
|
37
|
+
kaios: null,
|
|
38
|
+
op_mini: null
|
|
39
|
+
};
|
|
40
|
+
function browserslistToTargets(browserslist) {
|
|
41
|
+
const targets = {};
|
|
42
|
+
for (const browser of browserslist) {
|
|
43
|
+
const [name, v] = browser.split(" ");
|
|
44
|
+
if (BROWSER_MAPPING[name] === null) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const version = parseVersion(v);
|
|
48
|
+
if (version == null) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (targets[name] == null || version < targets[name]) {
|
|
52
|
+
targets[name] = version;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return targets;
|
|
56
|
+
}
|
|
57
|
+
exports.browserslistToTargets = browserslistToTargets;
|
|
58
|
+
function toFeatures(featureOptions) {
|
|
59
|
+
let feature = 0;
|
|
60
|
+
for (const key of Reflect.ownKeys(featureOptions)) {
|
|
61
|
+
if (featureOptions[key] !== true) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
switch (key) {
|
|
65
|
+
case "nesting":
|
|
66
|
+
feature |= Features.Nesting;
|
|
67
|
+
break;
|
|
68
|
+
case "notSelectorList":
|
|
69
|
+
feature |= Features.NotSelectorList;
|
|
70
|
+
break;
|
|
71
|
+
case "dirSelector":
|
|
72
|
+
feature |= Features.DirSelector;
|
|
73
|
+
break;
|
|
74
|
+
case "langSelectorList":
|
|
75
|
+
feature |= Features.LangSelectorList;
|
|
76
|
+
break;
|
|
77
|
+
case "isSelector":
|
|
78
|
+
feature |= Features.IsSelector;
|
|
79
|
+
break;
|
|
80
|
+
case "textDecorationThicknessPercent":
|
|
81
|
+
feature |= Features.TextDecorationThicknessPercent;
|
|
82
|
+
break;
|
|
83
|
+
case "mediaIntervalSyntax":
|
|
84
|
+
feature |= Features.MediaIntervalSyntax;
|
|
85
|
+
break;
|
|
86
|
+
case "mediaRangeSyntax":
|
|
87
|
+
feature |= Features.MediaRangeSyntax;
|
|
88
|
+
break;
|
|
89
|
+
case "customMediaQueries":
|
|
90
|
+
feature |= Features.CustomMediaQueries;
|
|
91
|
+
break;
|
|
92
|
+
case "clampFunction":
|
|
93
|
+
feature |= Features.ClampFunction;
|
|
94
|
+
break;
|
|
95
|
+
case "colorFunction":
|
|
96
|
+
feature |= Features.ColorFunction;
|
|
97
|
+
break;
|
|
98
|
+
case "oklabColors":
|
|
99
|
+
feature |= Features.OklabColors;
|
|
100
|
+
break;
|
|
101
|
+
case "labColors":
|
|
102
|
+
feature |= Features.LabColors;
|
|
103
|
+
break;
|
|
104
|
+
case "p3Colors":
|
|
105
|
+
feature |= Features.P3Colors;
|
|
106
|
+
break;
|
|
107
|
+
case "hexAlphaColors":
|
|
108
|
+
feature |= Features.HexAlphaColors;
|
|
109
|
+
break;
|
|
110
|
+
case "spaceSeparatedColorNotation":
|
|
111
|
+
feature |= Features.SpaceSeparatedColorNotation;
|
|
112
|
+
break;
|
|
113
|
+
case "fontFamilySystemUi":
|
|
114
|
+
feature |= Features.FontFamilySystemUi;
|
|
115
|
+
break;
|
|
116
|
+
case "doublePositionGradients":
|
|
117
|
+
feature |= Features.DoublePositionGradients;
|
|
118
|
+
break;
|
|
119
|
+
case "vendorPrefixes":
|
|
120
|
+
feature |= Features.VendorPrefixes;
|
|
121
|
+
break;
|
|
122
|
+
case "logicalProperties":
|
|
123
|
+
feature |= Features.LogicalProperties;
|
|
124
|
+
break;
|
|
125
|
+
case "selectors":
|
|
126
|
+
feature |= Features.Selectors;
|
|
127
|
+
break;
|
|
128
|
+
case "mediaQueries":
|
|
129
|
+
feature |= Features.MediaQueries;
|
|
130
|
+
break;
|
|
131
|
+
case "color":
|
|
132
|
+
feature |= Features.Color;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return feature;
|
|
137
|
+
}
|
|
138
|
+
exports.toFeatures = toFeatures;
|
|
139
|
+
function parseVersion(version) {
|
|
140
|
+
const [major, minor = 0, patch = 0] = version
|
|
141
|
+
.split("-")[0]
|
|
142
|
+
.split(".")
|
|
143
|
+
.map(v => Number.parseInt(v, 10));
|
|
144
|
+
if (isNaN(major) || isNaN(minor) || isNaN(patch)) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
return (major << 16) | (minor << 8) | patch;
|
|
148
|
+
}
|
|
149
|
+
var Features;
|
|
150
|
+
(function (Features) {
|
|
151
|
+
Features[Features["Empty"] = 0] = "Empty";
|
|
152
|
+
Features[Features["Nesting"] = 1] = "Nesting";
|
|
153
|
+
Features[Features["NotSelectorList"] = 2] = "NotSelectorList";
|
|
154
|
+
Features[Features["DirSelector"] = 4] = "DirSelector";
|
|
155
|
+
Features[Features["LangSelectorList"] = 8] = "LangSelectorList";
|
|
156
|
+
Features[Features["IsSelector"] = 16] = "IsSelector";
|
|
157
|
+
Features[Features["TextDecorationThicknessPercent"] = 32] = "TextDecorationThicknessPercent";
|
|
158
|
+
Features[Features["MediaIntervalSyntax"] = 64] = "MediaIntervalSyntax";
|
|
159
|
+
Features[Features["MediaRangeSyntax"] = 128] = "MediaRangeSyntax";
|
|
160
|
+
Features[Features["CustomMediaQueries"] = 256] = "CustomMediaQueries";
|
|
161
|
+
Features[Features["ClampFunction"] = 512] = "ClampFunction";
|
|
162
|
+
Features[Features["ColorFunction"] = 1024] = "ColorFunction";
|
|
163
|
+
Features[Features["OklabColors"] = 2048] = "OklabColors";
|
|
164
|
+
Features[Features["LabColors"] = 4096] = "LabColors";
|
|
165
|
+
Features[Features["P3Colors"] = 8192] = "P3Colors";
|
|
166
|
+
Features[Features["HexAlphaColors"] = 16384] = "HexAlphaColors";
|
|
167
|
+
Features[Features["SpaceSeparatedColorNotation"] = 32768] = "SpaceSeparatedColorNotation";
|
|
168
|
+
Features[Features["FontFamilySystemUi"] = 65536] = "FontFamilySystemUi";
|
|
169
|
+
Features[Features["DoublePositionGradients"] = 131072] = "DoublePositionGradients";
|
|
170
|
+
Features[Features["VendorPrefixes"] = 262144] = "VendorPrefixes";
|
|
171
|
+
Features[Features["LogicalProperties"] = 524288] = "LogicalProperties";
|
|
172
|
+
Features[Features["Selectors"] = 31] = "Selectors";
|
|
173
|
+
Features[Features["MediaQueries"] = 448] = "MediaQueries";
|
|
174
|
+
Features[Features["Color"] = 64512] = "Color";
|
|
175
|
+
})(Features = exports.Features || (exports.Features = {}));
|