@rsbuild/webpack 1.1.0 → 1.1.2
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/dist/15.cjs +88 -206
- package/dist/238.js +85 -200
- package/dist/997.cjs +554 -1115
- package/dist/997.js +553 -1113
- package/dist/index.cjs +297 -721
- package/dist/index.js +179 -368
- package/dist/initConfigs.d.ts +3 -3
- package/dist/inspectConfig.d.ts +1 -1
- package/dist/plugin.d.ts +2 -2
- package/dist/progress/ProgressPlugin.d.ts +2 -0
- package/dist/shared.d.ts +0 -27
- package/dist/webpackConfig.d.ts +3 -3
- package/package.json +5 -4
package/dist/index.cjs
CHANGED
|
@@ -1,56 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_modules__ = {
|
|
3
3
|
"../../../node_modules/.pnpm/webpack@5.96.1/node_modules/webpack/lib/MultiStats.js": function(module, __unused_webpack_exports, __webpack_require__) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
Author Tobias Koppers @sokra
|
|
7
|
-
*/ const identifierUtils = __webpack_require__("../../../node_modules/.pnpm/webpack@5.96.1/node_modules/webpack/lib/util/identifier.js");
|
|
8
|
-
/** @typedef {import("../declarations/WebpackOptions").StatsOptions} StatsOptions */ /** @typedef {import("./Compilation").CreateStatsOptionsContext} CreateStatsOptionsContext */ /** @typedef {import("./Compilation").NormalizedStatsOptions} NormalizedStatsOptions */ /** @typedef {import("./Stats")} Stats */ /** @typedef {import("./stats/DefaultStatsFactoryPlugin").KnownStatsCompilation} KnownStatsCompilation */ /** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsCompilation} StatsCompilation */ /** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsError} StatsError */ /**
|
|
9
|
-
* @param {string} str string
|
|
10
|
-
* @param {string} prefix pref
|
|
11
|
-
* @returns {string} indent
|
|
12
|
-
*/ const indent = (str, prefix)=>{
|
|
13
|
-
const rem = str.replace(/\n([^\n])/g, `\n${prefix}$1`);
|
|
4
|
+
let identifierUtils = __webpack_require__("../../../node_modules/.pnpm/webpack@5.96.1/node_modules/webpack/lib/util/identifier.js"), indent = (str, prefix)=>{
|
|
5
|
+
let rem = str.replace(/\n([^\n])/g, `\n${prefix}$1`);
|
|
14
6
|
return prefix + rem;
|
|
15
7
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* @param {Stats[]} stats the child stats
|
|
19
|
-
*/ constructor(stats){
|
|
8
|
+
module.exports = class MultiStats {
|
|
9
|
+
constructor(stats){
|
|
20
10
|
this.stats = stats;
|
|
21
11
|
}
|
|
22
12
|
get hash() {
|
|
23
13
|
return this.stats.map((stat)=>stat.hash).join("");
|
|
24
14
|
}
|
|
25
|
-
|
|
26
|
-
* @returns {boolean} true if a child compilation encountered an error
|
|
27
|
-
*/ hasErrors() {
|
|
15
|
+
hasErrors() {
|
|
28
16
|
return this.stats.some((stat)=>stat.hasErrors());
|
|
29
17
|
}
|
|
30
|
-
|
|
31
|
-
* @returns {boolean} true if a child compilation had a warning
|
|
32
|
-
*/ hasWarnings() {
|
|
18
|
+
hasWarnings() {
|
|
33
19
|
return this.stats.some((stat)=>stat.hasWarnings());
|
|
34
20
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
*/ _createChildOptions(options, context) {
|
|
40
|
-
const getCreateStatsOptions = ()=>{
|
|
41
|
-
if (!options) options = {};
|
|
42
|
-
const { children: childrenOptions, ...baseOptions } = "string" == typeof options ? {
|
|
21
|
+
_createChildOptions(options, context) {
|
|
22
|
+
let getCreateStatsOptions = ()=>{
|
|
23
|
+
!options && (options = {});
|
|
24
|
+
let { children: childrenOptions, ...baseOptions } = "string" == typeof options ? {
|
|
43
25
|
preset: options
|
|
44
|
-
} :
|
|
26
|
+
} : options;
|
|
45
27
|
return {
|
|
46
28
|
childrenOptions,
|
|
47
29
|
baseOptions
|
|
48
30
|
};
|
|
49
|
-
}
|
|
50
|
-
const children = this.stats.map((stat, idx)=>{
|
|
31
|
+
}, children = this.stats.map((stat, idx)=>{
|
|
51
32
|
if ("boolean" == typeof options) return stat.compilation.createStatsOptions(options, context);
|
|
52
|
-
|
|
53
|
-
const childOptions = Array.isArray(childrenOptions) ? childrenOptions[idx] : childrenOptions;
|
|
33
|
+
let { childrenOptions, baseOptions } = getCreateStatsOptions(), childOptions = Array.isArray(childrenOptions) ? childrenOptions[idx] : childrenOptions;
|
|
54
34
|
return stat.compilation.createStatsOptions({
|
|
55
35
|
...baseOptions,
|
|
56
36
|
..."string" == typeof childOptions ? {
|
|
@@ -68,379 +48,139 @@ var __webpack_modules__ = {
|
|
|
68
48
|
children
|
|
69
49
|
};
|
|
70
50
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const childOptions = this._createChildOptions(options, {
|
|
76
|
-
forToString: false
|
|
77
|
-
});
|
|
78
|
-
/** @type {KnownStatsCompilation} */ const obj = {};
|
|
51
|
+
toJson(options) {
|
|
52
|
+
let childOptions = this._createChildOptions(options, {
|
|
53
|
+
forToString: !1
|
|
54
|
+
}), obj = {};
|
|
79
55
|
obj.children = this.stats.map((stat, idx)=>{
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return obj;
|
|
85
|
-
});
|
|
86
|
-
if (childOptions.version) obj.version = obj.children[0].version;
|
|
87
|
-
if (childOptions.hash) obj.hash = obj.children.map((j)=>j.hash).join("");
|
|
88
|
-
/**
|
|
89
|
-
* @param {StatsCompilation} j stats error
|
|
90
|
-
* @param {StatsError} obj Stats error
|
|
91
|
-
* @returns {TODO} result
|
|
92
|
-
*/ const mapError = (j, obj)=>({
|
|
56
|
+
let obj = stat.toJson(childOptions.children[idx]), compilationName = stat.compilation.name, name = compilationName && identifierUtils.makePathsRelative(stat.compilation.compiler.context, compilationName, stat.compilation.compiler.root);
|
|
57
|
+
return obj.name = name, obj;
|
|
58
|
+
}), childOptions.version && (obj.version = obj.children[0].version), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(""));
|
|
59
|
+
let mapError = (j, obj)=>({
|
|
93
60
|
...obj,
|
|
94
61
|
compilerPath: obj.compilerPath ? `${j.name}.${obj.compilerPath}` : j.name
|
|
95
62
|
});
|
|
96
|
-
if (childOptions.errors)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
for (const i of errors)obj.errors.push(mapError(j, i));
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
if (childOptions.warnings) {
|
|
104
|
-
obj.warnings = [];
|
|
105
|
-
for (const j of obj.children){
|
|
106
|
-
const warnings = /** @type {NonNullable<KnownStatsCompilation["warnings"]>} */ j.warnings;
|
|
107
|
-
for (const i of warnings)obj.warnings.push(mapError(j, i));
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if (childOptions.errorsCount) {
|
|
111
|
-
obj.errorsCount = 0;
|
|
112
|
-
for (const j of obj.children)obj.errorsCount += /** @type {number} */ j.errorsCount;
|
|
113
|
-
}
|
|
114
|
-
if (childOptions.warningsCount) {
|
|
115
|
-
obj.warningsCount = 0;
|
|
116
|
-
for (const j of obj.children)obj.warningsCount += /** @type {number} */ j.warningsCount;
|
|
117
|
-
}
|
|
63
|
+
if (childOptions.errors) for (let j of (obj.errors = [], obj.children))for (let i of j.errors)obj.errors.push(mapError(j, i));
|
|
64
|
+
if (childOptions.warnings) for (let j of (obj.warnings = [], obj.children))for (let i of j.warnings)obj.warnings.push(mapError(j, i));
|
|
65
|
+
if (childOptions.errorsCount) for (let j of (obj.errorsCount = 0, obj.children))obj.errorsCount += j.errorsCount;
|
|
66
|
+
if (childOptions.warningsCount) for (let j of (obj.warningsCount = 0, obj.children))obj.warningsCount += j.warningsCount;
|
|
118
67
|
return obj;
|
|
119
68
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
*/ toString(options) {
|
|
124
|
-
const childOptions = this._createChildOptions(options, {
|
|
125
|
-
forToString: true
|
|
69
|
+
toString(options) {
|
|
70
|
+
let childOptions = this._createChildOptions(options, {
|
|
71
|
+
forToString: !0
|
|
126
72
|
});
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (!str) return str;
|
|
132
|
-
return name ? `${name}:\n${indent(str, " ")}` : str;
|
|
133
|
-
});
|
|
134
|
-
return results.filter(Boolean).join("\n\n");
|
|
73
|
+
return this.stats.map((stat, idx)=>{
|
|
74
|
+
let str = stat.toString(childOptions.children[idx]), compilationName = stat.compilation.name, name = compilationName && identifierUtils.makePathsRelative(stat.compilation.compiler.context, compilationName, stat.compilation.compiler.root).replace(/\|/g, " ");
|
|
75
|
+
return str ? name ? `${name}:\n${indent(str, " ")}` : str : str;
|
|
76
|
+
}).filter(Boolean).join("\n\n");
|
|
135
77
|
}
|
|
136
|
-
}
|
|
137
|
-
module.exports = MultiStats;
|
|
78
|
+
};
|
|
138
79
|
},
|
|
139
80
|
"../../../node_modules/.pnpm/webpack@5.96.1/node_modules/webpack/lib/util/identifier.js": function(module, __unused_webpack_exports, __webpack_require__) {
|
|
140
|
-
|
|
141
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
142
|
-
*/ const path = __webpack_require__("path");
|
|
143
|
-
const WINDOWS_ABS_PATH_REGEXP = /^[a-zA-Z]:[\\/]/;
|
|
144
|
-
const SEGMENTS_SPLIT_REGEXP = /([|!])/;
|
|
145
|
-
const WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g;
|
|
146
|
-
/**
|
|
147
|
-
* @typedef {object} MakeRelativePathsCache
|
|
148
|
-
* @property {Map<string, Map<string, string>>=} relativePaths
|
|
149
|
-
*/ /**
|
|
150
|
-
* @param {string} relativePath relative path
|
|
151
|
-
* @returns {string} request
|
|
152
|
-
*/ const relativePathToRequest = (relativePath)=>{
|
|
153
|
-
if ("" === relativePath) return "./.";
|
|
154
|
-
if (".." === relativePath) return "../.";
|
|
155
|
-
if (relativePath.startsWith("../")) return relativePath;
|
|
156
|
-
return `./${relativePath}`;
|
|
157
|
-
};
|
|
158
|
-
/**
|
|
159
|
-
* @param {string} context context for relative path
|
|
160
|
-
* @param {string} maybeAbsolutePath path to make relative
|
|
161
|
-
* @returns {string} relative path in request style
|
|
162
|
-
*/ const absoluteToRequest = (context, maybeAbsolutePath)=>{
|
|
81
|
+
let path = __webpack_require__("path"), WINDOWS_ABS_PATH_REGEXP = /^[a-zA-Z]:[\\/]/, SEGMENTS_SPLIT_REGEXP = /([|!])/, WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g, relativePathToRequest = (relativePath)=>"" === relativePath ? "./." : ".." === relativePath ? "../." : relativePath.startsWith("../") ? relativePath : `./${relativePath}`, absoluteToRequest = (context, maybeAbsolutePath)=>{
|
|
163
82
|
if ("/" === maybeAbsolutePath[0]) {
|
|
164
|
-
if (maybeAbsolutePath.length > 1 && "/" === maybeAbsolutePath[maybeAbsolutePath.length - 1])
|
|
165
|
-
|
|
166
|
-
return maybeAbsolutePath;
|
|
167
|
-
const querySplitPos = maybeAbsolutePath.indexOf("?");
|
|
168
|
-
let resource = -1 === querySplitPos ? maybeAbsolutePath : maybeAbsolutePath.slice(0, querySplitPos);
|
|
169
|
-
resource = relativePathToRequest(path.posix.relative(context, resource));
|
|
170
|
-
return -1 === querySplitPos ? resource : resource + maybeAbsolutePath.slice(querySplitPos);
|
|
83
|
+
if (maybeAbsolutePath.length > 1 && "/" === maybeAbsolutePath[maybeAbsolutePath.length - 1]) return maybeAbsolutePath;
|
|
84
|
+
let querySplitPos = maybeAbsolutePath.indexOf("?"), resource = -1 === querySplitPos ? maybeAbsolutePath : maybeAbsolutePath.slice(0, querySplitPos);
|
|
85
|
+
return resource = relativePathToRequest(path.posix.relative(context, resource)), -1 === querySplitPos ? resource : resource + maybeAbsolutePath.slice(querySplitPos);
|
|
171
86
|
}
|
|
172
87
|
if (WINDOWS_ABS_PATH_REGEXP.test(maybeAbsolutePath)) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
resource = path.win32.relative(context, resource);
|
|
176
|
-
if (!WINDOWS_ABS_PATH_REGEXP.test(resource)) resource = relativePathToRequest(resource.replace(WINDOWS_PATH_SEPARATOR_REGEXP, "/"));
|
|
177
|
-
return -1 === querySplitPos ? resource : resource + maybeAbsolutePath.slice(querySplitPos);
|
|
88
|
+
let querySplitPos = maybeAbsolutePath.indexOf("?"), resource = -1 === querySplitPos ? maybeAbsolutePath : maybeAbsolutePath.slice(0, querySplitPos);
|
|
89
|
+
return resource = path.win32.relative(context, resource), !WINDOWS_ABS_PATH_REGEXP.test(resource) && (resource = relativePathToRequest(resource.replace(WINDOWS_PATH_SEPARATOR_REGEXP, "/"))), -1 === querySplitPos ? resource : resource + maybeAbsolutePath.slice(querySplitPos);
|
|
178
90
|
}
|
|
179
|
-
// not an absolute path
|
|
180
91
|
return maybeAbsolutePath;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
* @param {string} relativePath path
|
|
185
|
-
* @returns {string} absolute path
|
|
186
|
-
*/ const requestToAbsolute = (context, relativePath)=>{
|
|
187
|
-
if (relativePath.startsWith("./") || relativePath.startsWith("../")) return path.join(context, relativePath);
|
|
188
|
-
return relativePath;
|
|
189
|
-
};
|
|
190
|
-
/**
|
|
191
|
-
* @template T
|
|
192
|
-
* @typedef {function(string, object=): T} MakeCacheableResult
|
|
193
|
-
*/ /**
|
|
194
|
-
* @template T
|
|
195
|
-
* @typedef {function(string): T} BindCacheResultFn
|
|
196
|
-
*/ /**
|
|
197
|
-
* @template T
|
|
198
|
-
* @typedef {function(object): BindCacheResultFn<T>} BindCache
|
|
199
|
-
*/ /**
|
|
200
|
-
* @template T
|
|
201
|
-
* @param {(function(string): T)} realFn real function
|
|
202
|
-
* @returns {MakeCacheableResult<T> & { bindCache: BindCache<T> }} cacheable function
|
|
203
|
-
*/ const makeCacheable = (realFn)=>{
|
|
204
|
-
/**
|
|
205
|
-
* @template T
|
|
206
|
-
* @typedef {Map<string, T>} CacheItem
|
|
207
|
-
*/ /** @type {WeakMap<object, CacheItem<T>>} */ const cache = new WeakMap();
|
|
208
|
-
/**
|
|
209
|
-
* @param {object} associatedObjectForCache an object to which the cache will be attached
|
|
210
|
-
* @returns {CacheItem<T>} cache item
|
|
211
|
-
*/ const getCache = (associatedObjectForCache)=>{
|
|
212
|
-
const entry = cache.get(associatedObjectForCache);
|
|
92
|
+
}, requestToAbsolute = (context, relativePath)=>relativePath.startsWith("./") || relativePath.startsWith("../") ? path.join(context, relativePath) : relativePath, makeCacheable = (realFn)=>{
|
|
93
|
+
let cache = new WeakMap(), getCache = (associatedObjectForCache)=>{
|
|
94
|
+
let entry = cache.get(associatedObjectForCache);
|
|
213
95
|
if (void 0 !== entry) return entry;
|
|
214
|
-
|
|
215
|
-
cache.set(associatedObjectForCache, map);
|
|
216
|
-
|
|
217
|
-
};
|
|
218
|
-
/** @type {MakeCacheableResult<T> & { bindCache: BindCache<T> }} */ const fn = (str, associatedObjectForCache)=>{
|
|
96
|
+
let map = new Map();
|
|
97
|
+
return cache.set(associatedObjectForCache, map), map;
|
|
98
|
+
}, fn = (str, associatedObjectForCache)=>{
|
|
219
99
|
if (!associatedObjectForCache) return realFn(str);
|
|
220
|
-
|
|
221
|
-
const entry = cache.get(str);
|
|
100
|
+
let cache = getCache(associatedObjectForCache), entry = cache.get(str);
|
|
222
101
|
if (void 0 !== entry) return entry;
|
|
223
|
-
|
|
224
|
-
cache.set(str, result);
|
|
225
|
-
return result;
|
|
102
|
+
let result = realFn(str);
|
|
103
|
+
return cache.set(str, result), result;
|
|
226
104
|
};
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
* @returns {T} value
|
|
232
|
-
*/ return (str)=>{
|
|
233
|
-
const entry = cache.get(str);
|
|
105
|
+
return fn.bindCache = (associatedObjectForCache)=>{
|
|
106
|
+
let cache = getCache(associatedObjectForCache);
|
|
107
|
+
return (str)=>{
|
|
108
|
+
let entry = cache.get(str);
|
|
234
109
|
if (void 0 !== entry) return entry;
|
|
235
|
-
|
|
236
|
-
cache.set(str, result);
|
|
237
|
-
return result;
|
|
110
|
+
let result = realFn(str);
|
|
111
|
+
return cache.set(str, result), result;
|
|
238
112
|
};
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
* @param {function(string, string): string} fn function
|
|
244
|
-
* @returns {MakeCacheableWithContextResult & { bindCache: BindCacheForContext, bindContextCache: BindContextCacheForContext }} cacheable function with context
|
|
245
|
-
*/ const makeCacheableWithContext = (fn)=>{
|
|
246
|
-
/** @type {WeakMap<object, Map<string, Map<string, string>>>} */ const cache = new WeakMap();
|
|
247
|
-
/** @type {MakeCacheableWithContextResult & { bindCache: BindCacheForContext, bindContextCache: BindContextCacheForContext }} */ const cachedFn = (context, identifier, associatedObjectForCache)=>{
|
|
113
|
+
}, fn;
|
|
114
|
+
}, makeCacheableWithContext = (fn)=>{
|
|
115
|
+
let cache = new WeakMap(), cachedFn = (context, identifier, associatedObjectForCache)=>{
|
|
116
|
+
let cachedResult;
|
|
248
117
|
if (!associatedObjectForCache) return fn(context, identifier);
|
|
249
118
|
let innerCache = cache.get(associatedObjectForCache);
|
|
250
|
-
|
|
251
|
-
innerCache = new Map();
|
|
252
|
-
cache.set(associatedObjectForCache, innerCache);
|
|
253
|
-
}
|
|
254
|
-
let cachedResult;
|
|
119
|
+
void 0 === innerCache && (innerCache = new Map(), cache.set(associatedObjectForCache, innerCache));
|
|
255
120
|
let innerSubCache = innerCache.get(context);
|
|
256
|
-
if (void 0 === innerSubCache
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
const result = fn(context, identifier);
|
|
260
|
-
innerSubCache.set(identifier, result);
|
|
261
|
-
return result;
|
|
121
|
+
if (void 0 === innerSubCache ? innerCache.set(context, innerSubCache = new Map()) : cachedResult = innerSubCache.get(identifier), void 0 !== cachedResult) return cachedResult;
|
|
122
|
+
let result = fn(context, identifier);
|
|
123
|
+
return innerSubCache.set(identifier, result), result;
|
|
262
124
|
};
|
|
263
|
-
|
|
125
|
+
return cachedFn.bindCache = (associatedObjectForCache)=>{
|
|
264
126
|
let innerCache;
|
|
265
|
-
|
|
266
|
-
innerCache = cache.get(associatedObjectForCache);
|
|
267
|
-
if (void 0 === innerCache) {
|
|
268
|
-
innerCache = new Map();
|
|
269
|
-
cache.set(associatedObjectForCache, innerCache);
|
|
270
|
-
}
|
|
271
|
-
} else innerCache = new Map();
|
|
272
|
-
/**
|
|
273
|
-
* @param {string} context context used to create relative path
|
|
274
|
-
* @param {string} identifier identifier used to create relative path
|
|
275
|
-
* @returns {string} the returned relative path
|
|
276
|
-
*/ const boundFn = (context, identifier)=>{
|
|
127
|
+
return associatedObjectForCache ? void 0 === (innerCache = cache.get(associatedObjectForCache)) && (innerCache = new Map(), cache.set(associatedObjectForCache, innerCache)) : innerCache = new Map(), (context, identifier)=>{
|
|
277
128
|
let cachedResult;
|
|
278
129
|
let innerSubCache = innerCache.get(context);
|
|
279
|
-
if (void 0 === innerSubCache
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
const result = fn(context, identifier);
|
|
283
|
-
innerSubCache.set(identifier, result);
|
|
284
|
-
return result;
|
|
130
|
+
if (void 0 === innerSubCache ? innerCache.set(context, innerSubCache = new Map()) : cachedResult = innerSubCache.get(identifier), void 0 !== cachedResult) return cachedResult;
|
|
131
|
+
let result = fn(context, identifier);
|
|
132
|
+
return innerSubCache.set(identifier, result), result;
|
|
285
133
|
};
|
|
286
|
-
|
|
287
|
-
};
|
|
288
|
-
/** @type {BindContextCacheForContext} */ cachedFn.bindContextCache = (context, associatedObjectForCache)=>{
|
|
134
|
+
}, cachedFn.bindContextCache = (context, associatedObjectForCache)=>{
|
|
289
135
|
let innerSubCache;
|
|
290
136
|
if (associatedObjectForCache) {
|
|
291
137
|
let innerCache = cache.get(associatedObjectForCache);
|
|
292
|
-
|
|
293
|
-
innerCache = new Map();
|
|
294
|
-
cache.set(associatedObjectForCache, innerCache);
|
|
295
|
-
}
|
|
296
|
-
innerSubCache = innerCache.get(context);
|
|
297
|
-
if (void 0 === innerSubCache) innerCache.set(context, innerSubCache = new Map());
|
|
138
|
+
void 0 === innerCache && (innerCache = new Map(), cache.set(associatedObjectForCache, innerCache)), void 0 === (innerSubCache = innerCache.get(context)) && innerCache.set(context, innerSubCache = new Map());
|
|
298
139
|
} else innerSubCache = new Map();
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
* @returns {string} the returned relative path
|
|
302
|
-
*/ const boundFn = (identifier)=>{
|
|
303
|
-
const cachedResult = innerSubCache.get(identifier);
|
|
140
|
+
return (identifier)=>{
|
|
141
|
+
let cachedResult = innerSubCache.get(identifier);
|
|
304
142
|
if (void 0 !== cachedResult) return cachedResult;
|
|
305
|
-
|
|
306
|
-
innerSubCache.set(identifier, result);
|
|
307
|
-
return result;
|
|
143
|
+
let result = fn(context, identifier);
|
|
144
|
+
return innerSubCache.set(identifier, result), result;
|
|
308
145
|
};
|
|
309
|
-
|
|
310
|
-
};
|
|
311
|
-
return cachedFn;
|
|
146
|
+
}, cachedFn;
|
|
312
147
|
};
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
* @returns {string} a converted relative path
|
|
317
|
-
*/ const _makePathsRelative = (context, identifier)=>identifier.split(SEGMENTS_SPLIT_REGEXP).map((str)=>absoluteToRequest(context, str)).join("");
|
|
318
|
-
module.exports.makePathsRelative = makeCacheableWithContext(_makePathsRelative);
|
|
319
|
-
/**
|
|
320
|
-
* @param {string} context context for relative path
|
|
321
|
-
* @param {string} identifier identifier for path
|
|
322
|
-
* @returns {string} a converted relative path
|
|
323
|
-
*/ const _makePathsAbsolute = (context, identifier)=>identifier.split(SEGMENTS_SPLIT_REGEXP).map((str)=>requestToAbsolute(context, str)).join("");
|
|
324
|
-
module.exports.makePathsAbsolute = makeCacheableWithContext(_makePathsAbsolute);
|
|
325
|
-
/**
|
|
326
|
-
* @param {string} context absolute context path
|
|
327
|
-
* @param {string} request any request string may containing absolute paths, query string, etc.
|
|
328
|
-
* @returns {string} a new request string avoiding absolute paths when possible
|
|
329
|
-
*/ const _contextify = (context, request)=>request.split("!").map((r)=>absoluteToRequest(context, r)).join("!");
|
|
330
|
-
const contextify = makeCacheableWithContext(_contextify);
|
|
148
|
+
module.exports.makePathsRelative = makeCacheableWithContext((context, identifier)=>identifier.split(SEGMENTS_SPLIT_REGEXP).map((str)=>absoluteToRequest(context, str)).join(""));
|
|
149
|
+
module.exports.makePathsAbsolute = makeCacheableWithContext((context, identifier)=>identifier.split(SEGMENTS_SPLIT_REGEXP).map((str)=>requestToAbsolute(context, str)).join(""));
|
|
150
|
+
let contextify = makeCacheableWithContext((context, request)=>request.split("!").map((r)=>absoluteToRequest(context, r)).join("!"));
|
|
331
151
|
module.exports.contextify = contextify;
|
|
332
|
-
|
|
333
|
-
* @param {string} context absolute context path
|
|
334
|
-
* @param {string} request any request string
|
|
335
|
-
* @returns {string} a new request string using absolute paths when possible
|
|
336
|
-
*/ const _absolutify = (context, request)=>request.split("!").map((r)=>requestToAbsolute(context, r)).join("!");
|
|
337
|
-
const absolutify = makeCacheableWithContext(_absolutify);
|
|
152
|
+
let absolutify = makeCacheableWithContext((context, request)=>request.split("!").map((r)=>requestToAbsolute(context, r)).join("!"));
|
|
338
153
|
module.exports.absolutify = absolutify;
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
* @param {string} str the path with query and fragment
|
|
343
|
-
* @returns {ParsedResource} parsed parts
|
|
344
|
-
*/ const _parseResource = (str)=>{
|
|
345
|
-
const match = /** @type {unknown} */ PATH_QUERY_FRAGMENT_REGEXP.exec(str);
|
|
154
|
+
let PATH_QUERY_FRAGMENT_REGEXP = /^((?:\0.|[^?#\0])*)(\?(?:\0.|[^#\0])*)?(#.*)?$/, PATH_QUERY_REGEXP = /^((?:\0.|[^?\0])*)(\?.*)?$/;
|
|
155
|
+
module.exports.parseResource = makeCacheable((str)=>{
|
|
156
|
+
let match = PATH_QUERY_FRAGMENT_REGEXP.exec(str);
|
|
346
157
|
return {
|
|
347
158
|
resource: str,
|
|
348
159
|
path: match[1].replace(/\0(.)/g, "$1"),
|
|
349
160
|
query: match[2] ? match[2].replace(/\0(.)/g, "$1") : "",
|
|
350
161
|
fragment: match[3] || ""
|
|
351
162
|
};
|
|
352
|
-
};
|
|
353
|
-
module.exports.
|
|
354
|
-
|
|
355
|
-
* Parse resource, skips fragment part
|
|
356
|
-
* @param {string} str the path with query and fragment
|
|
357
|
-
* @returns {ParsedResourceWithoutFragment} parsed parts
|
|
358
|
-
*/ const _parseResourceWithoutFragment = (str)=>{
|
|
359
|
-
const match = /** @type {unknown} */ PATH_QUERY_REGEXP.exec(str);
|
|
163
|
+
});
|
|
164
|
+
module.exports.parseResourceWithoutFragment = makeCacheable((str)=>{
|
|
165
|
+
let match = PATH_QUERY_REGEXP.exec(str);
|
|
360
166
|
return {
|
|
361
167
|
resource: str,
|
|
362
168
|
path: match[1].replace(/\0(.)/g, "$1"),
|
|
363
169
|
query: match[2] ? match[2].replace(/\0(.)/g, "$1") : ""
|
|
364
170
|
};
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
* @param {string} filename the filename which should be undone
|
|
369
|
-
* @param {string} outputPath the output path that is restored (only relevant when filename contains "..")
|
|
370
|
-
* @param {boolean} enforceRelative true returns ./ for empty paths
|
|
371
|
-
* @returns {string} repeated ../ to leave the directory of the provided filename to be back on output dir
|
|
372
|
-
*/ module.exports.getUndoPath = (filename, outputPath, enforceRelative)=>{
|
|
373
|
-
let depth = -1;
|
|
374
|
-
let append = "";
|
|
375
|
-
outputPath = outputPath.replace(/[\\/]$/, "");
|
|
376
|
-
for (const part of filename.split(/[/\\]+/))if (".." === part) {
|
|
171
|
+
}), module.exports.getUndoPath = (filename, outputPath, enforceRelative)=>{
|
|
172
|
+
let depth = -1, append = "";
|
|
173
|
+
for (let part of (outputPath = outputPath.replace(/[\\/]$/, ""), filename.split(/[/\\]+/)))if (".." === part) {
|
|
377
174
|
if (depth > -1) depth--;
|
|
378
175
|
else {
|
|
379
|
-
|
|
380
|
-
const j = outputPath.lastIndexOf("\\");
|
|
381
|
-
const pos = i < 0 ? j : j < 0 ? i : Math.max(i, j);
|
|
176
|
+
let i = outputPath.lastIndexOf("/"), j = outputPath.lastIndexOf("\\"), pos = i < 0 ? j : j < 0 ? i : Math.max(i, j);
|
|
382
177
|
if (pos < 0) return `${outputPath}/`;
|
|
383
|
-
append = `${outputPath.slice(pos + 1)}/${append}
|
|
384
|
-
outputPath = outputPath.slice(0, pos);
|
|
178
|
+
append = `${outputPath.slice(pos + 1)}/${append}`, outputPath = outputPath.slice(0, pos);
|
|
385
179
|
}
|
|
386
|
-
} else
|
|
180
|
+
} else "." !== part && depth++;
|
|
387
181
|
return depth > 0 ? `${"../".repeat(depth)}${append}` : enforceRelative ? `./${append}` : append;
|
|
388
182
|
};
|
|
389
183
|
},
|
|
390
|
-
"./src/shared.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
391
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
392
|
-
A9: function() {
|
|
393
|
-
return initRsbuildConfig;
|
|
394
|
-
},
|
|
395
|
-
AS: function() {
|
|
396
|
-
return prettyTime;
|
|
397
|
-
},
|
|
398
|
-
DO: function() {
|
|
399
|
-
return stringifyConfig;
|
|
400
|
-
},
|
|
401
|
-
EB: function() {
|
|
402
|
-
return modifyBundlerChain;
|
|
403
|
-
},
|
|
404
|
-
Oo: function() {
|
|
405
|
-
return registerBuildHook;
|
|
406
|
-
},
|
|
407
|
-
PD: function() {
|
|
408
|
-
return getRsbuildInspectConfig;
|
|
409
|
-
},
|
|
410
|
-
PZ: function() {
|
|
411
|
-
return createDevServer;
|
|
412
|
-
},
|
|
413
|
-
SM: function() {
|
|
414
|
-
return outputInspectConfigFiles;
|
|
415
|
-
},
|
|
416
|
-
XQ: function() {
|
|
417
|
-
return castArray;
|
|
418
|
-
},
|
|
419
|
-
g5: function() {
|
|
420
|
-
return getStatsOptions;
|
|
421
|
-
},
|
|
422
|
-
iL: function() {
|
|
423
|
-
return chainToConfig;
|
|
424
|
-
},
|
|
425
|
-
px: function() {
|
|
426
|
-
return getChainUtils;
|
|
427
|
-
},
|
|
428
|
-
v1: function() {
|
|
429
|
-
return formatStats;
|
|
430
|
-
},
|
|
431
|
-
xn: function() {
|
|
432
|
-
return registerDevHook;
|
|
433
|
-
}
|
|
434
|
-
});
|
|
435
|
-
/* ESM import */ var _rsbuild_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("@rsbuild/core");
|
|
436
|
-
const { getChainUtils, initRsbuildConfig, createDevServer, formatStats, getStatsOptions, stringifyConfig, outputInspectConfigFiles, getRsbuildInspectConfig, chainToConfig, modifyBundlerChain, registerDevHook, registerBuildHook, prettyTime } = _rsbuild_core__WEBPACK_IMPORTED_MODULE_0__.__internalHelper;
|
|
437
|
-
const castArray = (arr)=>{
|
|
438
|
-
if (void 0 === arr) return [];
|
|
439
|
-
return Array.isArray(arr) ? arr : [
|
|
440
|
-
arr
|
|
441
|
-
];
|
|
442
|
-
};
|
|
443
|
-
},
|
|
444
184
|
"@rsbuild/core": function(module) {
|
|
445
185
|
module.exports = require("@rsbuild/core");
|
|
446
186
|
},
|
|
@@ -468,103 +208,61 @@ var __webpack_modules__ = {
|
|
|
468
208
|
webpack: function(module) {
|
|
469
209
|
module.exports = import("webpack");
|
|
470
210
|
}
|
|
471
|
-
};
|
|
472
|
-
/************************************************************************/ // The module cache
|
|
473
|
-
var __webpack_module_cache__ = {};
|
|
474
|
-
// The require function
|
|
211
|
+
}, __webpack_module_cache__ = {};
|
|
475
212
|
function __webpack_require__(moduleId) {
|
|
476
|
-
// Check if module is in cache
|
|
477
213
|
var cachedModule = __webpack_module_cache__[moduleId];
|
|
478
214
|
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
479
|
-
// Create a new module (and put it into the cache)
|
|
480
215
|
var module = __webpack_module_cache__[moduleId] = {
|
|
481
216
|
id: moduleId,
|
|
482
|
-
loaded:
|
|
217
|
+
loaded: !1,
|
|
483
218
|
exports: {}
|
|
484
219
|
};
|
|
485
|
-
|
|
486
|
-
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
487
|
-
// Flag the module as loaded
|
|
488
|
-
module.loaded = true;
|
|
489
|
-
// Return the exports of the module
|
|
490
|
-
return module.exports;
|
|
220
|
+
return __webpack_modules__[moduleId](module, module.exports, __webpack_require__), module.loaded = !0, module.exports;
|
|
491
221
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
var resolveQueue = function(queue) {
|
|
500
|
-
if (queue && queue.d < 1) {
|
|
501
|
-
queue.d = 1;
|
|
502
|
-
queue.forEach(function(fn) {
|
|
503
|
-
fn.r--;
|
|
504
|
-
});
|
|
505
|
-
queue.forEach(function(fn) {
|
|
506
|
-
fn.r-- ? fn.r++ : fn();
|
|
507
|
-
});
|
|
508
|
-
}
|
|
509
|
-
};
|
|
510
|
-
var wrapDeps = function(deps) {
|
|
511
|
-
return deps.map(function(dep) {
|
|
512
|
-
if (null !== dep && "object" == typeof dep) {
|
|
513
|
-
if (dep[webpackQueues]) return dep;
|
|
514
|
-
if (dep.then) {
|
|
515
|
-
var queue = [];
|
|
516
|
-
queue.d = 0;
|
|
517
|
-
dep.then(function(r) {
|
|
518
|
-
obj[webpackExports] = r;
|
|
519
|
-
resolveQueue(queue);
|
|
520
|
-
}, function(e) {
|
|
521
|
-
obj[webpackError] = e;
|
|
522
|
-
resolveQueue(queue);
|
|
523
|
-
});
|
|
524
|
-
var obj = {};
|
|
525
|
-
obj[webpackQueues] = function(fn) {
|
|
526
|
-
fn(queue);
|
|
527
|
-
};
|
|
528
|
-
return obj;
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
var ret = {};
|
|
532
|
-
ret[webpackQueues] = function() {};
|
|
533
|
-
ret[webpackExports] = dep;
|
|
534
|
-
return ret;
|
|
535
|
-
});
|
|
222
|
+
__webpack_require__.m = __webpack_modules__, (()=>{
|
|
223
|
+
var webpackQueues = "function" == typeof Symbol ? Symbol("webpack queues") : "__webpack_queues__", webpackExports = "function" == typeof Symbol ? Symbol("webpack exports") : "__webpack_exports__", webpackError = "function" == typeof Symbol ? Symbol("webpack error") : "__webpack_error__", resolveQueue = function(queue) {
|
|
224
|
+
queue && queue.d < 1 && (queue.d = 1, queue.forEach(function(fn) {
|
|
225
|
+
fn.r--;
|
|
226
|
+
}), queue.forEach(function(fn) {
|
|
227
|
+
fn.r-- ? fn.r++ : fn();
|
|
228
|
+
}));
|
|
536
229
|
};
|
|
537
230
|
__webpack_require__.a = function(module, body, hasAwait) {
|
|
538
|
-
var queue;
|
|
539
231
|
hasAwait && ((queue = []).d = -1);
|
|
540
|
-
var depQueues = new Set()
|
|
541
|
-
|
|
542
|
-
var currentDeps;
|
|
543
|
-
var outerResolve;
|
|
544
|
-
var reject;
|
|
545
|
-
var promise = new Promise(function(resolve, rej) {
|
|
546
|
-
reject = rej;
|
|
547
|
-
outerResolve = resolve;
|
|
232
|
+
var queue, currentDeps, outerResolve, reject, depQueues = new Set(), exports1 = module.exports, promise = new Promise(function(resolve, rej) {
|
|
233
|
+
reject = rej, outerResolve = resolve;
|
|
548
234
|
});
|
|
549
|
-
promise[webpackExports] = exports1
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
235
|
+
promise[webpackExports] = exports1, promise[webpackQueues] = function(fn) {
|
|
236
|
+
queue && fn(queue), depQueues.forEach(fn), promise.catch(function() {});
|
|
237
|
+
}, module.exports = promise, body(function(deps) {
|
|
238
|
+
currentDeps = deps.map(function(dep) {
|
|
239
|
+
if (null !== dep && "object" == typeof dep) {
|
|
240
|
+
if (dep[webpackQueues]) return dep;
|
|
241
|
+
if (dep.then) {
|
|
242
|
+
var queue = [];
|
|
243
|
+
queue.d = 0, dep.then(function(r) {
|
|
244
|
+
obj[webpackExports] = r, resolveQueue(queue);
|
|
245
|
+
}, function(e) {
|
|
246
|
+
obj[webpackError] = e, resolveQueue(queue);
|
|
247
|
+
});
|
|
248
|
+
var obj = {};
|
|
249
|
+
return obj[webpackQueues] = function(fn) {
|
|
250
|
+
fn(queue);
|
|
251
|
+
}, obj;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
var ret = {};
|
|
255
|
+
return ret[webpackQueues] = function() {}, ret[webpackExports] = dep, ret;
|
|
256
|
+
});
|
|
257
|
+
var fn, getResult = function() {
|
|
558
258
|
return currentDeps.map(function(d) {
|
|
559
259
|
if (d[webpackError]) throw d[webpackError];
|
|
560
260
|
return d[webpackExports];
|
|
561
261
|
});
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
fn = function() {
|
|
262
|
+
}, promise = new Promise(function(resolve) {
|
|
263
|
+
(fn = function() {
|
|
565
264
|
resolve(getResult);
|
|
566
|
-
};
|
|
567
|
-
fn.r = 0;
|
|
265
|
+
}).r = 0;
|
|
568
266
|
var fnQueue = function(q) {
|
|
569
267
|
q === queue || depQueues.has(q) || (depQueues.add(q), q && !q.d && (fn.r++, q.push(fn)));
|
|
570
268
|
};
|
|
@@ -575,141 +273,76 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
575
273
|
return fn.r ? promise : getResult();
|
|
576
274
|
}, function(err) {
|
|
577
275
|
err ? reject(promise[webpackError] = err) : outerResolve(exports1), resolveQueue(queue);
|
|
578
|
-
});
|
|
579
|
-
queue && queue.d < 0 && (queue.d = 0);
|
|
276
|
+
}), queue && queue.d < 0 && (queue.d = 0);
|
|
580
277
|
};
|
|
581
|
-
})()
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
__webpack_require__.n = function(module) {
|
|
586
|
-
var getter = module && module.__esModule ? function() {
|
|
587
|
-
return module['default'];
|
|
588
|
-
} : function() {
|
|
589
|
-
return module;
|
|
590
|
-
};
|
|
591
|
-
__webpack_require__.d(getter, {
|
|
592
|
-
a: getter
|
|
593
|
-
});
|
|
594
|
-
return getter;
|
|
595
|
-
};
|
|
596
|
-
})();
|
|
597
|
-
// webpack/runtime/define_property_getters
|
|
598
|
-
(()=>{
|
|
599
|
-
__webpack_require__.d = function(exports1, definition) {
|
|
600
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
601
|
-
enumerable: true,
|
|
602
|
-
get: definition[key]
|
|
603
|
-
});
|
|
604
|
-
};
|
|
605
|
-
})();
|
|
606
|
-
// webpack/runtime/ensure_chunk
|
|
607
|
-
(()=>{
|
|
608
|
-
__webpack_require__.f = {};
|
|
609
|
-
// This file contains only the entry chunk.
|
|
610
|
-
// The chunk loading function for additional chunks
|
|
611
|
-
__webpack_require__.e = function(chunkId) {
|
|
612
|
-
return Promise.all(Object.keys(__webpack_require__.f).reduce(function(promises, key) {
|
|
613
|
-
__webpack_require__.f[key](chunkId, promises);
|
|
614
|
-
return promises;
|
|
615
|
-
}, []));
|
|
616
|
-
};
|
|
617
|
-
})();
|
|
618
|
-
// webpack/runtime/get javascript chunk filename
|
|
619
|
-
(()=>{
|
|
620
|
-
// This function allow to reference chunks
|
|
621
|
-
__webpack_require__.u = function(chunkId) {
|
|
622
|
-
// return url for filenames not based on template
|
|
623
|
-
// return url for filenames based on template
|
|
624
|
-
return "" + chunkId + ".cjs";
|
|
625
|
-
};
|
|
626
|
-
})();
|
|
627
|
-
// webpack/runtime/has_own_property
|
|
628
|
-
(()=>{
|
|
629
|
-
__webpack_require__.o = function(obj, prop) {
|
|
630
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
631
|
-
};
|
|
632
|
-
})();
|
|
633
|
-
// webpack/runtime/make_namespace_object
|
|
634
|
-
(()=>{
|
|
635
|
-
// define __esModule on exports
|
|
636
|
-
__webpack_require__.r = function(exports1) {
|
|
637
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
638
|
-
value: 'Module'
|
|
639
|
-
});
|
|
640
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
641
|
-
value: true
|
|
642
|
-
});
|
|
643
|
-
};
|
|
644
|
-
})();
|
|
645
|
-
// webpack/runtime/node_module_decorator
|
|
646
|
-
(()=>{
|
|
647
|
-
__webpack_require__.nmd = function(module) {
|
|
648
|
-
module.paths = [];
|
|
649
|
-
if (!module.children) module.children = [];
|
|
278
|
+
})(), __webpack_require__.n = function(module) {
|
|
279
|
+
var getter = module && module.__esModule ? function() {
|
|
280
|
+
return module.default;
|
|
281
|
+
} : function() {
|
|
650
282
|
return module;
|
|
651
283
|
};
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
284
|
+
return __webpack_require__.d(getter, {
|
|
285
|
+
a: getter
|
|
286
|
+
}), getter;
|
|
287
|
+
}, __webpack_require__.d = function(exports1, definition) {
|
|
288
|
+
for(var key in definition)__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key) && Object.defineProperty(exports1, key, {
|
|
289
|
+
enumerable: !0,
|
|
290
|
+
get: definition[key]
|
|
291
|
+
});
|
|
292
|
+
}, __webpack_require__.f = {}, __webpack_require__.e = function(chunkId) {
|
|
293
|
+
return Promise.all(Object.keys(__webpack_require__.f).reduce(function(promises, key) {
|
|
294
|
+
return __webpack_require__.f[key](chunkId, promises), promises;
|
|
295
|
+
}, []));
|
|
296
|
+
}, __webpack_require__.u = function(chunkId) {
|
|
297
|
+
return "" + chunkId + ".cjs";
|
|
298
|
+
}, __webpack_require__.o = function(obj, prop) {
|
|
299
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
300
|
+
}, __webpack_require__.r = function(exports1) {
|
|
301
|
+
'undefined' != typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
302
|
+
value: 'Module'
|
|
303
|
+
}), Object.defineProperty(exports1, '__esModule', {
|
|
304
|
+
value: !0
|
|
305
|
+
});
|
|
306
|
+
}, __webpack_require__.nmd = function(module) {
|
|
307
|
+
return module.paths = [], !module.children && (module.children = []), module;
|
|
308
|
+
}, (()=>{
|
|
655
309
|
var installedChunks = {
|
|
656
310
|
980: 1
|
|
657
|
-
}
|
|
658
|
-
// object to store loaded chunks
|
|
659
|
-
// "1" means "loaded", otherwise not loaded yet
|
|
660
|
-
var installChunk = function(chunk) {
|
|
311
|
+
}, installChunk = function(chunk) {
|
|
661
312
|
var moreModules = chunk.modules, chunkIds = chunk.ids, runtime = chunk.runtime;
|
|
662
|
-
for(var moduleId in moreModules)
|
|
663
|
-
|
|
313
|
+
for(var moduleId in moreModules)__webpack_require__.o(moreModules, moduleId) && (__webpack_require__.m[moduleId] = moreModules[moduleId]);
|
|
314
|
+
runtime && runtime(__webpack_require__);
|
|
664
315
|
for(var i = 0; i < chunkIds.length; i++)installedChunks[chunkIds[i]] = 1;
|
|
665
316
|
};
|
|
666
|
-
// require() chunk loading for javascript
|
|
667
317
|
__webpack_require__.f.require = function(chunkId, promises) {
|
|
668
|
-
|
|
669
|
-
if (!installedChunks[chunkId]) installChunk(require("./" + __webpack_require__.u(chunkId)));
|
|
318
|
+
!installedChunks[chunkId] && installChunk(require("./" + __webpack_require__.u(chunkId)));
|
|
670
319
|
};
|
|
671
320
|
})();
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
// EXPORTS
|
|
676
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
677
|
-
webpackProvider: ()=>/* reexport */ webpackProvider
|
|
321
|
+
var __webpack_exports__ = {};
|
|
322
|
+
__webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
|
|
323
|
+
webpackProvider: ()=>webpackProvider
|
|
678
324
|
});
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
var MultiStats = __webpack_require__("../../../node_modules/.pnpm/webpack@5.96.1/node_modules/webpack/lib/MultiStats.js");
|
|
683
|
-
var MultiStats_default = /*#__PURE__*/ __webpack_require__.n(MultiStats);
|
|
684
|
-
const external_node_path_namespaceObject = require("node:path");
|
|
685
|
-
// EXTERNAL MODULE: ./src/shared.ts
|
|
686
|
-
var shared = __webpack_require__("./src/shared.ts");
|
|
687
|
-
const getInspectOutputPath = (context, inspectOptions)=>{
|
|
688
|
-
if (inspectOptions.outputPath) {
|
|
689
|
-
if ((0, external_node_path_namespaceObject.isAbsolute)(inspectOptions.outputPath)) return inspectOptions.outputPath;
|
|
690
|
-
return (0, external_node_path_namespaceObject.join)(context.distPath, inspectOptions.outputPath);
|
|
691
|
-
}
|
|
325
|
+
var core_ = __webpack_require__("@rsbuild/core"), MultiStats = __webpack_require__("../../../node_modules/.pnpm/webpack@5.96.1/node_modules/webpack/lib/MultiStats.js"), MultiStats_default = __webpack_require__.n(MultiStats);
|
|
326
|
+
let external_node_path_namespaceObject = require("node:path"), getInspectOutputPath = (context, inspectOptions)=>{
|
|
327
|
+
if (inspectOptions.outputPath) return (0, external_node_path_namespaceObject.isAbsolute)(inspectOptions.outputPath) ? inspectOptions.outputPath : (0, external_node_path_namespaceObject.join)(context.distPath, inspectOptions.outputPath);
|
|
692
328
|
return (0, external_node_path_namespaceObject.join)(context.distPath, '.rsbuild');
|
|
693
329
|
};
|
|
694
|
-
async function inspectConfig({ context, pluginManager, rsbuildOptions, bundlerConfigs, inspectOptions = {} }) {
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
const webpackConfigs = bundlerConfigs || (await initConfigs({
|
|
330
|
+
async function inspectConfig({ helpers, context, pluginManager, rsbuildOptions, bundlerConfigs, inspectOptions = {} }) {
|
|
331
|
+
inspectOptions.mode ? process.env.NODE_ENV = inspectOptions.mode : !process.env.NODE_ENV && (process.env.NODE_ENV = 'development');
|
|
332
|
+
let webpackConfigs = bundlerConfigs || (await initConfigs({
|
|
698
333
|
context,
|
|
699
334
|
pluginManager,
|
|
700
|
-
rsbuildOptions
|
|
701
|
-
|
|
702
|
-
|
|
335
|
+
rsbuildOptions,
|
|
336
|
+
helpers
|
|
337
|
+
})).webpackConfigs, rawBundlerConfigs = webpackConfigs.map((config, index)=>({
|
|
703
338
|
name: config.name || String(index),
|
|
704
|
-
content:
|
|
705
|
-
}))
|
|
706
|
-
const { rsbuildConfig, rawRsbuildConfig, environmentConfigs, rawEnvironmentConfigs } = (0, shared /* getRsbuildInspectConfig */ .PD)({
|
|
339
|
+
content: helpers.stringifyConfig(config, inspectOptions.verbose)
|
|
340
|
+
})), { rsbuildConfig, rawRsbuildConfig, environmentConfigs, rawEnvironmentConfigs } = helpers.getRsbuildInspectConfig({
|
|
707
341
|
normalizedConfig: context.normalizedConfig,
|
|
708
342
|
inspectOptions,
|
|
709
343
|
pluginManager
|
|
710
|
-
});
|
|
711
|
-
|
|
712
|
-
if (inspectOptions.writeToDisk) await (0, shared /* outputInspectConfigFiles */ .SM)({
|
|
344
|
+
}), outputPath = getInspectOutputPath(context, inspectOptions);
|
|
345
|
+
return inspectOptions.writeToDisk && await helpers.outputInspectConfigFiles({
|
|
713
346
|
rawBundlerConfigs,
|
|
714
347
|
rawEnvironmentConfigs,
|
|
715
348
|
inspectOptions: {
|
|
@@ -717,8 +350,7 @@ async function inspectConfig({ context, pluginManager, rsbuildOptions, bundlerCo
|
|
|
717
350
|
outputPath
|
|
718
351
|
},
|
|
719
352
|
configType: 'webpack'
|
|
720
|
-
})
|
|
721
|
-
return {
|
|
353
|
+
}), {
|
|
722
354
|
rsbuildConfig: rawRsbuildConfig,
|
|
723
355
|
environmentConfigs: rawEnvironmentConfigs.map((r)=>r.content),
|
|
724
356
|
bundlerConfigs: rawBundlerConfigs.map((r)=>r.content),
|
|
@@ -729,20 +361,21 @@ async function inspectConfig({ context, pluginManager, rsbuildOptions, bundlerCo
|
|
|
729
361
|
}
|
|
730
362
|
};
|
|
731
363
|
}
|
|
732
|
-
|
|
364
|
+
let external_reduce_configs_namespaceObject = require("reduce-configs"), castArray = (arr)=>void 0 === arr ? [] : Array.isArray(arr) ? arr : [
|
|
365
|
+
arr
|
|
366
|
+
];
|
|
733
367
|
async function modifyWebpackChain(context, utils, chain) {
|
|
734
368
|
var _utils_environment_config_tools;
|
|
735
369
|
core_.logger.debug('modify webpack chain');
|
|
736
|
-
|
|
370
|
+
let [modifiedChain] = await context.hooks.modifyWebpackChain.callInEnvironment({
|
|
737
371
|
environment: utils.environment.name,
|
|
738
372
|
args: [
|
|
739
373
|
chain,
|
|
740
374
|
utils
|
|
741
375
|
]
|
|
742
376
|
});
|
|
743
|
-
if (null === (_utils_environment_config_tools = utils.environment.config.tools) || void 0 === _utils_environment_config_tools ? void 0 : _utils_environment_config_tools.webpackChain) for (
|
|
744
|
-
core_.logger.debug('modify webpack chain done');
|
|
745
|
-
return modifiedChain;
|
|
377
|
+
if (null === (_utils_environment_config_tools = utils.environment.config.tools) || void 0 === _utils_environment_config_tools ? void 0 : _utils_environment_config_tools.webpackChain) for (let item of castArray(utils.environment.config.tools.webpackChain))item(modifiedChain, utils);
|
|
378
|
+
return core_.logger.debug('modify webpack chain done'), modifiedChain;
|
|
746
379
|
}
|
|
747
380
|
async function modifyWebpackConfig(context, webpackConfig, utils) {
|
|
748
381
|
var _utils_environment_config_tools;
|
|
@@ -754,34 +387,28 @@ async function modifyWebpackConfig(context, webpackConfig, utils) {
|
|
|
754
387
|
utils
|
|
755
388
|
]
|
|
756
389
|
});
|
|
757
|
-
|
|
390
|
+
return (null === (_utils_environment_config_tools = utils.environment.config.tools) || void 0 === _utils_environment_config_tools ? void 0 : _utils_environment_config_tools.webpack) && (modifiedConfig = (0, external_reduce_configs_namespaceObject.reduceConfigsWithContext)({
|
|
758
391
|
initial: modifiedConfig,
|
|
759
392
|
config: utils.environment.config.tools.webpack,
|
|
760
393
|
ctx: utils,
|
|
761
394
|
mergeFn: utils.mergeConfig
|
|
762
|
-
});
|
|
763
|
-
core_.logger.debug('modify webpack config done');
|
|
764
|
-
return modifiedConfig;
|
|
395
|
+
})), core_.logger.debug('modify webpack config done'), modifiedConfig;
|
|
765
396
|
}
|
|
766
|
-
async function getChainUtils(target, environment) {
|
|
767
|
-
|
|
768
|
-
const nameMap = {
|
|
769
|
-
web: 'client',
|
|
770
|
-
node: 'server',
|
|
771
|
-
'web-worker': 'web-worker'
|
|
772
|
-
};
|
|
397
|
+
async function getChainUtils(target, environment, helpers) {
|
|
398
|
+
let { default: webpack } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "webpack"));
|
|
773
399
|
return {
|
|
774
|
-
...
|
|
775
|
-
name:
|
|
400
|
+
...helpers.getChainUtils(target, environment),
|
|
401
|
+
name: ({
|
|
402
|
+
web: 'client',
|
|
403
|
+
node: 'server',
|
|
404
|
+
'web-worker': 'web-worker'
|
|
405
|
+
})[target] || '',
|
|
776
406
|
webpack,
|
|
777
|
-
HtmlWebpackPlugin:
|
|
407
|
+
HtmlWebpackPlugin: helpers.getHTMLPlugin()
|
|
778
408
|
};
|
|
779
409
|
}
|
|
780
|
-
async function generateWebpackConfig({ target, context, environment }) {
|
|
781
|
-
|
|
782
|
-
const { default: webpack } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "webpack"));
|
|
783
|
-
const { BannerPlugin, DefinePlugin, IgnorePlugin, ProvidePlugin, HotModuleReplacementPlugin } = webpack;
|
|
784
|
-
const bundlerChain = await (0, shared /* modifyBundlerChain */ .EB)(context, {
|
|
410
|
+
async function generateWebpackConfig({ target, context, environment, helpers }) {
|
|
411
|
+
let chainUtils = await getChainUtils(target, context.environments[environment], helpers), { default: webpack } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "webpack")), { BannerPlugin, DefinePlugin, IgnorePlugin, ProvidePlugin, HotModuleReplacementPlugin } = webpack, bundlerChain = await helpers.modifyBundlerChain(context, {
|
|
785
412
|
...chainUtils,
|
|
786
413
|
bundler: {
|
|
787
414
|
BannerPlugin,
|
|
@@ -790,43 +417,36 @@ async function generateWebpackConfig({ target, context, environment }) {
|
|
|
790
417
|
ProvidePlugin,
|
|
791
418
|
HotModuleReplacementPlugin
|
|
792
419
|
}
|
|
793
|
-
});
|
|
794
|
-
|
|
795
|
-
let webpackConfig = (0, shared /* chainToConfig */ .iL)(chain);
|
|
796
|
-
const configUtils = await core_.__internalHelper.getConfigUtils(webpackConfig, chainUtils);
|
|
797
|
-
webpackConfig = await modifyWebpackConfig(context, webpackConfig, configUtils);
|
|
798
|
-
return webpackConfig;
|
|
420
|
+
}), chain = await modifyWebpackChain(context, chainUtils, bundlerChain), webpackConfig = helpers.chainToConfig(chain), configUtils = await helpers.getConfigUtils(webpackConfig, chainUtils);
|
|
421
|
+
return webpackConfig = await modifyWebpackConfig(context, webpackConfig, configUtils);
|
|
799
422
|
}
|
|
800
|
-
async function initConfigs({ context, pluginManager, rsbuildOptions }) {
|
|
801
|
-
|
|
423
|
+
async function initConfigs({ context, pluginManager, rsbuildOptions, helpers }) {
|
|
424
|
+
let normalizedConfig = await helpers.initRsbuildConfig({
|
|
802
425
|
context,
|
|
803
426
|
pluginManager
|
|
804
|
-
})
|
|
805
|
-
const webpackConfigs = await Promise.all(Object.entries(normalizedConfig.environments).map(([environment, config])=>generateWebpackConfig({
|
|
427
|
+
}), webpackConfigs = await Promise.all(Object.entries(normalizedConfig.environments).map(([environment, config])=>generateWebpackConfig({
|
|
806
428
|
target: config.output.target,
|
|
807
429
|
context,
|
|
808
|
-
environment
|
|
430
|
+
environment,
|
|
431
|
+
helpers
|
|
809
432
|
})));
|
|
810
|
-
// write Rsbuild config and webpack config to disk in debug mode
|
|
811
433
|
if ('verbose' === core_.logger.level) {
|
|
812
|
-
|
|
813
|
-
const inspectOptions = {
|
|
814
|
-
verbose: true,
|
|
815
|
-
writeToDisk: true
|
|
816
|
-
};
|
|
434
|
+
let inspect = ()=>{
|
|
817
435
|
inspectConfig({
|
|
818
436
|
context,
|
|
819
437
|
pluginManager,
|
|
820
|
-
inspectOptions
|
|
438
|
+
inspectOptions: {
|
|
439
|
+
verbose: !0,
|
|
440
|
+
writeToDisk: !0
|
|
441
|
+
},
|
|
821
442
|
rsbuildOptions,
|
|
822
|
-
bundlerConfigs: webpackConfigs
|
|
443
|
+
bundlerConfigs: webpackConfigs,
|
|
444
|
+
helpers
|
|
823
445
|
});
|
|
824
446
|
};
|
|
825
|
-
// run inspect later to avoid cleaned by cleanOutput plugin
|
|
826
447
|
context.hooks.onBeforeBuild.tap(({ isFirstCompile })=>{
|
|
827
|
-
|
|
828
|
-
});
|
|
829
|
-
context.hooks.onAfterStartDevServer.tap(inspect);
|
|
448
|
+
isFirstCompile && inspect();
|
|
449
|
+
}), context.hooks.onAfterStartDevServer.tap(inspect);
|
|
830
450
|
}
|
|
831
451
|
return {
|
|
832
452
|
webpackConfigs
|
|
@@ -835,86 +455,65 @@ async function initConfigs({ context, pluginManager, rsbuildOptions }) {
|
|
|
835
455
|
async function createCompiler_createCompiler(options) {
|
|
836
456
|
var _context_normalizedConfig;
|
|
837
457
|
core_.logger.debug('create compiler');
|
|
838
|
-
|
|
839
|
-
const { webpackConfigs } = await initConfigs(options);
|
|
458
|
+
let { helpers, context } = options, { webpackConfigs } = await initConfigs(options);
|
|
840
459
|
await context.hooks.onBeforeCreateCompiler.call({
|
|
841
460
|
bundlerConfigs: webpackConfigs,
|
|
842
461
|
environments: context.environments
|
|
843
462
|
});
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
const statsOptions = (0, shared /* getStatsOptions */ .g5)(compiler);
|
|
848
|
-
const statsJson = stats.toJson({
|
|
849
|
-
children: true,
|
|
463
|
+
let { default: webpack } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "webpack")), compiler = webpack(1 === webpackConfigs.length ? webpackConfigs[0] : webpackConfigs), done = (stats)=>{
|
|
464
|
+
let statsOptions = helpers.getStatsOptions(compiler), statsJson = stats.toJson({
|
|
465
|
+
children: !0,
|
|
850
466
|
...'string' == typeof statsOptions ? {
|
|
851
467
|
preset: statsOptions
|
|
852
468
|
} : {
|
|
853
469
|
preset: 'errors-warnings'
|
|
854
470
|
},
|
|
855
471
|
...'object' == typeof statsOptions ? statsOptions : {}
|
|
856
|
-
});
|
|
857
|
-
|
|
858
|
-
if ('error' === level) core_.logger.error(message);
|
|
859
|
-
if ('warning' === level) core_.logger.warn(message);
|
|
472
|
+
}), { message, level } = helpers.formatStats(statsJson, stats.hasErrors());
|
|
473
|
+
'error' === level && core_.logger.error(message), 'warning' === level && core_.logger.warn(message);
|
|
860
474
|
};
|
|
861
|
-
compiler.hooks.done.tap('rsbuild:done', (stats)=>{
|
|
475
|
+
return compiler.hooks.done.tap('rsbuild:done', (stats)=>{
|
|
862
476
|
done(stats);
|
|
863
|
-
})
|
|
864
|
-
if ((null === (_context_normalizedConfig = context.normalizedConfig) || void 0 === _context_normalizedConfig ? void 0 : _context_normalizedConfig.mode) === 'development') (0, shared /* registerDevHook */ .xn)({
|
|
477
|
+
}), (null === (_context_normalizedConfig = context.normalizedConfig) || void 0 === _context_normalizedConfig ? void 0 : _context_normalizedConfig.mode) === 'development' && helpers.registerDevHook({
|
|
865
478
|
compiler,
|
|
866
479
|
context,
|
|
867
480
|
bundlerConfigs: webpackConfigs,
|
|
868
481
|
MultiStatsCtor: MultiStats_default()
|
|
869
|
-
})
|
|
870
|
-
await context.hooks.onAfterCreateCompiler.call({
|
|
482
|
+
}), await context.hooks.onAfterCreateCompiler.call({
|
|
871
483
|
compiler,
|
|
872
484
|
environments: context.environments
|
|
873
|
-
})
|
|
874
|
-
core_.logger.debug('create compiler done');
|
|
875
|
-
return {
|
|
485
|
+
}), core_.logger.debug('create compiler done'), {
|
|
876
486
|
compiler,
|
|
877
487
|
webpackConfigs
|
|
878
488
|
};
|
|
879
489
|
}
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
let
|
|
883
|
-
let bundlerConfigs;
|
|
490
|
+
let build = async (initOptions, { watch, compiler: customCompiler } = {})=>{
|
|
491
|
+
let compiler, bundlerConfigs;
|
|
492
|
+
let { helpers, context } = initOptions;
|
|
884
493
|
if (customCompiler) compiler = customCompiler;
|
|
885
494
|
else {
|
|
886
|
-
|
|
887
|
-
compiler = result.compiler;
|
|
888
|
-
bundlerConfigs = result.webpackConfigs;
|
|
495
|
+
let result = await createCompiler_createCompiler(initOptions);
|
|
496
|
+
compiler = result.compiler, bundlerConfigs = result.webpackConfigs;
|
|
889
497
|
}
|
|
890
|
-
(
|
|
498
|
+
if (helpers.registerBuildHook({
|
|
891
499
|
context,
|
|
892
500
|
bundlerConfigs: bundlerConfigs,
|
|
893
501
|
compiler,
|
|
894
|
-
isWatch:
|
|
502
|
+
isWatch: !!watch,
|
|
895
503
|
MultiStatsCtor: MultiStats_default()
|
|
896
|
-
})
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
})
|
|
907
|
-
};
|
|
908
|
-
}
|
|
909
|
-
const { stats } = await new Promise((resolve, reject)=>{
|
|
504
|
+
}), watch) return compiler.watch({}, (err)=>{
|
|
505
|
+
err && core_.logger.error(err);
|
|
506
|
+
}), {
|
|
507
|
+
close: ()=>new Promise((resolve)=>{
|
|
508
|
+
compiler.close(()=>{
|
|
509
|
+
resolve();
|
|
510
|
+
});
|
|
511
|
+
})
|
|
512
|
+
};
|
|
513
|
+
let { stats } = await new Promise((resolve, reject)=>{
|
|
910
514
|
compiler.run((err, stats)=>{
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
else // When using run or watch, call close and wait for it to finish before calling run or watch again.
|
|
914
|
-
// Concurrent compilations will corrupt the output files.
|
|
915
|
-
compiler.close((closeErr)=>{
|
|
916
|
-
closeErr && core_.logger.error(closeErr);
|
|
917
|
-
resolve({
|
|
515
|
+
err ? reject(err) : (null == stats ? void 0 : stats.hasErrors()) ? reject(Error('Webpack build failed!')) : compiler.close((closeErr)=>{
|
|
516
|
+
closeErr && core_.logger.error(closeErr), resolve({
|
|
918
517
|
stats
|
|
919
518
|
});
|
|
920
519
|
});
|
|
@@ -922,165 +521,142 @@ const build = async (initOptions, { watch, compiler: customCompiler } = {})=>{
|
|
|
922
521
|
});
|
|
923
522
|
return {
|
|
924
523
|
stats,
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
524
|
+
close: ()=>new Promise((resolve)=>{
|
|
525
|
+
compiler.close(()=>{
|
|
526
|
+
resolve();
|
|
527
|
+
});
|
|
528
|
+
})
|
|
928
529
|
};
|
|
929
|
-
};
|
|
930
|
-
|
|
931
|
-
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
530
|
+
}, external_node_fs_namespaceObject = require("node:fs");
|
|
531
|
+
var external_node_fs_default = __webpack_require__.n(external_node_fs_namespaceObject);
|
|
932
532
|
async function applyTsConfigPathsPlugin({ chain, CHAIN_ID, mainFields, extensions, configFile }) {
|
|
933
|
-
|
|
533
|
+
let { TsconfigPathsPlugin } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "tsconfig-paths-webpack-plugin"));
|
|
934
534
|
chain.resolve.plugin(CHAIN_ID.RESOLVE_PLUGIN.TS_CONFIG_PATHS).use(TsconfigPathsPlugin, [
|
|
935
535
|
{
|
|
936
536
|
configFile,
|
|
937
537
|
extensions,
|
|
938
|
-
// https://github.com/dividab/tsconfig-paths-webpack-plugin/pull/106
|
|
939
538
|
mainFields: mainFields
|
|
940
539
|
}
|
|
941
540
|
]);
|
|
942
541
|
}
|
|
943
542
|
function isWebTarget(target) {
|
|
944
|
-
|
|
945
|
-
return targets.includes('web') || target.includes('web-worker');
|
|
543
|
+
return castArray(target).includes('web') || target.includes('web-worker');
|
|
946
544
|
}
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
if (isWebTarget(target)) return [
|
|
545
|
+
let getMainFields = (chain, target)=>{
|
|
546
|
+
let mainFields = chain.resolve.mainFields.values();
|
|
547
|
+
return mainFields.length ? mainFields : isWebTarget(target) ? [
|
|
951
548
|
'browser',
|
|
952
549
|
'module',
|
|
953
550
|
'main'
|
|
954
|
-
]
|
|
955
|
-
return [
|
|
551
|
+
] : [
|
|
956
552
|
'module',
|
|
957
553
|
'main'
|
|
958
554
|
];
|
|
959
|
-
}
|
|
960
|
-
/**
|
|
961
|
-
* Handling differences between Webpack and Rspack
|
|
962
|
-
*/ const pluginAdaptor = ()=>({
|
|
555
|
+
}, pluginAdaptor = (helpers)=>({
|
|
963
556
|
name: 'rsbuild-webpack:adaptor',
|
|
964
557
|
setup (api) {
|
|
965
558
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, target })=>{
|
|
966
|
-
|
|
967
|
-
|
|
559
|
+
let { config, tsconfigPath } = environment;
|
|
560
|
+
tsconfigPath && 'prefer-tsconfig' === config.source.aliasStrategy && await applyTsConfigPathsPlugin({
|
|
968
561
|
chain,
|
|
969
562
|
CHAIN_ID,
|
|
970
563
|
configFile: tsconfigPath,
|
|
971
564
|
mainFields: getMainFields(chain, target),
|
|
972
565
|
extensions: chain.resolve.extensions.values()
|
|
973
566
|
});
|
|
974
|
-
|
|
975
|
-
const progress = config.dev.progressBar ?? true;
|
|
567
|
+
let progress = config.dev.progressBar ?? !0;
|
|
976
568
|
if (progress) {
|
|
977
|
-
|
|
569
|
+
let { ProgressPlugin } = await Promise.all([
|
|
978
570
|
__webpack_require__.e("997"),
|
|
979
571
|
__webpack_require__.e("15")
|
|
980
572
|
]).then(__webpack_require__.bind(__webpack_require__, "./src/progress/ProgressPlugin.ts"));
|
|
981
573
|
chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(ProgressPlugin, [
|
|
982
574
|
{
|
|
983
575
|
id: environment.name,
|
|
984
|
-
|
|
576
|
+
prettyTime: helpers.prettyTime,
|
|
577
|
+
...!0 === progress ? {} : progress
|
|
985
578
|
}
|
|
986
579
|
]);
|
|
987
580
|
}
|
|
988
|
-
|
|
581
|
+
let { copy } = config.output;
|
|
989
582
|
if (copy) {
|
|
990
|
-
|
|
991
|
-
const options = Array.isArray(copy) ? {
|
|
583
|
+
let { default: CopyPlugin } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "copy-webpack-plugin")), options = Array.isArray(copy) ? {
|
|
992
584
|
patterns: copy
|
|
993
585
|
} : copy;
|
|
994
586
|
chain.plugin(CHAIN_ID.PLUGIN.COPY).use(CopyPlugin, [
|
|
995
|
-
// @ts-expect-error to type mismatch
|
|
996
587
|
options
|
|
997
588
|
]);
|
|
998
589
|
}
|
|
999
|
-
})
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
if (copyPlugin) {
|
|
1004
|
-
// If the pattern.context directory not exists, we should remove CopyPlugin.
|
|
1005
|
-
// Otherwise the CopyPlugin will cause the webpack to re-compile.
|
|
1006
|
-
const isContextNotExists = copyPlugin.patterns.every((pattern)=>'string' != typeof pattern && pattern.context && !external_node_fs_default().existsSync(pattern.context));
|
|
1007
|
-
if (isContextNotExists) {
|
|
1008
|
-
var _config_plugins1;
|
|
1009
|
-
config.plugins = null === (_config_plugins1 = config.plugins) || void 0 === _config_plugins1 ? void 0 : _config_plugins1.filter((item)=>(null == item ? void 0 : item.constructor.name) !== 'CopyPlugin');
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
590
|
+
}), api.modifyWebpackConfig(async (config)=>{
|
|
591
|
+
var _config_plugins, _config_plugins1;
|
|
592
|
+
let copyPlugin = null === (_config_plugins = config.plugins) || void 0 === _config_plugins ? void 0 : _config_plugins.find((item)=>(null == item ? void 0 : item.constructor.name) === 'CopyPlugin');
|
|
593
|
+
copyPlugin && copyPlugin.patterns.every((pattern)=>'string' != typeof pattern && pattern.context && !external_node_fs_default().existsSync(pattern.context)) && (config.plugins = null === (_config_plugins1 = config.plugins) || void 0 === _config_plugins1 ? void 0 : _config_plugins1.filter((item)=>(null == item ? void 0 : item.constructor.name) !== 'CopyPlugin'));
|
|
1012
594
|
});
|
|
1013
595
|
}
|
|
1014
|
-
})
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
const createCompiler = async ()=>{
|
|
1019
|
-
const result = await createCompiler_createCompiler({
|
|
596
|
+
}), webpackProvider = async ({ context, pluginManager, rsbuildOptions, helpers })=>{
|
|
597
|
+
let { default: cssExtractPlugin } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "mini-css-extract-plugin"));
|
|
598
|
+
helpers.setCssExtractPlugin(cssExtractPlugin);
|
|
599
|
+
let createCompiler = async ()=>(await createCompiler_createCompiler({
|
|
1020
600
|
context,
|
|
1021
601
|
pluginManager,
|
|
1022
|
-
rsbuildOptions
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
]);
|
|
1029
|
-
return {
|
|
602
|
+
rsbuildOptions,
|
|
603
|
+
helpers
|
|
604
|
+
})).compiler;
|
|
605
|
+
return pluginManager.addPlugins([
|
|
606
|
+
pluginAdaptor(helpers)
|
|
607
|
+
]), {
|
|
1030
608
|
bundler: 'webpack',
|
|
1031
609
|
createCompiler,
|
|
1032
610
|
async initConfigs () {
|
|
1033
|
-
|
|
611
|
+
let { webpackConfigs } = await initConfigs({
|
|
1034
612
|
context,
|
|
1035
613
|
pluginManager,
|
|
1036
|
-
rsbuildOptions
|
|
614
|
+
rsbuildOptions,
|
|
615
|
+
helpers
|
|
1037
616
|
});
|
|
1038
617
|
return webpackConfigs;
|
|
1039
618
|
},
|
|
1040
619
|
async createDevServer (options) {
|
|
1041
|
-
|
|
620
|
+
let config = await helpers.initRsbuildConfig({
|
|
1042
621
|
context,
|
|
1043
622
|
pluginManager
|
|
1044
623
|
});
|
|
1045
|
-
return
|
|
624
|
+
return helpers.createDevServer({
|
|
1046
625
|
context,
|
|
1047
626
|
pluginManager,
|
|
1048
627
|
rsbuildOptions
|
|
1049
628
|
}, createCompiler, config, options);
|
|
1050
629
|
},
|
|
1051
630
|
async startDevServer (options) {
|
|
1052
|
-
|
|
631
|
+
let config = await helpers.initRsbuildConfig({
|
|
1053
632
|
context,
|
|
1054
633
|
pluginManager
|
|
1055
634
|
});
|
|
1056
|
-
|
|
635
|
+
return (await helpers.createDevServer({
|
|
1057
636
|
context,
|
|
1058
637
|
pluginManager,
|
|
1059
638
|
rsbuildOptions
|
|
1060
|
-
}, createCompiler, config, options);
|
|
1061
|
-
return server.listen();
|
|
639
|
+
}, createCompiler, config, options)).listen();
|
|
1062
640
|
},
|
|
1063
|
-
async
|
|
1064
|
-
return build({
|
|
641
|
+
build: async (options)=>build({
|
|
1065
642
|
context,
|
|
1066
643
|
pluginManager,
|
|
1067
|
-
rsbuildOptions
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
async
|
|
1071
|
-
return await inspectConfig({
|
|
644
|
+
rsbuildOptions,
|
|
645
|
+
helpers
|
|
646
|
+
}, options),
|
|
647
|
+
inspectConfig: async (inspectOptions)=>await inspectConfig({
|
|
1072
648
|
context,
|
|
1073
649
|
pluginManager,
|
|
1074
650
|
rsbuildOptions,
|
|
1075
|
-
inspectOptions
|
|
1076
|
-
|
|
1077
|
-
|
|
651
|
+
inspectOptions,
|
|
652
|
+
helpers
|
|
653
|
+
})
|
|
1078
654
|
};
|
|
1079
655
|
};
|
|
1080
656
|
var __webpack_export_target__ = exports;
|
|
1081
657
|
for(var i in __webpack_exports__)__webpack_export_target__[i] = __webpack_exports__[i];
|
|
1082
|
-
|
|
1083
|
-
value:
|
|
658
|
+
__webpack_exports__.__esModule && Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
659
|
+
value: !0
|
|
1084
660
|
});
|
|
1085
661
|
|
|
1086
662
|
// Annotate the CommonJS export names for ESM import in node:
|