@lynx-js/rspeedy 0.14.5 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/dist/{0~src_plugins_api_plugin_ts.js → 0~api.plugin.js} +3 -4
  3. package/dist/{0~src_plugins_dev_plugin_ts.js → 0~dev.plugin.js} +19 -13
  4. package/dist/{0~src_cli_exit_ts.js → 0~exit.js} +4 -3
  5. package/dist/0~getESVersionTarget.js +33 -0
  6. package/dist/{0~src_plugins_inspect_plugin_ts.js → 0~inspect.plugin.js} +13 -28
  7. package/dist/{0~node_modules_pnpm_ipaddr_js_2_3_0_node_modules_ipaddr_js_lib_ipaddr_js.js → 0~ipaddr.js} +2 -1
  8. package/dist/0~is-lynx.js +5 -0
  9. package/dist/{1~src_plugins_optimization_plugin_ts.js → 0~optimization.plugin.js} +3 -2
  10. package/dist/{0~src_plugins_output_plugin_ts.js → 0~output.plugin.js} +14 -3
  11. package/dist/0~plugins.js +40 -0
  12. package/dist/{0~src_plugins_rsdoctor_plugin_ts.js → 0~rsdoctor.plugin.js} +1 -1
  13. package/dist/{1~src_plugins_sourcemap_plugin_ts.js → 0~sourcemap.plugin.js} +19 -2
  14. package/dist/0~statsJson.plugin.js +26 -0
  15. package/dist/0~swc.plugin.js +25 -0
  16. package/dist/{0~src_plugins_target_plugin_ts.js → 0~target.plugin.js} +4 -4
  17. package/dist/{1~src_config_validate_ts.js → 0~validate.js} +17963 -28527
  18. package/dist/{1~src_plugins_api_plugin_ts.js → 1~api.plugin.js} +3 -4
  19. package/dist/{1~src_cli_build_ts.js → 1~build.js} +7 -7
  20. package/dist/{1~node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js → 1~chokidar.js} +47 -47
  21. package/dist/{1~src_cli_commands_ts.js → 1~commands.js} +7 -17
  22. package/dist/{1~src_cli_dev_ts.js → 1~dev.js} +6 -6
  23. package/dist/{1~src_plugins_dev_plugin_ts.js → 1~dev.plugin.js} +20 -16
  24. package/dist/{1~node_modules_pnpm_commander_13_1_0_node_modules_commander_esm_mjs.js → 1~esm.js} +33 -29
  25. package/dist/1~getESVersionTarget.js +33 -0
  26. package/dist/{1~src_cli_inspect_ts.js → 1~inspect.js} +2 -1
  27. package/dist/{1~src_plugins_inspect_plugin_ts.js → 1~inspect.plugin.js} +15 -32
  28. package/dist/{1~node_modules_pnpm_ipaddr_js_2_3_0_node_modules_ipaddr_js_lib_ipaddr_js.js → 1~ipaddr.js} +2 -1
  29. package/dist/1~is-lynx.js +5 -0
  30. package/dist/{1~src_plugins_minify_plugin_ts.js → 1~minify.plugin.js} +2 -1
  31. package/dist/{0~src_plugins_optimization_plugin_ts.js → 1~optimization.plugin.js} +3 -2
  32. package/dist/{1~src_plugins_output_plugin_ts.js → 1~output.plugin.js} +14 -3
  33. package/dist/1~plugins.js +40 -0
  34. package/dist/{1~src_cli_preview_ts.js → 1~preview.js} +5 -5
  35. package/dist/{1~src_plugins_rsdoctor_plugin_ts.js → 1~rsdoctor.plugin.js} +2 -2
  36. package/dist/{0~src_plugins_sourcemap_plugin_ts.js → 1~sourcemap.plugin.js} +19 -2
  37. package/dist/1~src_cli_init_ts-src_create-rspeedy_ts.js +43 -29
  38. package/dist/1~statsJson.plugin.js +26 -0
  39. package/dist/1~swc.plugin.js +25 -0
  40. package/dist/{1~src_plugins_target_plugin_ts.js → 1~target.plugin.js} +4 -4
  41. package/dist/{0~src_config_validate_ts.js → 1~validate.js} +17963 -28527
  42. package/dist/{1~src_cli_watch_ts.js → 1~watch.js} +1 -3
  43. package/dist/cli/main.js +1 -1
  44. package/dist/index.d.ts +94 -17
  45. package/dist/{src_cli_main_ts.js → src_cli_main_ts-node_child_process-node_events-node_fs-node_path-node_process.js} +127 -30
  46. package/dist/src_index_ts.js +132 -19
  47. package/package.json +18 -17
  48. package/dist/0~src_plugins_index_ts.js +0 -64
  49. package/dist/0~src_plugins_swc_plugin_ts.js +0 -21
  50. package/dist/0~src_utils_getESVersionTarget_ts.js +0 -4
  51. package/dist/1~node_fs.js +0 -7
  52. package/dist/1~node_path.js +0 -7
  53. package/dist/1~src_plugins_index_ts.js +0 -64
  54. package/dist/1~src_plugins_swc_plugin_ts.js +0 -21
  55. package/dist/1~src_utils_getESVersionTarget_ts.js +0 -4
  56. package/dist/rslib-runtime.js +0 -75
  57. /package/dist/{0~src_plugins_chunkLoading_plugin_ts.js → 0~chunkLoading.plugin.js} +0 -0
  58. /package/dist/{0~src_config_output_dist-path_ts.js → 0~dist-path.js} +0 -0
  59. /package/dist/{0~src_plugins_emitOnErrors_plugin_ts.js → 0~emitOnErrors.plugin.js} +0 -0
  60. /package/dist/{0~src_plugins_minify_plugin_ts.js → 0~minify.plugin.js} +0 -0
  61. /package/dist/{0~src_plugins_resolve_plugin_ts.js → 0~resolve.plugin.js} +0 -0
  62. /package/dist/{1~node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js.LICENSE.txt → 1~chokidar.js.LICENSE.txt} +0 -0
  63. /package/dist/{1~src_plugins_chunkLoading_plugin_ts.js → 1~chunkLoading.plugin.js} +0 -0
  64. /package/dist/{1~src_config_output_dist-path_ts.js → 1~dist-path.js} +0 -0
  65. /package/dist/{1~src_plugins_emitOnErrors_plugin_ts.js → 1~emitOnErrors.plugin.js} +0 -0
  66. /package/dist/{1~src_utils_is-ci_ts.js → 1~is-ci.js} +0 -0
  67. /package/dist/{1~src_plugins_resolve_plugin_ts.js → 1~resolve.plugin.js} +0 -0
