@lynx-js/rspeedy-canary 0.13.0-canary-20260105-ec1caf1a → 0.13.0-canary-20260105-03ea61ec

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.
Files changed (66) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/{0~vendors-node_modules_pnpm_ipaddr_js_2_3_0_node_modules_ipaddr_js_lib_ipaddr_js.js → 0~node_modules_pnpm_ipaddr_js_2_3_0_node_modules_ipaddr_js_lib_ipaddr_js.js} +3 -6
  3. package/dist/0~src_cli_exit_ts.js +98 -108
  4. package/dist/0~src_config_output_dist-path_ts.js +2 -0
  5. package/dist/0~src_config_validate_ts.js +41917 -41925
  6. package/dist/0~src_plugins_api_plugin_ts.js +21 -31
  7. package/dist/0~src_plugins_chunkLoading_plugin_ts.js +10 -20
  8. package/dist/0~src_plugins_dev_plugin_ts.js +168 -179
  9. package/dist/0~src_plugins_emitOnErrors_plugin_ts.js +10 -20
  10. package/dist/0~src_plugins_index_ts.js +63 -51
  11. package/dist/0~src_plugins_inspect_plugin_ts.js +434 -39
  12. package/dist/0~src_plugins_minify_plugin_ts.js +66 -76
  13. package/dist/0~src_plugins_optimization_plugin_ts.js +14 -24
  14. package/dist/0~src_plugins_output_plugin_ts.js +29 -45
  15. package/dist/0~src_plugins_resolve_plugin_ts.js +10 -20
  16. package/dist/0~src_plugins_rsdoctor_plugin_ts.js +39 -49
  17. package/dist/0~src_plugins_sourcemap_plugin_ts.js +86 -96
  18. package/dist/0~src_plugins_swc_plugin_ts.js +20 -38
  19. package/dist/0~src_plugins_target_plugin_ts.js +21 -39
  20. package/dist/0~src_utils_getESVersionTarget_ts.js +4 -0
  21. package/dist/1~node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js +1422 -0
  22. package/dist/{1~vendors-node_modules_pnpm_commander_13_1_0_node_modules_commander_esm_mjs.js → 1~node_modules_pnpm_commander_13_1_0_node_modules_commander_esm_mjs.js} +17 -24
  23. package/dist/{1~vendors-node_modules_pnpm_ipaddr_js_2_3_0_node_modules_ipaddr_js_lib_ipaddr_js.js → 1~node_modules_pnpm_ipaddr_js_2_3_0_node_modules_ipaddr_js_lib_ipaddr_js.js} +3 -6
  24. package/dist/1~src_cli_build_ts.js +35 -424
  25. package/dist/1~src_cli_commands_ts.js +56 -74
  26. package/dist/1~src_cli_dev_ts.js +29 -410
  27. package/dist/1~src_cli_init_ts-src_create-rspeedy_ts.js +318 -0
  28. package/dist/1~src_cli_inspect_ts.js +18 -356
  29. package/dist/1~src_cli_preview_ts.js +23 -359
  30. package/dist/1~src_cli_watch_ts.js +39 -0
  31. package/dist/1~src_config_output_dist-path_ts.js +2 -0
  32. package/dist/1~src_config_validate_ts.js +41917 -41925
  33. package/dist/1~src_plugins_api_plugin_ts.js +22 -31
  34. package/dist/1~src_plugins_chunkLoading_plugin_ts.js +10 -20
  35. package/dist/1~src_plugins_dev_plugin_ts.js +170 -179
  36. package/dist/1~src_plugins_emitOnErrors_plugin_ts.js +10 -20
  37. package/dist/1~src_plugins_index_ts.js +63 -51
  38. package/dist/1~src_plugins_inspect_plugin_ts.js +436 -39
  39. package/dist/1~src_plugins_minify_plugin_ts.js +66 -76
  40. package/dist/1~src_plugins_optimization_plugin_ts.js +14 -24
  41. package/dist/1~src_plugins_output_plugin_ts.js +29 -45
  42. package/dist/1~src_plugins_resolve_plugin_ts.js +10 -20
  43. package/dist/1~src_plugins_rsdoctor_plugin_ts.js +37 -55
  44. package/dist/1~src_plugins_sourcemap_plugin_ts.js +86 -96
  45. package/dist/1~src_plugins_swc_plugin_ts.js +20 -38
  46. package/dist/1~src_plugins_target_plugin_ts.js +21 -39
  47. package/dist/1~src_utils_getESVersionTarget_ts.js +4 -0
  48. package/dist/1~src_utils_is-ci_ts.js +4 -0
  49. package/dist/1~src_version_ts.js +6 -18
  50. package/dist/cli/main.js +1 -357
  51. package/dist/cli/start.js +16 -130
  52. package/dist/index.js +1 -524
  53. package/dist/node_fs.js +7 -0
  54. package/dist/node_path.js +7 -0
  55. package/dist/node_url.js +1 -0
  56. package/dist/rslib-runtime.js +75 -0
  57. package/dist/src_cli_main_ts.js +149 -0
  58. package/dist/src_debug_ts.js +93 -0
  59. package/dist/src_index_ts.js +381 -0
  60. package/package.json +1 -1
  61. package/dist/0~vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-562fbc.js +0 -417
  62. package/dist/1~events-fs-fs_promises-os-path-stream.js +0 -30
  63. package/dist/1~node_child_process-node_events-node_fs-node_path.js +0 -22
  64. package/dist/1~vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js +0 -1432
  65. package/dist/1~vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-562fbc.js +0 -417
  66. /package/dist/{1~vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js.LICENSE.txt → 1~node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js.LICENSE.txt} +0 -0
