@rsbuild/webpack 1.6.0 → 1.6.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/{0~0.js → 0~999.js} +266 -52
- package/dist/161.js +294 -0
- package/dist/1~0.cjs +61 -46
- package/dist/{1~363.cjs → 1~56.cjs} +15 -14
- package/dist/index.cjs +17 -39
- package/dist/index.js +1 -344
- package/dist/rslib-runtime.js +25 -0
- package/package.json +6 -6
- package/dist/0~502.js +0 -204
package/dist/1~0.cjs
CHANGED
|
@@ -83,7 +83,7 @@ exports.ids = [
|
|
|
83
83
|
};
|
|
84
84
|
Object.defineProperty(module, 'exports', {
|
|
85
85
|
enumerable: !0,
|
|
86
|
-
get: function() {
|
|
86
|
+
get: function assembleStyles() {
|
|
87
87
|
let codes = new Map(), styles = {
|
|
88
88
|
modifier: {
|
|
89
89
|
reset: [
|
|
@@ -416,6 +416,9 @@ exports.ids = [
|
|
|
416
416
|
value: labels
|
|
417
417
|
});
|
|
418
418
|
}
|
|
419
|
+
function comparativeDistance(x, y) {
|
|
420
|
+
return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
|
|
421
|
+
}
|
|
419
422
|
convert.rgb.hsl = function(rgb) {
|
|
420
423
|
let h, r = rgb[0] / 255, g = rgb[1] / 255, b = rgb[2] / 255, min = Math.min(r, g, b), max = Math.max(r, g, b), delta = max - min;
|
|
421
424
|
max === min ? h = 0 : r === max ? h = (g - b) / delta : g === max ? h = 2 + (b - r) / delta : b === max && (h = 4 + (r - g) / delta), (h = Math.min(60 * h, 360)) < 0 && (h += 360);
|
|
@@ -454,7 +457,7 @@ exports.ids = [
|
|
|
454
457
|
if (reversed) return reversed;
|
|
455
458
|
let currentClosestDistance = 1 / 0;
|
|
456
459
|
for (let keyword of Object.keys(cssKeywords)){
|
|
457
|
-
let
|
|
460
|
+
let distance = comparativeDistance(rgb, cssKeywords[keyword]);
|
|
458
461
|
distance < currentClosestDistance && (currentClosestDistance = distance, currentClosestKeyword = keyword);
|
|
459
462
|
}
|
|
460
463
|
return currentClosestKeyword;
|
|
@@ -818,6 +821,24 @@ exports.ids = [
|
|
|
818
821
|
},
|
|
819
822
|
"../../../node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
|
|
820
823
|
let conversions = __webpack_require__("../../../node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/conversions.js"), route = __webpack_require__("../../../node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/route.js"), convert = {};
|
|
824
|
+
function wrapRaw(fn) {
|
|
825
|
+
let wrappedFn = function(...args) {
|
|
826
|
+
let arg0 = args[0];
|
|
827
|
+
return null == arg0 ? arg0 : (arg0.length > 1 && (args = arg0), fn(args));
|
|
828
|
+
};
|
|
829
|
+
return 'conversion' in fn && (wrappedFn.conversion = fn.conversion), wrappedFn;
|
|
830
|
+
}
|
|
831
|
+
function wrapRounded(fn) {
|
|
832
|
+
let wrappedFn = function(...args) {
|
|
833
|
+
let arg0 = args[0];
|
|
834
|
+
if (null == arg0) return arg0;
|
|
835
|
+
arg0.length > 1 && (args = arg0);
|
|
836
|
+
let result = fn(args);
|
|
837
|
+
if ('object' == typeof result) for(let len = result.length, i = 0; i < len; i++)result[i] = Math.round(result[i]);
|
|
838
|
+
return result;
|
|
839
|
+
};
|
|
840
|
+
return 'conversion' in fn && (wrappedFn.conversion = fn.conversion), wrappedFn;
|
|
841
|
+
}
|
|
821
842
|
Object.keys(conversions).forEach((fromModel)=>{
|
|
822
843
|
convert[fromModel] = {}, Object.defineProperty(convert[fromModel], 'channels', {
|
|
823
844
|
value: conversions[fromModel].channels
|
|
@@ -826,58 +847,52 @@ exports.ids = [
|
|
|
826
847
|
});
|
|
827
848
|
let routes = route(fromModel);
|
|
828
849
|
Object.keys(routes).forEach((toModel)=>{
|
|
829
|
-
let
|
|
830
|
-
convert[fromModel][toModel] = (
|
|
831
|
-
let arg0 = args[0];
|
|
832
|
-
if (null == arg0) return arg0;
|
|
833
|
-
arg0.length > 1 && (args = arg0);
|
|
834
|
-
let result = fn(args);
|
|
835
|
-
if ('object' == typeof result) for(let len = result.length, i = 0; i < len; i++)result[i] = Math.round(result[i]);
|
|
836
|
-
return result;
|
|
837
|
-
}, 'conversion' in fn && (wrappedFn.conversion = fn.conversion), wrappedFn), convert[fromModel][toModel].raw = (wrappedFn1 = function(...args) {
|
|
838
|
-
let arg0 = args[0];
|
|
839
|
-
return null == arg0 ? arg0 : (arg0.length > 1 && (args = arg0), fn(args));
|
|
840
|
-
}, 'conversion' in fn && (wrappedFn1.conversion = fn.conversion), wrappedFn1);
|
|
850
|
+
let fn = routes[toModel];
|
|
851
|
+
convert[fromModel][toModel] = wrapRounded(fn), convert[fromModel][toModel].raw = wrapRaw(fn);
|
|
841
852
|
});
|
|
842
853
|
}), module.exports = convert;
|
|
843
854
|
},
|
|
844
855
|
"../../../node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/route.js": function(module, __unused_webpack_exports, __webpack_require__) {
|
|
845
856
|
let conversions = __webpack_require__("../../../node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/conversions.js");
|
|
846
|
-
|
|
847
|
-
let graph =
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
}
|
|
857
|
+
function buildGraph() {
|
|
858
|
+
let graph = {}, models = Object.keys(conversions);
|
|
859
|
+
for(let len = models.length, i = 0; i < len; i++)graph[models[i]] = {
|
|
860
|
+
distance: -1,
|
|
861
|
+
parent: null
|
|
862
|
+
};
|
|
863
|
+
return graph;
|
|
864
|
+
}
|
|
865
|
+
function deriveBFS(fromModel) {
|
|
866
|
+
let graph = buildGraph(), queue = [
|
|
867
|
+
fromModel
|
|
868
|
+
];
|
|
869
|
+
for(graph[fromModel].distance = 0; queue.length;){
|
|
870
|
+
let current = queue.pop(), adjacents = Object.keys(conversions[current]);
|
|
871
|
+
for(let len = adjacents.length, i = 0; i < len; i++){
|
|
872
|
+
let adjacent = adjacents[i], node = graph[adjacent];
|
|
873
|
+
-1 === node.distance && (node.distance = graph[current].distance + 1, node.parent = current, queue.unshift(adjacent));
|
|
864
874
|
}
|
|
865
|
-
|
|
866
|
-
|
|
875
|
+
}
|
|
876
|
+
return graph;
|
|
877
|
+
}
|
|
878
|
+
function link(from, to) {
|
|
879
|
+
return function(args) {
|
|
880
|
+
return to(from(args));
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
function wrapConversion(toModel, graph) {
|
|
884
|
+
let path = [
|
|
885
|
+
graph[toModel].parent,
|
|
886
|
+
toModel
|
|
887
|
+
], fn = conversions[graph[toModel].parent][toModel], cur = graph[toModel].parent;
|
|
888
|
+
for(; graph[cur].parent;)path.unshift(graph[cur].parent), fn = link(conversions[graph[cur].parent][cur], fn), cur = graph[cur].parent;
|
|
889
|
+
return fn.conversion = path, fn;
|
|
890
|
+
}
|
|
891
|
+
module.exports = function(fromModel) {
|
|
892
|
+
let graph = deriveBFS(fromModel), conversion = {}, models = Object.keys(graph);
|
|
867
893
|
for(let len = models.length, i = 0; i < len; i++){
|
|
868
894
|
let toModel = models[i];
|
|
869
|
-
null !== graph[toModel].parent && (conversion[toModel] =
|
|
870
|
-
let path = [
|
|
871
|
-
graph[toModel].parent,
|
|
872
|
-
toModel
|
|
873
|
-
], fn = conversions[graph[toModel].parent][toModel], cur = graph[toModel].parent;
|
|
874
|
-
for(; graph[cur].parent;)path.unshift(graph[cur].parent), fn = function(from, to) {
|
|
875
|
-
return function(args) {
|
|
876
|
-
return to(from(args));
|
|
877
|
-
};
|
|
878
|
-
}(conversions[graph[cur].parent][cur], fn), cur = graph[cur].parent;
|
|
879
|
-
return fn.conversion = path, fn;
|
|
880
|
-
}(toModel, graph));
|
|
895
|
+
null !== graph[toModel].parent && (conversion[toModel] = wrapConversion(toModel, graph));
|
|
881
896
|
}
|
|
882
897
|
return conversion;
|
|
883
898
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const __rslib_import_meta_url__ = 'undefined' == typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
3
3
|
exports.ids = [
|
|
4
|
-
"
|
|
4
|
+
"56"
|
|
5
5
|
], exports.modules = {
|
|
6
6
|
"./src/progress/ProgressPlugin.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
7
7
|
__webpack_require__.d(__webpack_exports__, {
|
|
8
8
|
ProgressPlugin: ()=>ProgressPlugin
|
|
9
9
|
});
|
|
10
|
-
var core_ = __webpack_require__("@rsbuild/core"), external_picocolors_ = __webpack_require__("picocolors"), external_picocolors_default = __webpack_require__.n(external_picocolors_), external_webpack_ = __webpack_require__("webpack
|
|
10
|
+
var core_ = __webpack_require__("@rsbuild/core"), external_picocolors_ = __webpack_require__("picocolors"), external_picocolors_default = __webpack_require__.n(external_picocolors_), external_webpack_ = __webpack_require__("webpack"), external_webpack_default = __webpack_require__.n(external_webpack_), cli_truncate = __webpack_require__("../../../node_modules/.pnpm/cli-truncate@2.1.0/node_modules/cli-truncate/index.js"), cli_truncate_default = __webpack_require__.n(cli_truncate);
|
|
11
11
|
let clamp = (x, min, max)=>Math.min(max, Math.max(min, x)), defaultOption = {
|
|
12
12
|
total: 100,
|
|
13
13
|
current: 0,
|
|
@@ -127,6 +127,18 @@ exports.ids = [
|
|
|
127
127
|
this.log.clear(), this.log.done();
|
|
128
128
|
}
|
|
129
129
|
}();
|
|
130
|
+
function createNonTTYLogger() {
|
|
131
|
+
let prevPercentage = 0;
|
|
132
|
+
return {
|
|
133
|
+
log: ({ id, done, current, hasErrors, compileTime })=>{
|
|
134
|
+
let suffix = external_picocolors_default().gray(`(${id})`);
|
|
135
|
+
if (done) {
|
|
136
|
+
if (100 === prevPercentage) return;
|
|
137
|
+
prevPercentage = 100, hasErrors ? core_.logger.error(`build failed in ${compileTime} ${suffix}`) : core_.logger.ready(`built in ${compileTime} ${suffix}`);
|
|
138
|
+
} else current - prevPercentage > 10 && (prevPercentage = current, core_.logger.info(`build progress: ${current.toFixed(0)}% ${suffix}`));
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
130
142
|
class ProgressPlugin extends external_webpack_default().ProgressPlugin {
|
|
131
143
|
name = 'ProgressPlugin';
|
|
132
144
|
id;
|
|
@@ -134,18 +146,7 @@ exports.ids = [
|
|
|
134
146
|
compileTime = null;
|
|
135
147
|
prettyTime;
|
|
136
148
|
constructor(options){
|
|
137
|
-
const { id = 'Rsbuild' } = options, nonTTYLogger =
|
|
138
|
-
let prevPercentage = 0;
|
|
139
|
-
return {
|
|
140
|
-
log: ({ id, done, current, hasErrors, compileTime })=>{
|
|
141
|
-
let suffix = external_picocolors_default().gray(`(${id})`);
|
|
142
|
-
if (done) {
|
|
143
|
-
if (100 === prevPercentage) return;
|
|
144
|
-
prevPercentage = 100, hasErrors ? core_.logger.error(`built failed in ${compileTime} ${suffix}`) : core_.logger.ready(`built in ${compileTime} ${suffix}`);
|
|
145
|
-
} else current - prevPercentage > 10 && (prevPercentage = current, core_.logger.info(`build progress: ${current.toFixed(0)}% ${suffix}`));
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
}(), friendlyPercentage = (()=>{
|
|
149
|
+
const { id = 'Rsbuild' } = options, nonTTYLogger = createNonTTYLogger(), friendlyPercentage = (()=>{
|
|
149
150
|
let prevPercentage = 0;
|
|
150
151
|
return (percentage)=>{
|
|
151
152
|
if (0 === percentage || 1 === percentage) return prevPercentage = 0, percentage;
|
package/dist/index.cjs
CHANGED
|
@@ -13,33 +13,8 @@ var __webpack_modules__ = {
|
|
|
13
13
|
stream: function(module) {
|
|
14
14
|
module.exports = require("stream");
|
|
15
15
|
},
|
|
16
|
-
|
|
16
|
+
webpack: function(module) {
|
|
17
17
|
module.exports = require("webpack");
|
|
18
|
-
},
|
|
19
|
-
"copy-webpack-plugin": function(module) {
|
|
20
|
-
module.exports = import("copy-webpack-plugin").then(function(module) {
|
|
21
|
-
return module;
|
|
22
|
-
});
|
|
23
|
-
},
|
|
24
|
-
"html-webpack-plugin": function(module) {
|
|
25
|
-
module.exports = import("html-webpack-plugin").then(function(module) {
|
|
26
|
-
return module;
|
|
27
|
-
});
|
|
28
|
-
},
|
|
29
|
-
"mini-css-extract-plugin": function(module) {
|
|
30
|
-
module.exports = import("mini-css-extract-plugin").then(function(module) {
|
|
31
|
-
return module;
|
|
32
|
-
});
|
|
33
|
-
},
|
|
34
|
-
"tsconfig-paths-webpack-plugin": function(module) {
|
|
35
|
-
module.exports = import("tsconfig-paths-webpack-plugin").then(function(module) {
|
|
36
|
-
return module;
|
|
37
|
-
});
|
|
38
|
-
},
|
|
39
|
-
"webpack?5a4d": function(module) {
|
|
40
|
-
module.exports = import("webpack").then(function(module) {
|
|
41
|
-
return module;
|
|
42
|
-
});
|
|
43
18
|
}
|
|
44
19
|
}, __webpack_module_cache__ = {};
|
|
45
20
|
function __webpack_require__(moduleId) {
|
|
@@ -120,10 +95,10 @@ for(var __webpack_i__ in (()=>{
|
|
|
120
95
|
mergeFn: utils.mergeConfig
|
|
121
96
|
})), core_.logger.debug('modify webpack config done'), modifiedConfig;
|
|
122
97
|
}
|
|
123
|
-
async function getChainUtils(target, environment, helpers) {
|
|
124
|
-
let { default: webpack } = await
|
|
98
|
+
async function getChainUtils(target, environment, environments, helpers) {
|
|
99
|
+
let { default: webpack } = await import("webpack");
|
|
125
100
|
return {
|
|
126
|
-
...helpers.getChainUtils(target, environment),
|
|
101
|
+
...helpers.getChainUtils(target, environment, environments),
|
|
127
102
|
name: ({
|
|
128
103
|
web: 'client',
|
|
129
104
|
node: 'server',
|
|
@@ -134,7 +109,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
134
109
|
};
|
|
135
110
|
}
|
|
136
111
|
async function generateWebpackConfig({ target, context, environment, helpers }) {
|
|
137
|
-
let chainUtils = await getChainUtils(target, context.environments[environment], helpers), { default: webpack } = await
|
|
112
|
+
let chainUtils = await getChainUtils(target, context.environments[environment], context.environments, helpers), { default: webpack } = await import("webpack"), { BannerPlugin, DefinePlugin, IgnorePlugin, ProvidePlugin, SourceMapDevToolPlugin, HotModuleReplacementPlugin } = webpack, bundlerChain = await helpers.modifyBundlerChain(context, {
|
|
138
113
|
...chainUtils,
|
|
139
114
|
bundler: {
|
|
140
115
|
BannerPlugin,
|
|
@@ -186,7 +161,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
186
161
|
bundlerConfigs: webpackConfigs,
|
|
187
162
|
environments: context.environments
|
|
188
163
|
});
|
|
189
|
-
let { default: webpack } = await
|
|
164
|
+
let { default: webpack } = await import("webpack"), compiler = webpack(1 === webpackConfigs.length ? webpackConfigs[0] : webpackConfigs);
|
|
190
165
|
return compiler.hooks.run.tap(HOOK_NAME, ()=>{
|
|
191
166
|
context.buildState.status = 'building';
|
|
192
167
|
}), compiler.hooks.watchRun.tap(HOOK_NAME, ()=>{
|
|
@@ -213,7 +188,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
213
188
|
}
|
|
214
189
|
let build = async (initOptions, { watch, compiler: customCompiler } = {})=>{
|
|
215
190
|
let compiler, bundlerConfigs, { helpers, context } = initOptions;
|
|
216
|
-
if (customCompiler) compiler = customCompiler;
|
|
191
|
+
if (customCompiler) compiler = customCompiler, bundlerConfigs = customCompiler.options;
|
|
217
192
|
else {
|
|
218
193
|
let result = await createCompiler_createCompiler(initOptions);
|
|
219
194
|
compiler = result.compiler, bundlerConfigs = result.webpackConfigs;
|
|
@@ -249,7 +224,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
249
224
|
}, external_node_fs_namespaceObject = require("node:fs");
|
|
250
225
|
var external_node_fs_default = __webpack_require__.n(external_node_fs_namespaceObject);
|
|
251
226
|
async function applyTsConfigPathsPlugin({ chain, CHAIN_ID, mainFields, extensions, configFile }) {
|
|
252
|
-
let { TsconfigPathsPlugin } = await
|
|
227
|
+
let { TsconfigPathsPlugin } = await import("tsconfig-paths-webpack-plugin");
|
|
253
228
|
chain.resolve.plugin(CHAIN_ID.RESOLVE_PLUGIN.TS_CONFIG_PATHS).use(TsconfigPathsPlugin, [
|
|
254
229
|
{
|
|
255
230
|
configFile,
|
|
@@ -258,10 +233,13 @@ for(var __webpack_i__ in (()=>{
|
|
|
258
233
|
}
|
|
259
234
|
]);
|
|
260
235
|
}
|
|
236
|
+
function isWebTarget(target) {
|
|
237
|
+
return castArray(target).includes('web') || target.includes('web-worker');
|
|
238
|
+
}
|
|
261
239
|
let webpackProvider = async ({ context, pluginManager, rsbuildOptions, helpers })=>{
|
|
262
|
-
let helpers1, { default: cssExtractPlugin } = await
|
|
240
|
+
let helpers1, { default: cssExtractPlugin } = await import("mini-css-extract-plugin");
|
|
263
241
|
if (helpers.setCssExtractPlugin(cssExtractPlugin), helpers.setHTMLPlugin) {
|
|
264
|
-
let { default: htmlPlugin } = await
|
|
242
|
+
let { default: htmlPlugin } = await import("html-webpack-plugin");
|
|
265
243
|
helpers.setHTMLPlugin(htmlPlugin);
|
|
266
244
|
}
|
|
267
245
|
let createCompiler = async ()=>(await createCompiler_createCompiler({
|
|
@@ -275,13 +253,13 @@ for(var __webpack_i__ in (()=>{
|
|
|
275
253
|
name: 'rsbuild-webpack:adaptor',
|
|
276
254
|
setup (api) {
|
|
277
255
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, environment, target })=>{
|
|
278
|
-
var chain1, target1
|
|
256
|
+
var chain1, target1;
|
|
279
257
|
let mainFields, { config, tsconfigPath } = environment, aliasStrategy = config.source.aliasStrategy ?? config.resolve.aliasStrategy;
|
|
280
258
|
tsconfigPath && 'prefer-tsconfig' === aliasStrategy && await applyTsConfigPathsPlugin({
|
|
281
259
|
chain,
|
|
282
260
|
CHAIN_ID,
|
|
283
261
|
configFile: tsconfigPath,
|
|
284
|
-
mainFields: (chain1 = chain, target1 = target, (mainFields = chain1.resolve.mainFields.values()).length ? mainFields :
|
|
262
|
+
mainFields: (chain1 = chain, target1 = target, (mainFields = chain1.resolve.mainFields.values()).length ? mainFields : isWebTarget(target1) ? [
|
|
285
263
|
'browser',
|
|
286
264
|
'module',
|
|
287
265
|
'main'
|
|
@@ -295,7 +273,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
295
273
|
if (progressBar) {
|
|
296
274
|
let { ProgressPlugin } = await Promise.all([
|
|
297
275
|
__webpack_require__.e("0"),
|
|
298
|
-
__webpack_require__.e("
|
|
276
|
+
__webpack_require__.e("56")
|
|
299
277
|
]).then(__webpack_require__.bind(__webpack_require__, "./src/progress/ProgressPlugin.ts"));
|
|
300
278
|
chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(ProgressPlugin, [
|
|
301
279
|
{
|
|
@@ -307,7 +285,7 @@ for(var __webpack_i__ in (()=>{
|
|
|
307
285
|
}
|
|
308
286
|
let { copy } = config.output;
|
|
309
287
|
if (copy) {
|
|
310
|
-
let { default: CopyPlugin } = await
|
|
288
|
+
let { default: CopyPlugin } = await import("copy-webpack-plugin"), options = Array.isArray(copy) ? {
|
|
311
289
|
patterns: copy
|
|
312
290
|
} : copy;
|
|
313
291
|
chain.plugin(CHAIN_ID.PLUGIN.COPY).use(CopyPlugin, [
|