@@ -0,0 +1,33 @@
1
+ function getESVersionTarget() {
2
+ return 'es2017';
3
+ }
4
+ const ES2019_INCLUDE = [
5
+ 'transform-nullish-coalescing-operator',
6
+ 'transform-optional-chaining',
7
+ 'transform-export-namespace-from',
8
+ 'transform-logical-assignment-operators',
9
+ 'transform-numeric-separator',
10
+ 'transform-class-properties',
11
+ 'transform-class-static-block',
12
+ 'transform-private-methods',
13
+ 'transform-private-property-in-object'
14
+ ];
15
+ const ES2017_INCLUDE = [
16
+ 'transform-async-generator-functions',
17
+ 'transform-dotall-regex',
18
+ 'transform-named-capturing-groups-regex',
19
+ 'transform-object-rest-spread',
20
+ 'transform-unicode-property-regex',
21
+ 'transform-json-strings',
22
+ 'transform-optional-catch-binding',
23
+ ...ES2019_INCLUDE
24
+ ];
25
+ function getESVersionEnvInclude() {
26
+ return [
27
+ ...ES2017_INCLUDE
28
+ ];
29
+ }
30
+ const ES_ENV_TARGETS = {
31
+ chrome: '120'
32
+ };
33
+ export { ES_ENV_TARGETS, getESVersionEnvInclude, getESVersionTarget };
@@ -1,4 +1,5 @@
1
- import { logger, exit_exit } from "./src_cli_main_ts.js";
1
+ import { logger } from "@rsbuild/core";
2
+ import { exit as exit_exit } from "./src_cli_main_ts-node_child_process-node_events-node_fs-node_path-node_process.js";
2
3
  import { createRspeedy, init } from "./1~src_cli_init_ts-src_create-rspeedy_ts.js";