@@ -1,48 +1,445 @@
1
+ import { __webpack_require__ } from "./rslib-runtime.js";
1
2
  import { mkdir, writeFile } from "node:fs/promises";
2
- export const __rspack_esm_id = "src_plugins_inspect_plugin_ts";
3
- export const __rspack_esm_ids = [
4
- "src_plugins_inspect_plugin_ts"
5
- ];
6
- export const __webpack_modules__ = {
7
- "./src/config/output/dist-path.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
8
- __webpack_require__.d(__webpack_exports__, {
9
- z: ()=>DEFAULT_DIST_PATH_INTERMEDIATE
3
+ import "./node_path.js";
4
+ import { debug, logger } from "./src_debug_ts.js";
5
+ import { DEFAULT_DIST_PATH_INTERMEDIATE } from "./1~src_config_output_dist-path_ts.js";
6
+ __webpack_require__.add({
7
+ "../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/array.js" (__unused_rspack_module, exports) {
8
+ Object.defineProperty(exports, "__esModule", {
9
+ value: true
10
10
  });
11
- const DEFAULT_DIST_PATH_INTERMEDIATE = '.rspeedy';
11
+ exports.arrayToString = void 0;
12
+ const arrayToString = (array, space, next)=>{
13
+ const values = array.map(function(value, index) {
14
+ const result = next(value, index);
15
+ if (void 0 === result) return String(result);
16
+ return space + result.split("\n").join(`\n${space}`);
17
+ }).join(space ? ",\n" : ",");
18
+ const eol = space && values ? "\n" : "";
19
+ return `[${eol}${values}${eol}]`;
20
+ };
21
+ exports.arrayToString = arrayToString;
12
22
  },
13
- "./src/plugins/inspect.plugin.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
14
- __webpack_require__.d(__webpack_exports__, {
15
- inspectRspeedyConfig: ()=>inspectRspeedyConfig,
16
- pluginInspect: ()=>pluginInspect
23
+ "../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/function.js" (__unused_rspack_module, exports, __webpack_require__) {
24
+ Object.defineProperty(exports, "__esModule", {
25
+ value: true
17
26
  });
18
- var external_node_path_ = __webpack_require__("node:path");
19
- var core_ = __webpack_require__("@rsbuild/core");
20
- var dist = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/index.js");
21
- var picocolors = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
22
- var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
23
- var dist_path = __webpack_require__("./src/config/output/dist-path.ts");
24
- var debug = __webpack_require__("./src/debug.ts");
25
- function pluginInspect(config) {
26
- return {
27
- name: 'lynx:rsbuild:inspect',
28
- setup (api) {
29
- api.onBeforeBuild(async ()=>{
30
- await inspectRspeedyConfig(config, external_node_path_["default"].join(api.context.distPath, dist_path.z, 'rspeedy.config.js'), false);
31
- });
27
+ exports.FunctionParser = exports.dedentFunction = exports.functionToString = exports.USED_METHOD_KEY = void 0;
28
+ const quote_1 = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/quote.js");
29
+ const METHOD_NAMES_ARE_QUOTED = '"' === ({
30
+ " " () {}
31
+ })[" "].toString().charAt(0);
32
+ const FUNCTION_PREFIXES = {
33
+ Function: "function ",
34
+ GeneratorFunction: "function* ",
35
+ AsyncFunction: "async function ",
36
+ AsyncGeneratorFunction: "async function* "
37
+ };
38
+ const METHOD_PREFIXES = {
39
+ Function: "",
40
+ GeneratorFunction: "*",
41
+ AsyncFunction: "async ",
42
+ AsyncGeneratorFunction: "async *"
43
+ };
44
+ const TOKENS_PRECEDING_REGEXPS = new Set("case delete else in instanceof new return throw typeof void , ; : + - ! ~ & | ^ * / % < > ? =".split(" "));
45
+ exports.USED_METHOD_KEY = new WeakSet();
46
+ const functionToString = (fn, space, next, key)=>{
47
+ const name = "string" == typeof key ? key : void 0;
48
+ if (void 0 !== name) exports.USED_METHOD_KEY.add(fn);
49
+ return new FunctionParser(fn, space, next, name).stringify();
50
+ };
51
+ exports.functionToString = functionToString;
52
+ function dedentFunction(fnString) {
53
+ let found;
54
+ for (const line of fnString.split("\n").slice(1)){
55
+ const m = /^[\s\t]+/.exec(line);
56
+ if (!m) return fnString;
57
+ const [str] = m;
58
+ if (void 0 === found) found = str;
59
+ else if (str.length < found.length) found = str;
60
+ }
61
+ return found ? fnString.split(`\n${found}`).join("\n") : fnString;
62
+ }
63
+ exports.dedentFunction = dedentFunction;
64
+ class FunctionParser {
65
+ constructor(fn, indent, next, key){
66
+ this.fn = fn;
67
+ this.indent = indent;
68
+ this.next = next;
69
+ this.key = key;
70
+ this.pos = 0;
71
+ this.hadKeyword = false;
72
+ this.fnString = Function.prototype.toString.call(fn);
73
+ this.fnType = fn.constructor.name;
74
+ this.keyQuote = void 0 === key ? "" : quote_1.quoteKey(key, next);
75
+ this.keyPrefix = void 0 === key ? "" : `${this.keyQuote}:${indent ? " " : ""}`;
76
+ this.isMethodCandidate = void 0 === key ? false : "" === this.fn.name || this.fn.name === key;
77
+ }
78
+ stringify() {
79
+ const value = this.tryParse();
80
+ if (!value) return `${this.keyPrefix}void ${this.next(this.fnString)}`;
81
+ return dedentFunction(value);
82
+ }
83
+ getPrefix() {
84
+ if (this.isMethodCandidate && !this.hadKeyword) return METHOD_PREFIXES[this.fnType] + this.keyQuote;
85
+ return this.keyPrefix + FUNCTION_PREFIXES[this.fnType];
86
+ }
87
+ tryParse() {
88
+ if ("}" !== this.fnString[this.fnString.length - 1]) return this.keyPrefix + this.fnString;
89
+ if (this.fn.name) {
90
+ const result = this.tryStrippingName();
91
+ if (result) return result;
92
+ }
93
+ const prevPos = this.pos;
94
+ if ("class" === this.consumeSyntax()) return this.fnString;
95
+ this.pos = prevPos;
96
+ if (this.tryParsePrefixTokens()) {
97
+ const result = this.tryStrippingName();
98
+ if (result) return result;
99
+ let offset = this.pos;
100
+ switch(this.consumeSyntax("WORD_LIKE")){
101
+ case "WORD_LIKE":
102
+ if (this.isMethodCandidate && !this.hadKeyword) offset = this.pos;
103
+ case "()":
104
+ if ("=>" === this.fnString.substr(this.pos, 2)) return this.keyPrefix + this.fnString;
105
+ this.pos = offset;
106
+ case '"':
107
+ case "'":
108
+ case "[]":
109
+ return this.getPrefix() + this.fnString.substr(this.pos);
110
+ }
111
+ }
112
+ }
113
+ tryStrippingName() {
114
+ if (METHOD_NAMES_ARE_QUOTED) return;
115
+ let start = this.pos;
116
+ const prefix = this.fnString.substr(this.pos, this.fn.name.length);
117
+ if (prefix === this.fn.name) {
118
+ this.pos += prefix.length;
119
+ if ("()" === this.consumeSyntax() && "{}" === this.consumeSyntax() && this.pos === this.fnString.length) {
120
+ if (this.isMethodCandidate || !quote_1.isValidVariableName(prefix)) start += prefix.length;
121
+ return this.getPrefix() + this.fnString.substr(start);
122
+ }
123
+ }
124
+ this.pos = start;
125
+ }
126
+ tryParsePrefixTokens() {
127
+ let posPrev = this.pos;
128
+ this.hadKeyword = false;
129
+ switch(this.fnType){
130
+ case "AsyncFunction":
131
+ if ("async" !== this.consumeSyntax()) return false;
132
+ posPrev = this.pos;
133
+ case "Function":
134
+ if ("function" === this.consumeSyntax()) this.hadKeyword = true;
135
+ else this.pos = posPrev;
136
+ return true;
137
+ case "AsyncGeneratorFunction":
138
+ if ("async" !== this.consumeSyntax()) return false;
139
+ case "GeneratorFunction":
140
+ let token = this.consumeSyntax();
141
+ if ("function" === token) {
142
+ token = this.consumeSyntax();
143
+ this.hadKeyword = true;
144
+ }
145
+ return "*" === token;
146
+ }
147
+ }
148
+ consumeSyntax(wordLikeToken) {
149
+ const m = this.consumeMatch(/^(?:([A-Za-z_0-9$\xA0-\uFFFF]+)|=>|\+\+|\-\-|.)/);
150
+ if (!m) return;
151
+ const [token, match] = m;
152
+ this.consumeWhitespace();
153
+ if (match) return wordLikeToken || match;
154
+ switch(token){
155
+ case "(":
156
+ return this.consumeSyntaxUntil("(", ")");
157
+ case "[":
158
+ return this.consumeSyntaxUntil("[", "]");
159
+ case "{":
160
+ return this.consumeSyntaxUntil("{", "}");
161
+ case "`":
162
+ return this.consumeTemplate();
163
+ case '"':
164
+ return this.consumeRegExp(/^(?:[^\\"]|\\.)*"/, '"');
165
+ case "'":
166
+ return this.consumeRegExp(/^(?:[^\\']|\\.)*'/, "'");
167
+ }
168
+ return token;
169
+ }
170
+ consumeSyntaxUntil(startToken, endToken) {
171
+ let isRegExpAllowed = true;
172
+ for(;;){
173
+ const token = this.consumeSyntax();
174
+ if (token === endToken) return startToken + endToken;
175
+ if (!token || ")" === token || "]" === token || "}" === token) return;
176
+ if ("/" === token && isRegExpAllowed && this.consumeMatch(/^(?:\\.|[^\\\/\n[]|\[(?:\\.|[^\]])*\])+\/[a-z]*/)) {
177
+ isRegExpAllowed = false;
178
+ this.consumeWhitespace();
179
+ } else isRegExpAllowed = TOKENS_PRECEDING_REGEXPS.has(token);
180
+ }
181
+ }
182
+ consumeMatch(re) {
183
+ const m = re.exec(this.fnString.substr(this.pos));
184
+ if (m) this.pos += m[0].length;
185
+ return m;
186
+ }
187
+ consumeRegExp(re, token) {
188
+ const m = re.exec(this.fnString.substr(this.pos));
189
+ if (!m) return;
190
+ this.pos += m[0].length;
191
+ this.consumeWhitespace();
192
+ return token;
193
+ }
194
+ consumeTemplate() {
195
+ for(;;){
196
+ this.consumeMatch(/^(?:[^`$\\]|\\.|\$(?!{))*/);
197
+ if ("`" === this.fnString[this.pos]) {
198
+ this.pos++;
199
+ this.consumeWhitespace();
200
+ return "`";
201
+ }
202
+ if ("${" === this.fnString.substr(this.pos, 2)) {
203
+ this.pos += 2;
204
+ this.consumeWhitespace();
205
+ if (this.consumeSyntaxUntil("{", "}")) continue;
206
+ }
207
+ return;
32
208
  }
209
+ }
210
+ consumeWhitespace() {
211
+ this.consumeMatch(/^(?:\s|\/\/.*|\/\*[^]*?\*\/)*/);
212
+ }
213
+ }
214
+ exports.FunctionParser = FunctionParser;
215
+ },
216
+ "../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/index.js" (__unused_rspack_module, exports, __webpack_require__) {
217
+ exports.stringify = void 0;
218
+ const stringify_1 = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/stringify.js");
219
+ const quote_1 = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/quote.js");
220
+ const ROOT_SENTINEL = Symbol("root");
221
+ function stringify(value, replacer, indent, options = {}) {
222
+ const space = "string" == typeof indent ? indent : " ".repeat(indent || 0);
223
+ const path = [];
224
+ const stack = new Set();
225
+ const tracking = new Map();
226
+ const unpack = new Map();
227
+ let valueCount = 0;
228
+ const { maxDepth = 100, references = false, skipUndefinedProperties = false, maxValues = 100000 } = options;
229
+ const valueToString = replacerToString(replacer);
230
+ const onNext = (value, key)=>{
231
+ if (++valueCount > maxValues) return;
232
+ if (skipUndefinedProperties && void 0 === value) return;
233
+ if (path.length > maxDepth) return;
234
+ if (void 0 === key) return valueToString(value, space, onNext, key);
235
+ path.push(key);
236
+ const result = builder(value, key === ROOT_SENTINEL ? void 0 : key);
237
+ path.pop();
238
+ return result;
239
+ };
240
+ const builder = references ? (value, key)=>{
241
+ if (null !== value && ("object" == typeof value || "function" == typeof value || "symbol" == typeof value)) {
242
+ if (tracking.has(value)) {
243
+ unpack.set(path.slice(1), tracking.get(value));
244
+ return valueToString(void 0, space, onNext, key);
245
+ }
246
+ tracking.set(value, path.slice(1));
247
+ }
248
+ return valueToString(value, space, onNext, key);
249
+ } : (value, key)=>{
250
+ if (stack.has(value)) return;
251
+ stack.add(value);
252
+ const result = valueToString(value, space, onNext, key);
253
+ stack.delete(value);
254
+ return result;
33
255
  };
256
+ const result = onNext(value, ROOT_SENTINEL);
257
+ if (unpack.size) {
258
+ const sp = space ? " " : "";
259
+ const eol = space ? "\n" : "";
260
+ let wrapper = `var x${sp}=${sp}${result};${eol}`;
261
+ for (const [key, value] of unpack.entries()){
262
+ const keyPath = quote_1.stringifyPath(key, onNext);
263
+ const valuePath = quote_1.stringifyPath(value, onNext);
264
+ wrapper += `x${keyPath}${sp}=${sp}x${valuePath};${eol}`;
265
+ }
266
+ return `(function${sp}()${sp}{${eol}${wrapper}return x;${eol}}())`;
267
+ }
268
+ return result;
34
269
  }
35
- async function inspectRspeedyConfig(config, path, verbose) {
36
- const stringifiedConfig = (0, dist.stringify)(config, (value, _, stringify)=>{
37
- if ('function' == typeof value && !verbose && value.toString().length > 100) return "function () { /* omitted long function */ }";
38
- return stringify(value);
39
- }, 2);
40
- if (!stringifiedConfig) return void (0, debug.Yz)('No Rspeedy config found, skip inspect config.');
41
- await mkdir((0, external_node_path_.dirname)(path), {
42
- recursive: true
43
- });
44
- await writeFile(path, `export default ${stringifiedConfig}`);
45
- core_.logger.success(`Inspect Rspeedy config succeed, open following files to view the content: \n\n - ${picocolors_default().bold(picocolors_default().yellow('Rspeedy'))}: ${picocolors_default().underline(path)}\n`);
270
+ exports.stringify = stringify;
271
+ function replacerToString(replacer) {
272
+ if (!replacer) return stringify_1.toString;
273
+ return (value, space, next, key)=>replacer(value, space, (value)=>stringify_1.toString(value, space, next, key), key);
46
274
  }
275
+ },
276
+ "../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/object.js" (__unused_rspack_module, exports, __webpack_require__) {
277
+ Object.defineProperty(exports, "__esModule", {
278
+ value: true
279
+ });
280
+ exports.objectToString = void 0;
281
+ const quote_1 = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/quote.js");
282
+ const function_1 = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/function.js");
283
+ const array_1 = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/array.js");
284
+ const objectToString = (value, space, next, key)=>{
285
+ if ("function" == typeof Buffer && Buffer.isBuffer(value)) return `Buffer.from(${next(value.toString("base64"))}, 'base64')`;
286
+ if ("object" == typeof global && value === global) return globalToString(value, space, next, key);
287
+ const toString = OBJECT_TYPES[Object.prototype.toString.call(value)];
288
+ return toString ? toString(value, space, next, key) : void 0;
289
+ };
290
+ exports.objectToString = objectToString;
291
+ const rawObjectToString = (obj, indent, next, key)=>{
292
+ const eol = indent ? "\n" : "";
293
+ const space = indent ? " " : "";
294
+ const values = Object.keys(obj).reduce(function(values, key) {
295
+ const fn = obj[key];
296
+ const result = next(fn, key);
297
+ if (void 0 === result) return values;
298
+ const value = result.split("\n").join(`\n${indent}`);
299
+ if (function_1.USED_METHOD_KEY.has(fn)) {
300
+ values.push(`${indent}${value}`);
301
+ return values;
302
+ }
303
+ values.push(`${indent}${quote_1.quoteKey(key, next)}:${space}${value}`);
304
+ return values;
305
+ }, []).join(`,${eol}`);
306
+ if ("" === values) return "{}";
307
+ return `{${eol}${values}${eol}}`;
308
+ };
309
+ const globalToString = (value, space, next)=>`Function(${next("return this")})()`;
310
+ const OBJECT_TYPES = {
311
+ "[object Array]": array_1.arrayToString,
312
+ "[object Object]": rawObjectToString,
313
+ "[object Error]": (error, space, next)=>`new Error(${next(error.message)})`,
314
+ "[object Date]": (date)=>`new Date(${date.getTime()})`,
315
+ "[object String]": (str, space, next)=>`new String(${next(str.toString())})`,
316
+ "[object Number]": (num)=>`new Number(${num})`,
317
+ "[object Boolean]": (bool)=>`new Boolean(${bool})`,
318
+ "[object Set]": (set, space, next)=>`new Set(${next(Array.from(set))})`,
319
+ "[object Map]": (map, space, next)=>`new Map(${next(Array.from(map))})`,
320
+ "[object RegExp]": String,
321
+ "[object global]": globalToString,
322
+ "[object Window]": globalToString
323
+ };
324
+ },
325
+ "../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/quote.js" (__unused_rspack_module, exports) {
326
+ Object.defineProperty(exports, "__esModule", {
327
+ value: true
328
+ });
329
+ exports.stringifyPath = exports.quoteKey = exports.isValidVariableName = exports.IS_VALID_IDENTIFIER = exports.quoteString = void 0;
330
+ const ESCAPABLE = /[\\\'\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
331
+ const META_CHARS = new Map([
332
+ [
333
+ "\b",
334
+ "\\b"
335
+ ],
336
+ [
337
+ "\t",
338
+ "\\t"
339
+ ],
340
+ [
341
+ "\n",
342
+ "\\n"
343
+ ],
344
+ [
345
+ "\f",
346
+ "\\f"
347
+ ],
348
+ [
349
+ "\r",
350
+ "\\r"
351
+ ],
352
+ [
353
+ "'",
354
+ "\\'"
355
+ ],
356
+ [
357
+ '"',
358
+ '\\"'
359
+ ],
360
+ [
361
+ "\\",
362
+ "\\\\"
363
+ ]
364
+ ]);
365
+ function escapeChar(char) {
366
+ return META_CHARS.get(char) || `\\u${`0000${char.charCodeAt(0).toString(16)}`.slice(-4)}`;
367
+ }
368
+ function quoteString(str) {
369
+ return `'${str.replace(ESCAPABLE, escapeChar)}'`;
370
+ }
371
+ exports.quoteString = quoteString;
372
+ const RESERVED_WORDS = new Set("break else new var case finally return void catch for switch while continue function this with default if throw delete in try do instanceof typeof abstract enum int short boolean export interface static byte extends long super char final native synchronized class float package throws const goto private transient debugger implements protected volatile double import public let yield".split(" "));
373
+ exports.IS_VALID_IDENTIFIER = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
374
+ function isValidVariableName(name) {
375
+ return "string" == typeof name && !RESERVED_WORDS.has(name) && exports.IS_VALID_IDENTIFIER.test(name);
376
+ }
377
+ exports.isValidVariableName = isValidVariableName;
378
+ function quoteKey(key, next) {
379
+ return isValidVariableName(key) ? key : next(key);
380
+ }
381
+ exports.quoteKey = quoteKey;
382
+ function stringifyPath(path, next) {
383
+ let result = "";
384
+ for (const key of path)if (isValidVariableName(key)) result += `.${key}`;
385
+ else result += `[${next(key)}]`;
386
+ return result;
387
+ }
388
+ exports.stringifyPath = stringifyPath;
389
+ },
390
+ "../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/stringify.js" (__unused_rspack_module, exports, __webpack_require__) {
391
+ Object.defineProperty(exports, "__esModule", {
392
+ value: true
393
+ });
394
+ exports.toString = void 0;
395
+ const quote_1 = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/quote.js");
396
+ const object_1 = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/object.js");
397
+ const function_1 = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/function.js");
398
+ const PRIMITIVE_TYPES = {
399
+ string: quote_1.quoteString,
400
+ number: (value)=>Object.is(value, -0) ? "-0" : String(value),
401
+ boolean: String,
402
+ symbol: (value, space, next)=>{
403
+ const key = Symbol.keyFor(value);
404
+ if (void 0 !== key) return `Symbol.for(${next(key)})`;
405
+ return `Symbol(${next(value.description)})`;
406
+ },
407
+ bigint: (value, space, next)=>`BigInt(${next(String(value))})`,
408
+ undefined: String,
409
+ object: object_1.objectToString,
410
+ function: function_1.functionToString
411
+ };
412
+ const toString = (value, space, next, key)=>{
413
+ if (null === value) return "null";
414
+ return PRIMITIVE_TYPES[typeof value](value, space, next, key);
415
+ };
416
+ exports.toString = toString;
47
417
  }
48
- };
418
+ });
419
+ const external_node_path_ = __webpack_require__("node:path");
420
+ const dist = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/index.js");
421
+ const picocolors = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
422
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
423
+ function pluginInspect(config) {
424
+ return {
425
+ name: 'lynx:rsbuild:inspect',
426
+ setup (api) {
427
+ api.onBeforeBuild(async ()=>{
428
+ await inspectRspeedyConfig(config, external_node_path_["default"].join(api.context.distPath, DEFAULT_DIST_PATH_INTERMEDIATE, 'rspeedy.config.js'), false);
429
+ });
430
+ }
431
+ };
432
+ }
433
+ async function inspectRspeedyConfig(config, path, verbose) {
434
+ const stringifiedConfig = (0, dist.stringify)(config, (value, _, stringify)=>{
435
+ if ('function' == typeof value && !verbose && value.toString().length > 100) return "function () { /* omitted long function */ }";
436
+ return stringify(value);
437
+ }, 2);
438
+ if (!stringifiedConfig) return void debug('No Rspeedy config found, skip inspect config.');
439
+ await mkdir((0, external_node_path_.dirname)(path), {
440
+ recursive: true
441
+ });
442
+ await writeFile(path, `export default ${stringifiedConfig}`);
443
+ logger.success(`Inspect Rspeedy config succeed, open following files to view the content: \n\n - ${picocolors_default().bold(picocolors_default().yellow('Rspeedy'))}: ${picocolors_default().underline(path)}\n`);
444
+ }
445
+ export { inspectRspeedyConfig, pluginInspect };
@@ -1,85 +1,75 @@
1
- export const __rspack_esm_id = "src_plugins_minify_plugin_ts";
2
- export const __rspack_esm_ids = [
3
- "src_plugins_minify_plugin_ts"
4
- ];
5
- export const __webpack_modules__ = {
6
- "./src/plugins/minify.plugin.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
7
- __webpack_require__.d(__webpack_exports__, {
8
- pluginMinify: ()=>pluginMinify
9
- });
10
- var _debug_js__rspack_import_0 = __webpack_require__("./src/debug.ts");
11
- function pluginMinify(options) {
12
- const defaultConfig = Object.freeze({
13
- output: {
14
- minify: {
15
- js: true,
16
- jsOptions: {
17
- minimizerOptions: {
18
- compress: {
19
- negate_iife: false,
20
- join_vars: false,
21
- ecma: 2015,
22
- inline: 2,
23
- comparisons: false,
24
- toplevel: true,
25
- side_effects: false
26
- },
27
- format: {
28
- keep_quoted_props: true,
29
- comments: false
30
- },
31
- mangle: {
32
- toplevel: true
33
- }
34
- }
1
+ import { debug } from "./src_debug_ts.js";
2
+ function pluginMinify(options) {
3
+ const defaultConfig = Object.freeze({
4
+ output: {
5
+ minify: {
6
+ js: true,
7
+ jsOptions: {
8
+ minimizerOptions: {
9
+ compress: {
10
+ negate_iife: false,
11
+ join_vars: false,
12
+ ecma: 2015,
13
+ inline: 2,
14
+ comparisons: false,
15
+ toplevel: true,
16
+ side_effects: false
35
17
  },
36
- css: true,
37
- cssOptions: {
38
- minimizerOptions: {
39
- targets: '',
40
- include: {
41
- nesting: true,
42
- doublePositionGradients: true,
43
- spaceSeparatedColorNotation: true
44
- },
45
- exclude: {
46
- vendorPrefixes: true,
47
- logicalProperties: true,
48
- hexAlphaColors: true
49
- }
50
- }
18
+ format: {
19
+ keep_quoted_props: true,
20
+ comments: false
21
+ },
22
+ mangle: {
23
+ toplevel: true
24
+ }
25
+ }
26
+ },
27
+ css: true,
28
+ cssOptions: {
29
+ minimizerOptions: {
30
+ targets: '',
31
+ include: {
32
+ nesting: true,
33
+ doublePositionGradients: true,
34
+ spaceSeparatedColorNotation: true
35
+ },
36
+ exclude: {
37
+ vendorPrefixes: true,
38
+ logicalProperties: true,
39
+ hexAlphaColors: true
51
40
  }
52
41
  }
53
42
  }
54
- });
55
- return {
56
- name: 'lynx:rsbuild:minify',
57
- setup (api) {
58
- api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>{
59
- if (false === options) {
60
- (0, _debug_js__rspack_import_0.Yz)("minification disabled");
61
- return mergeRsbuildConfig(config, {
62
- output: {
63
- minify: false
64
- }
65
- });
43
+ }
44
+ }
45
+ });
46
+ return {
47
+ name: 'lynx:rsbuild:minify',
48
+ setup (api) {
49
+ api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>{
50
+ if (false === options) {
51
+ debug("minification disabled");
52
+ return mergeRsbuildConfig(config, {
53
+ output: {
54
+ minify: false
66
55
  }
67
- const configs = [
68
- config,
69
- defaultConfig
70
- ];
71
- if (true !== options && void 0 !== options) {
72
- (0, _debug_js__rspack_import_0.Yz)("merging minification options");
73
- configs.push({
74
- output: {
75
- minify: options
76
- }
77
- });
56
+ });
57
+ }
58
+ const configs = [
59
+ config,
60
+ defaultConfig
61
+ ];
62
+ if (true !== options && void 0 !== options) {
63
+ debug("merging minification options");
64
+ configs.push({
65
+ output: {
66
+ minify: options
78
67
  }
79
- return mergeRsbuildConfig(...configs);
80
68
  });
81
69
  }
82
- };
70
+ return mergeRsbuildConfig(...configs);
71
+ });
83
72
  }
84
- }
85
- };
73
+ };
74
+ }
75
+ export { pluginMinify };