3
4
  async function inspect(cwd, inspectOptions) {
4
5
  try {
@@ -1,13 +1,11 @@
1
- import { __webpack_require__ } from "./rslib-runtime.js";
2
1
  import { mkdir, writeFile } from "node:fs/promises";
3
- import "./1~node_path.js";
4
- import { debug, logger } from "./src_cli_main_ts.js";
5
- import { DEFAULT_DIST_PATH_INTERMEDIATE } from "./1~src_config_output_dist-path_ts.js";
2
+ import node_path, { dirname } from "node:path";
3
+ import { logger } from "@rsbuild/core";
4
+ import { __webpack_require__ } from "./src_cli_main_ts-node_child_process-node_events-node_fs-node_path-node_process.js";
5
+ import { debug } from "./src_cli_main_ts-node_child_process-node_events-node_fs-node_path-node_process.js";
6
+ import { DEFAULT_DIST_PATH_INTERMEDIATE } from "./1~dist-path.js";
6
7
  __webpack_require__.add({
7
8
  "../../../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
- });
11
9
  exports.arrayToString = void 0;
12
10
  const arrayToString = (array, space, next)=>{
13
11
  const values = array.map(function(value, index) {
@@ -21,10 +19,7 @@ __webpack_require__.add({
21
19
  exports.arrayToString = arrayToString;
22
20
  },
23
21
  "../../../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
26
- });
27
- exports.FunctionParser = exports.dedentFunction = exports.functionToString = exports.USED_METHOD_KEY = void 0;
22
+ exports.functionToString = exports.USED_METHOD_KEY = void 0;
28
23
  const quote_1 = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/quote.js");
29
24
  const METHOD_NAMES_ARE_QUOTED = '"' === ({
30
25
  " " () {}
@@ -60,7 +55,6 @@ __webpack_require__.add({
60
55
  }
61
56
  return found ? fnString.split(`\n${found}`).join("\n") : fnString;
62
57
  }
63
- exports.dedentFunction = dedentFunction;
64
58
  class FunctionParser {
65
59
  constructor(fn, indent, next, key){
66
60
  this.fn = fn;
@@ -211,10 +205,9 @@ __webpack_require__.add({
211
205
  this.consumeMatch(/^(?:\s|\/\/.*|\/\*[^]*?\*\/)*/);
212
206
  }
213
207
  }
214
- exports.FunctionParser = FunctionParser;
215
208
  },
216
209
  "../../../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;
210
+ exports.A = void 0;
218
211
  const stringify_1 = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/stringify.js");
219
212
  const quote_1 = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/quote.js");
220
213
  const ROOT_SENTINEL = Symbol("root");
@@ -267,23 +260,20 @@ __webpack_require__.add({
267
260
  }
268
261
  return result;
269
262
  }
270
- exports.stringify = stringify;
263
+ exports.A = stringify;
271
264
  function replacerToString(replacer) {
272
265
  if (!replacer) return stringify_1.toString;
273
266
  return (value, space, next, key)=>replacer(value, space, (value)=>stringify_1.toString(value, space, next, key), key);
274
267
  }
275
268
  },
276
269
  "../../../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
270
  exports.objectToString = void 0;
281
271
  const quote_1 = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/quote.js");
282
272
  const function_1 = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/function.js");
283
273
  const array_1 = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/array.js");
284
274
  const objectToString = (value, space, next, key)=>{
285
275
  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);
276
+ if ("object" == typeof global && value === global) return globalToString(value, space, next);
287
277
  const toString = OBJECT_TYPES[Object.prototype.toString.call(value)];
288
278
  return toString ? toString(value, space, next, key) : void 0;
289
279
  };
@@ -323,10 +313,7 @@ __webpack_require__.add({
323
313
  };
324
314
  },
325
315
  "../../../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;
316
+ exports.stringifyPath = exports.quoteKey = exports.isValidVariableName = exports.W = exports.quoteString = void 0;
330
317
  const ESCAPABLE = /[\\\'\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
331
318
  const META_CHARS = new Map([
332
319
  [
@@ -370,9 +357,9 @@ __webpack_require__.add({
370
357
  }
371
358
  exports.quoteString = quoteString;
372
359
  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_$]*$/;
360
+ exports.W = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
374
361
  function isValidVariableName(name) {
375
- return "string" == typeof name && !RESERVED_WORDS.has(name) && exports.IS_VALID_IDENTIFIER.test(name);
362
+ return "string" == typeof name && !RESERVED_WORDS.has(name) && exports.W.test(name);
376
363
  }
377
364
  exports.isValidVariableName = isValidVariableName;
378
365
  function quoteKey(key, next) {
@@ -388,9 +375,6 @@ __webpack_require__.add({
388
375
  exports.stringifyPath = stringifyPath;
389
376
  },
390
377
  "../../../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
378
  exports.toString = void 0;
395
379
  const quote_1 = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/quote.js");
396
380
  const object_1 = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/object.js");
@@ -416,7 +400,6 @@ __webpack_require__.add({
416
400
  exports.toString = toString;
417
401
  }
418
402
  });
419
- const external_node_path_ = __webpack_require__("node:path");
420
403
  const dist = __webpack_require__("../../../node_modules/.pnpm/javascript-stringify@2.1.0/node_modules/javascript-stringify/dist/index.js");
421
404
  const picocolors = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
422
405
  var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
@@ -425,18 +408,18 @@ function pluginInspect(config) {
425
408
  name: 'lynx:rsbuild:inspect',
426
409
  setup (api) {
427
410
  api.onBeforeBuild(async ()=>{
428
- await inspectRspeedyConfig(config, external_node_path_["default"].join(api.context.distPath, DEFAULT_DIST_PATH_INTERMEDIATE, 'rspeedy.config.js'), false);
411
+ await inspectRspeedyConfig(config, node_path.join(api.context.distPath, DEFAULT_DIST_PATH_INTERMEDIATE, 'rspeedy.config.js'), false);
429
412
  });
430
413
  }
431
414
  };
432
415
  }
433
416
  async function inspectRspeedyConfig(config, path, verbose) {
434
- const stringifiedConfig = (0, dist.stringify)(config, (value, _, stringify)=>{
417
+ const stringifiedConfig = (0, dist.A)(config, (value, _, stringify)=>{
435
418
  if ('function' == typeof value && !verbose && value.toString().length > 100) return "function () { /* omitted long function */ }";
436
419
  return stringify(value);
437
420
  }, 2);
438
421
  if (!stringifiedConfig) return void debug('No Rspeedy config found, skip inspect config.');
439
- await mkdir((0, external_node_path_.dirname)(path), {
422
+ await mkdir(dirname(path), {
440
423
  recursive: true
441
424
  });
442
425
  await writeFile(path, `export default ${stringifiedConfig}`);
@@ -1,4 +1,4 @@
1
- import { __webpack_require__ } from "./rslib-runtime.js";
1
+ import { __webpack_require__ } from "./src_cli_main_ts-node_child_process-node_events-node_fs-node_path-node_process.js";
2
2
  __webpack_require__.add({
3
3
  "../../../node_modules/.pnpm/ipaddr.js@2.3.0/node_modules/ipaddr.js/lib/ipaddr.js" (module) {
4
4
  (function(root) {
@@ -1068,3 +1068,4 @@ __webpack_require__.add({
1068
1068
  })(this);
1069
1069
  }
1070
1070
  });
1071
+ __webpack_require__("../../../node_modules/.pnpm/ipaddr.js@2.3.0/node_modules/ipaddr.js/lib/ipaddr.js");
@@ -0,0 +1,5 @@
1
+ function isLynx(environment) {
2
+ const environmentName = 'string' == typeof environment ? environment : environment.name;
3
+ return 'lynx' === environmentName || environmentName.startsWith('lynx-');
4
+ }
5
+ export { isLynx };
@@ -1,4 +1,5 @@
1
- import { mergeRsbuildConfig as core_mergeRsbuildConfig, debug } from "./src_cli_main_ts.js";
1
+ import { mergeRsbuildConfig as core_mergeRsbuildConfig } from "@rsbuild/core";
2
+ import { debug } from "./src_cli_main_ts-node_child_process-node_events-node_fs-node_path-node_process.js";
2
3
  function mergeRspeedyConfig(...configs) {
3
4
  return core_mergeRsbuildConfig(...configs);
4
5
  }
@@ -3,8 +3,9 @@ function pluginOptimization() {
3
3
  name: 'lynx:rsbuild:optimization',
4
4
  setup (api) {
5
5
  api.modifyBundlerChain((chain, { CHAIN_ID, isProd })=>{
6
- const rule = chain.module.rules.get(CHAIN_ID.RULE.JS);
7
- chain.module.rule('js-override-strict').type(rule.get('type')).test(rule.get('test')).parser({
6
+ const jsRule = chain.module.rule(CHAIN_ID.RULE.JS);
7
+ const jsMainRule = jsRule.oneOf(CHAIN_ID.ONE_OF.JS_MAIN);
8
+ chain.module.rule('js-override-strict').type(jsMainRule.get('type')).test(jsRule.get('test')).parser({
8
9
  overrideStrict: 'strict'
9
10
  }).end();
10
11
  if (isProd) chain.optimization.avoidEntryIife(true);
@@ -1,4 +1,4 @@
1
- import { DEFAULT_DIST_PATH_INTERMEDIATE } from "./1~src_config_output_dist-path_ts.js";
1
+ import { DEFAULT_DIST_PATH_INTERMEDIATE } from "./1~dist-path.js";
2
2
  const defaultFilenameOptions = Object.freeze({
3
3
  css: '[name]/[name].css'
4
4
  });
@@ -10,14 +10,25 @@ function pluginOutput(options) {
10
10
  name: 'lynx:rsbuild:output',
11
11
  setup (api) {
12
12
  api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>{
13
- if (!options) return mergeRsbuildConfig({
13
+ const lowerToVar = {
14
+ tools: {
15
+ rspack: {
16
+ output: {
17
+ environment: {
18
+ const: false
19
+ }
20
+ }
21
+ }
22
+ }
23
+ };
24
+ if (!options) return mergeRsbuildConfig(lowerToVar, {
14
25
  output: {
15
26
  filename: {
16
27
  css: defaultFilenameOptions.css
17
28
  }
18
29
  }
19
30
  }, config);
20
- return mergeRsbuildConfig(config, {
31
+ return mergeRsbuildConfig(lowerToVar, config, {
21
32
  output: {
22
33
  distPath: Object.assign({}, defaultDistPathOptions, options.distPath),
23
34
  filename: Object.assign({}, defaultFilenameOptions, options.filename)
@@ -0,0 +1,40 @@
1
+ import { debug, isDebug } from "./src_cli_main_ts-node_child_process-node_events-node_fs-node_path-node_process.js";
2
+ async function applyDebugPlugins(rsbuildInstance, config) {
3
+ const debugPlugins = Object.freeze([
4
+ import("./1~emitOnErrors.plugin.js").then(({ pluginEmitOnErrors })=>pluginEmitOnErrors()),
5
+ import("./1~inspect.plugin.js").then(({ pluginInspect })=>pluginInspect(config))
6
+ ]);
7
+ rsbuildInstance.addPlugins(await Promise.all(debugPlugins));
8
+ }
9
+ async function applyDefaultPlugins(rsbuildInstance, config) {
10
+ const defaultPlugins = Object.freeze([
11
+ import("./1~api.plugin.js").then(({ pluginAPI })=>pluginAPI(config)),
12
+ import("./1~chunkLoading.plugin.js").then(({ pluginChunkLoading })=>pluginChunkLoading()),
13
+ import("@lynx-js/debug-metadata-rsbuild-plugin").then(({ pluginLynxDebugMetadata })=>pluginLynxDebugMetadata()),
14
+ import("./1~dev.plugin.js").then(({ pluginDev })=>pluginDev(config.dev, config.server)),
15
+ import("./1~minify.plugin.js").then(({ pluginMinify })=>pluginMinify(config.output?.minify)),
16
+ import("./1~optimization.plugin.js").then(({ pluginOptimization })=>pluginOptimization()),
17
+ import("./1~output.plugin.js").then(({ pluginOutput })=>pluginOutput(config.output)),
18
+ import("./1~resolve.plugin.js").then(({ pluginResolve })=>pluginResolve()),
19
+ import("./1~rsdoctor.plugin.js").then(({ pluginRsdoctor })=>pluginRsdoctor(config.tools?.rsdoctor)),
20
+ import("./1~sourcemap.plugin.js").then(({ pluginSourcemap })=>pluginSourcemap()),
21
+ import("./1~statsJson.plugin.js").then(({ pluginStatsJson })=>pluginStatsJson(config)),
22
+ import("./1~swc.plugin.js").then(({ pluginSwc })=>pluginSwc()),
23
+ import("./1~target.plugin.js").then(({ pluginTarget })=>pluginTarget())
24
+ ]);
25
+ const promises = [
26
+ Promise.all(defaultPlugins).then((plugins)=>{
27
+ rsbuildInstance.addPlugins(plugins);
28
+ })
29
+ ];
30
+ if (isDebug()) {
31
+ debug('apply Rspeedy default debug plugins');
32
+ promises.push(applyDebugPlugins(rsbuildInstance, config));
33
+ }
34
+ await Promise.all(promises);
35
+ const { pluginCssMinimizer, PLUGIN_CSS_MINIMIZER_NAME } = await import("@rsbuild/plugin-css-minimizer");
36
+ if (!rsbuildInstance.isPluginExists(PLUGIN_CSS_MINIMIZER_NAME)) rsbuildInstance.addPlugins([
37
+ pluginCssMinimizer()
38
+ ]);
39
+ }
40
+ export { applyDefaultPlugins };
@@ -1,8 +1,8 @@
1
- import { __webpack_require__ } from "./rslib-runtime.js";
2
- import "./1~node_fs.js";
3
- import { logger, exit_exit } from "./src_cli_main_ts.js";
1
+ import { __webpack_require__ } from "./src_cli_main_ts-node_child_process-node_events-node_fs-node_path-node_process.js";
2
+ import node_fs from "node:fs";
3
+ import { logger } from "@rsbuild/core";
4
+ import { exit as exit_exit } from "./src_cli_main_ts-node_child_process-node_events-node_fs-node_path-node_process.js";
4
5
  import { createRspeedy, init } from "./1~src_cli_init_ts-src_create-rspeedy_ts.js";
5
- const external_node_fs_ = __webpack_require__("node:fs");
6
6
  const picocolors = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
7
7
  var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
8
8
  async function preview(cwd, previewOptions) {
@@ -11,7 +11,7 @@ async function preview(cwd, previewOptions) {
11
11
  const rspeedy = await createRspeedy(createRspeedyOptions);
12
12
  await rspeedy.initConfigs();
13
13
  const { distPath } = rspeedy.context;
14
- if (!external_node_fs_["default"].existsSync(distPath)) throw new Error(`The output directory ${picocolors_default().yellow(distPath)} does not exist, please build the project before previewing.`);
14
+ if (!node_fs.existsSync(distPath)) throw new Error(`The output directory ${picocolors_default().yellow(distPath)} does not exist, please build the project before previewing.`);
15
15
  await rspeedy.preview();
16
16
  } catch (error) {
17
17
  logger.error('Failed to start preview server.');
@@ -1,5 +1,5 @@
1
- import { mergeRsbuildConfig, logger } from "./src_cli_main_ts.js";
2
- import { isCI } from "./1~src_utils_is-ci_ts.js";
1
+ import { logger, mergeRsbuildConfig } from "@rsbuild/core";
2
+ import { isCI } from "./1~is-ci.js";
3
3
  function pluginRsdoctor(options) {
4
4
  return {
5
5
  name: 'lynx:rsbuild:rsdoctor',
@@ -1,3 +1,4 @@
1
+ import { isLynx } from "./1~is-lynx.js";
1
2
  var isProduction = 'production' === process.env.NODE_ENV;
2
3
  var prefix = 'Invariant failed';
3
4
  function invariant(condition, message) {
@@ -34,12 +35,13 @@ function pluginSourcemap() {
34
35
  'lynx:rsbuild:dev'
35
36
  ],
36
37
  setup (api) {
37
- api.modifyBundlerChain((chain, { isDev })=>{
38
+ api.modifyBundlerChain((chain, { isDev, environment })=>{
38
39
  const { dev, output, server } = api.getRsbuildConfig('current');
39
40
  const publicPath = isDev ? dev?.assetPrefix : output?.assetPrefix;
40
41
  if (false === publicPath) return;
41
42
  invariant('string' == typeof publicPath || void 0 === publicPath, `dev.assetPrefix should be normalized to string, got ${dev?.assetPrefix}`);
42
43
  applySourceMapPlugin(chain, getDevtoolFromSourceMap(), publicPath?.replaceAll('<port>', String(api.context.devServer?.port ?? server?.port)));
44
+ if (isLynx(environment)) applyDropSourceMapAssets(chain);
43
45
  function getDevtoolFromSourceMap() {
44
46
  const DEFAULT_DEV_DEVTOOL = 'cheap-module-source-map';
45
47
  switch(typeof output?.sourceMap){
@@ -48,13 +50,28 @@ function pluginSourcemap() {
48
50
  return false;
49
51
  case 'undefined':
50
52
  case 'object':
51
- return output?.sourceMap?.js ?? (isDev ? DEFAULT_DEV_DEVTOOL : false);
53
+ return output?.sourceMap?.js ?? (isDev ? DEFAULT_DEV_DEVTOOL : isLynx(environment) ? 'source-map' : false);
52
54
  }
53
55
  }
54
56
  });
55
57
  }
56
58
  };
57
59
  }
60
+ function applyDropSourceMapAssets(chain) {
61
+ chain.plugin('lynx:sourcemap-drop').use(class {
62
+ apply(compiler) {
63
+ const { Compilation } = compiler.webpack;
64
+ compiler.hooks.compilation.tap('LynxDropSourceMapAssetsPlugin', (compilation)=>{
65
+ compilation.hooks.processAssets.tap({
66
+ name: 'LynxDropSourceMapAssetsPlugin',
67
+ stage: Compilation.PROCESS_ASSETS_STAGE_REPORT + 1
68
+ }, ()=>{
69
+ for (const name of Object.keys(compilation.assets))if (name.endsWith('.map')) compilation.deleteAsset(name);
70
+ });
71
+ });
72
+ }
73
+ }, []);
74
+ }
58
75
  function applySourceMapPlugin(chain, devtool, publicPath) {
59
76
  if (false === devtool) return;
60
77
  const CHAIN_ID_DEV_SOURCEMAP = 'lynx:sourcemap';
@@ -1,11 +1,12 @@
1
- import { __webpack_require__ } from "./rslib-runtime.js";
1
+ import { __webpack_require__ } from "./src_cli_main_ts-node_child_process-node_events-node_fs-node_path-node_process.js";
2
+ import node_path, { extname, isAbsolute, join } from "node:path";
3
+ import { createRsbuild, mergeRsbuildConfig } from "@rsbuild/core";
4
+ import node_fs from "node:fs";
2
5
  import { pathToFileURL } from "node:url";
3
6
  import { register } from "#register";
4
- import "./1~node_path.js";
5
- import "./1~node_fs.js";
6
- import { debug, isDebug, createRsbuild, mergeRsbuildConfig, debugList } from "./src_cli_main_ts.js";
7
+ import { debug, isDebug, debugList } from "./src_cli_main_ts-node_child_process-node_events-node_fs-node_path-node_process.js";
7
8
  function applyDefaultRspeedyConfig(config) {
8
- const enableChunkSplitting = config.performance?.chunkSplit?.strategy && config.performance?.chunkSplit?.strategy !== 'all-in-one';
9
+ const enableChunkSplitting = getEnableChunkSplitting(config);
9
10
  return mergeRsbuildConfig({
10
11
  mode: (()=>{
11
12
  if (config.mode) return config.mode;
@@ -34,6 +35,11 @@ function applyDefaultRspeedyConfig(config) {
34
35
  }
35
36
  }, config);
36
37
  }
38
+ function getEnableChunkSplitting(config) {
39
+ if (void 0 !== config.splitChunks) return false !== config.splitChunks;
40
+ const strategy = config.performance?.chunkSplit?.strategy;
41
+ return Boolean(strategy && 'all-in-one' !== strategy);
42
+ }
37
43
  const DEFAULT_FILENAME = '[name].[platform].bundle';
38
44
  function getFilename(filename) {
39
45
  if ('string' == typeof filename) return {
@@ -41,6 +47,9 @@ function getFilename(filename) {
41
47
  template: filename
42
48
  };
43
49
  const finalFilename = filename?.bundle ?? filename?.template ?? DEFAULT_FILENAME;
50
+ if ('function' == typeof finalFilename) return {
51
+ bundle: finalFilename
52
+ };
44
53
  return {
45
54
  bundle: finalFilename,
46
55
  template: finalFilename
@@ -116,13 +125,12 @@ function toRsbuildConfig(config) {
116
125
  sourceMap: config.output?.sourceMap
117
126
  },
118
127
  resolve: {
119
- alias: config.resolve?.alias,
128
+ alias: toRsbuildAlias(config),
120
129
  aliasStrategy: config.resolve?.aliasStrategy,
121
130
  dedupe: config.resolve?.dedupe,
122
131
  extensions: config.resolve?.extensions
123
132
  },
124
133
  source: {
125
- alias: config.source?.alias,
126
134
  assetsInclude: config.source?.assetsInclude,
127
135
  decorators: config.source?.decorators,
128
136
  define: config.source?.define,
@@ -133,12 +141,13 @@ function toRsbuildConfig(config) {
133
141
  transformImport: config.source?.transformImport,
134
142
  tsconfigPath: config.source?.tsconfigPath
135
143
  },
144
+ splitChunks: toRsbuildSplitChunks(config),
136
145
  server: {
137
146
  base: config.server?.base,
138
147
  compress: config.server?.compress,
139
148
  cors: config.server?.cors,
140
149
  headers: config.server?.headers,
141
- host: config.server?.host,
150
+ host: config.server?.host ?? '0.0.0.0',
142
151
  port: config.server?.port,
143
152
  proxy: config.server?.proxy,
144
153
  strictPort: config.server?.strictPort
@@ -147,7 +156,6 @@ function toRsbuildConfig(config) {
147
156
  performance: {
148
157
  buildCache: config.performance?.buildCache,
149
158
  chunkSplit: config.performance?.chunkSplit,
150
- profile: config.performance?.profile,
151
159
  removeConsole: toRsbuildRemoveConsole(config),
152
160
  printFileSize: config.performance?.printFileSize ?? true
153
161
  },
@@ -173,7 +181,21 @@ function toRsbuildRemoveConsole(config) {
173
181
  ];
174
182
  return config.performance?.removeConsole;
175
183
  }
176
- const external_node_path_ = __webpack_require__("node:path");
184
+ function toRsbuildSplitChunks(config) {
185
+ if (void 0 !== config.splitChunks) return config.splitChunks;
186
+ const legacyStrategy = config.performance?.chunkSplit?.strategy;
187
+ if (legacyStrategy && 'all-in-one' !== legacyStrategy) return;
188
+ return false;
189
+ }
190
+ function toRsbuildAlias(config) {
191
+ const sourceAlias = config.source?.alias;
192
+ const resolveAlias = config.resolve?.alias;
193
+ if (void 0 === sourceAlias && void 0 === resolveAlias) return;
194
+ return {
195
+ ...resolveAlias,
196
+ ...sourceAlias
197
+ };
198
+ }
177
199
  async function createRspeedy({ cwd = process.cwd(), rspeedyConfig = {}, loadEnv = true, environment = [], callerName = 'rspeedy' }) {
178
200
  const config = applyDefaultRspeedyConfig(rspeedyConfig);
179
201
  const [rspeedy, { applyDefaultPlugins }] = await Promise.all([
@@ -184,9 +206,7 @@ async function createRspeedy({ cwd = process.cwd(), rspeedyConfig = {}, loadEnv
184
206
  environment,
185
207
  callerName
186
208
  }),
187
- import("./1~src_plugins_index_ts.js").then((mod)=>({
188
- applyDefaultPlugins: mod.applyDefaultPlugins
189
- }))
209
+ import("./1~plugins.js")
190
210
  ]);
191
211
  await applyDefaultPlugins(rspeedy, config);
192
212
  const inspectConfig = rspeedy.inspectConfig.bind(rspeedy);
@@ -194,22 +214,19 @@ async function createRspeedy({ cwd = process.cwd(), rspeedyConfig = {}, loadEnv
194
214
  getRspeedyConfig: ()=>config,
195
215
  async inspectConfig (options) {
196
216
  const result = await inspectConfig(options);
197
- const { inspectRspeedyConfig } = await import("./1~src_plugins_inspect_plugin_ts.js").then((mod)=>({
198
- inspectRspeedyConfig: mod.inspectRspeedyConfig
199
- }));
200
- await inspectRspeedyConfig(rspeedyConfig, external_node_path_["default"].resolve(options.outputPath ?? rspeedy.context.distPath, '.rsbuild/rspeedy.config.js'), options.verbose ?? false);
217
+ const { inspectRspeedyConfig } = await import("./1~inspect.plugin.js");
218
+ await inspectRspeedyConfig(rspeedyConfig, node_path.resolve(options.outputPath ?? rspeedy.context.distPath, '.rsbuild/rspeedy.config.js'), options.verbose ?? false);
201
219
  return result;
202
220
  }
203
221
  });
204
222
  }
205
- const external_node_fs_ = __webpack_require__("node:fs");
206
223
  const picocolors = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
207
224
  var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
208
225
  const resolveConfigPath = (root, customConfig)=>{
209
226
  if (customConfig) {
210
227
  debug(`load custom config file ${customConfig} from ${root}`);
211
- const customConfigPath = (0, external_node_path_.isAbsolute)(customConfig) ? customConfig : (0, external_node_path_.join)(root, customConfig);
212
- if (external_node_fs_["default"].existsSync(customConfigPath)) return customConfigPath;
228
+ const customConfigPath = isAbsolute(customConfig) ? customConfig : join(root, customConfig);
229
+ if (node_fs.existsSync(customConfigPath)) return customConfigPath;
213
230
  throw new Error(`Cannot find config file: ${picocolors_default().dim(customConfigPath)}`);
214
231
  }
215
232
  const CONFIG_FILES = [
@@ -220,20 +237,20 @@ const resolveConfigPath = (root, customConfig)=>{
220
237
  ];
221
238
  for (const file of CONFIG_FILES){
222
239
  debug(`load default config file ${file} from ${root}`);
223
- const configFile = (0, external_node_path_.join)(root, file);
224
- if (external_node_fs_["default"].existsSync(configFile)) {
240
+ const configFile = join(root, file);
241
+ if (node_fs.existsSync(configFile)) {
225
242
  debug(`default config ${configFile} found`);
226
243
  return configFile;
227
244
  }
228
245
  }
229
246
  throw new Error([
230
- `Cannot find the default config file: ${picocolors_default().dim((0, external_node_path_.join)(root, CONFIG_FILES[0]))}.`,
247
+ `Cannot find the default config file: ${picocolors_default().dim(join(root, CONFIG_FILES[0]))}.`,
231
248
  `Use custom config with ${picocolors_default().green('`--config <config>`')} options.`
232
249
  ].join(' '));
233
250
  };
234
251
  async function loadConfig(loadConfigOptions) {
235
252
  let { configPath } = loadConfigOptions;
236
- if (!configPath || !(0, external_node_path_.isAbsolute)(configPath)) configPath = resolveConfigPath(loadConfigOptions.cwd ?? process.cwd(), configPath);
253
+ if (!configPath || !isAbsolute(configPath)) configPath = resolveConfigPath(loadConfigOptions.cwd ?? process.cwd(), configPath);
237
254
  const specifier = pathToFileURL(configPath).toString();
238
255
  let unregister;
239
256
  unregister = shouldUseNativeImport(configPath) ? ()=>{} : register({
@@ -243,10 +260,7 @@ async function loadConfig(loadConfigOptions) {
243
260
  try {
244
261
  const [exports, { validate }] = await Promise.all([
245
262
  import(`${specifier}?t=${Date.now()}`),
246
- import("./1~src_config_validate_ts.js").then((mod)=>({
247
- validate: mod.validate,
248
- validateConfig: mod.validateConfig
249
- }))
263
+ import("./1~validate.js").then((m)=>m.validate_namespaceObject)
250
264
  ]);
251
265
  const configExport = 'default' in exports ? exports.default : exports;
252
266
  const rawContent = 'function' == typeof configExport ? await configExport({
@@ -273,7 +287,7 @@ function hasNativeTSSupport() {
273
287
  return NODE_OPTIONS.includes('--experimental-transform-types') || NODE_OPTIONS.includes('--experimental-strip-types');
274
288
  }
275
289
  function isJavaScriptPath(configPath) {
276
- const ext = (0, external_node_path_.extname)(configPath);
290
+ const ext = extname(configPath);
277
291
  return [
278
292
  '.js',
279
293
  '.mjs',
@@ -0,0 +1,26 @@
1
+ import { mkdir, writeFile } from "node:fs/promises";
2
+ import node_path from "node:path";
3
+ const BUNDLE_STATS_JSON_OPTIONS = {
4
+ assets: true,
5
+ chunks: true,
6
+ modules: true,
7
+ entrypoints: true,
8
+ chunkGroups: true
9
+ };
10
+ function pluginStatsJson(config) {
11
+ return {
12
+ name: 'lynx:stats-json',
13
+ setup (api) {
14
+ if (!config.performance?.profile) return;
15
+ api.onAfterBuild(async ({ stats })=>{
16
+ if (!stats) return;
17
+ const statsPath = node_path.join(api.context.distPath, 'stats.json');
18
+ await mkdir(node_path.dirname(statsPath), {
19
+ recursive: true
20
+ });
21
+ await writeFile(statsPath, JSON.stringify(stats.toJson(BUNDLE_STATS_JSON_OPTIONS), null, 2));
22
+ });
23
+ }
24
+ };
25
+ }
26
+ export { pluginStatsJson };
@@ -0,0 +1,25 @@
1
+ import { ES_ENV_TARGETS, getESVersionEnvInclude } from "./1~getESVersionTarget.js";
2
+ function pluginSwc() {
3
+ return {
4
+ name: 'lynx:rsbuild:swc',
5
+ setup (api) {
6
+ api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>mergeRsbuildConfig(config, {
7
+ tools: {
8
+ swc (config) {
9
+ if (config.jsc?.target !== void 0) throw new Error(`Rspeedy manages the SWC compilation target via \`env\`, which is mutually exclusive with \`jsc.target\`. Remove \`tools.swc.jsc.target\` (received \`${JSON.stringify(config.jsc.target)}\`). To downlevel specific syntax, add the corresponding transforms to \`tools.swc.env.include\` instead (e.g. \`[\'transform-class-properties\']\`).`);
10
+ config.env = {
11
+ ...config.env,
12
+ targets: ES_ENV_TARGETS,
13
+ include: [
14
+ 'transform-block-scoping',
15
+ ...getESVersionEnvInclude(),
16
+ ...config.env?.include ?? []
17
+ ]
18
+ };
19
+ }
20
+ }
21
+ }));
22
+ }
23
+ };
24
+ }
25
+ export { pluginSwc };
@@ -1,4 +1,4 @@
1
- import { getESVersionTarget } from "./1~src_utils_getESVersionTarget_ts.js";
1
+ import { getESVersionTarget } from "./1~getESVersionTarget.js";
2
2
  function isWeb(environment) {
3
3
  const environmentName = 'string' == typeof environment ? environment : environment.name;
4
4
  return 'web' === environmentName || environmentName.startsWith('web-');
@@ -7,13 +7,13 @@ function pluginTarget() {
7
7
  return {
8
8
  name: 'lynx:rsbuild:target',
9
9
  setup (api) {
10
- api.modifyBundlerChain((options, { environment, isProd })=>{
10
+ api.modifyBundlerChain((options, { environment })=>{
11
11
  if (isWeb(environment)) options.target([
12
- getESVersionTarget(isProd),
12
+ getESVersionTarget(),
13
13
  'web'
14
14
  ]);
15
15
  else options.target([
16
- getESVersionTarget(isProd)
16
+ getESVersionTarget()
17
17
  ]);
18
18
  });
19
19
  }