@lynx-js/rspeedy 0.10.5 → 0.10.7

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/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @lynx-js/rspeedy
2
2
 
3
+ ## 0.10.7
4
+
5
+ ### Patch Changes
6
+
7
+ - `output.inlineScripts` defaults to `false` when chunkSplit strategy is not `'all-in-one'` ([#1504](https://github.com/lynx-family/lynx-stack/pull/1504))
8
+
9
+ ## 0.10.6
10
+
11
+ ### Patch Changes
12
+
13
+ - Remove the experimental `provider` option. ([#1432](https://github.com/lynx-family/lynx-stack/pull/1432))
14
+
15
+ - Add `output.filename.wasm` and `output.filename.assets` options. ([#1449](https://github.com/lynx-family/lynx-stack/pull/1449))
16
+
17
+ - fix deno compatibility ([#1412](https://github.com/lynx-family/lynx-stack/pull/1412))
18
+
19
+ - Should call the `api.onCloseBuild` hook after the build finished. ([#1446](https://github.com/lynx-family/lynx-stack/pull/1446))
20
+
21
+ - Bump Rsbuild v1.4.15. ([#1423](https://github.com/lynx-family/lynx-stack/pull/1423))
22
+
23
+ - Support using function in `output.filename.*`. ([#1449](https://github.com/lynx-family/lynx-stack/pull/1449))
24
+
3
25
  ## 0.10.5
4
26
 
5
27
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -303,31 +303,6 @@ export declare interface ChunkSplitCustom {
303
303
  * @public
304
304
  */
305
305
  export declare interface Config {
306
- /**
307
- * The Rsbuild provider.
308
- *
309
- * @example
310
- * You can switch from Rspack to Webpack by:
311
- *
312
- * - Use `webpackProvider` from `@rsbuild/webpack`
313
- * - Add `pluginSwc` from `@rsbuild/plugin-webpack-swc` for TypeScript transpilation
314
- *
315
- * ```ts
316
- * import { defineConfig } from '@lynx-js/rspeedy'
317
- * import { webpackProvider } from '@rsbuild/webpack'
318
- * import { pluginSwc } from '@rsbuild/plugin-webpack-swc'
319
- *
320
- * export default defineConfig({
321
- * provider: webpackProvider,
322
- * plugins: [
323
- * pluginSwc(),
324
- * ],
325
- * })
326
- * ```
327
- *
328
- * @alpha
329
- */
330
- provider?: RsbuildConfig['provider'];
331
306
  /**
332
307
  * The {@link Dev} option is used to control the behavior related with development. Including: HMR, DevServer, etc.
333
308
  */
@@ -1459,8 +1434,31 @@ export declare interface Filename {
1459
1434
  *
1460
1435
  * - Development: `'[name].js'`
1461
1436
  * - Production: `'[name].[contenthash:8].js'`
1437
+ *
1438
+ * @example
1439
+ *
1440
+ * - Using a function to dynamically set the filename based on the file information:
1441
+ *
1442
+ * ```js
1443
+ * import { defineConfig } from '@lynx-js/rspeedy'
1444
+ *
1445
+ * export default defineConfig({
1446
+ * output: {
1447
+ * filename: {
1448
+ * js: (pathData, assetInfo) => {
1449
+ * console.log(pathData); // You can check the contents of pathData here
1450
+ *
1451
+ * if (pathData.chunk?.name === 'index') {
1452
+ * return isProd ? '[name].[contenthash:8].js' : '[name].js';
1453
+ * }
1454
+ * return '/some-path/[name].js';
1455
+ * },
1456
+ * },
1457
+ * },
1458
+ * })
1459
+ * ```
1462
1460
  */
1463
- js?: string | undefined;
1461
+ js?: Rspack.Filename | undefined;
1464
1462
  /**
1465
1463
  * The name of the CSS files.
1466
1464
  *
@@ -1469,8 +1467,31 @@ export declare interface Filename {
1469
1467
  * Default values:
1470
1468
  *
1471
1469
  * - `'[name].css'`
1470
+ *
1471
+ * @example
1472
+ *
1473
+ * - Using a function to dynamically set the filename based on the file information:
1474
+ *
1475
+ * ```js
1476
+ * import { defineConfig } from '@lynx-js/rspeedy'
1477
+ *
1478
+ * export default defineConfig({
1479
+ * output: {
1480
+ * filename: {
1481
+ * css: (pathData, assetInfo) => {
1482
+ * console.log(pathData); // You can check the contents of pathData here
1483
+ *
1484
+ * if (pathData.chunk?.name === 'index') {
1485
+ * return isProd ? '[name].[contenthash:8].css' : '[name].css';
1486
+ * }
1487
+ * return '/some-path/[name].css';
1488
+ * },
1489
+ * },
1490
+ * },
1491
+ * })
1492
+ * ```
1472
1493
  */
1473
- css?: string | undefined;
1494
+ css?: Rspack.CssFilename | undefined;
1474
1495
  /**
1475
1496
  * The name of the SVG images.
1476
1497
  *
@@ -1480,7 +1501,7 @@ export declare interface Filename {
1480
1501
  *
1481
1502
  * - `'[name].[contenthash:8].svg'`
1482
1503
  */
1483
- svg?: string | undefined;
1504
+ svg?: Rspack.AssetModuleFilename | undefined;
1484
1505
  /**
1485
1506
  * The name of the font files.
1486
1507
  *
@@ -1490,7 +1511,7 @@ export declare interface Filename {
1490
1511
  *
1491
1512
  * - `'[name].[contenthash:8][ext]'`
1492
1513
  */
1493
- font?: string | undefined;
1514
+ font?: Rspack.AssetModuleFilename | undefined;
1494
1515
  /**
1495
1516
  * The name of non-SVG images.
1496
1517
  *
@@ -1500,7 +1521,7 @@ export declare interface Filename {
1500
1521
  *
1501
1522
  * - `'[name].[contenthash:8][ext]'`
1502
1523
  */
1503
- image?: string | undefined;
1524
+ image?: Rspack.AssetModuleFilename | undefined;
1504
1525
  /**
1505
1526
  * The name of media assets, such as video.
1506
1527
  *
@@ -1510,7 +1531,27 @@ export declare interface Filename {
1510
1531
  *
1511
1532
  * - `'[name].[contenthash:8][ext]'`
1512
1533
  */
1513
- media?: string | undefined;
1534
+ media?: Rspack.AssetModuleFilename | undefined;
1535
+ /**
1536
+ * The name of WebAssembly files.
1537
+ *
1538
+ * @remarks
1539
+ *
1540
+ * Default values:
1541
+ *
1542
+ * - `'[hash].module.wasm'`
1543
+ */
1544
+ wasm?: Rspack.WebassemblyModuleFilename;
1545
+ /**
1546
+ * The name of other assets, except for above (image, svg, font, html, wasm...)
1547
+ *
1548
+ * @remarks
1549
+ *
1550
+ * Default values:
1551
+ *
1552
+ * - `'[name].[contenthash:8][ext]'`
1553
+ */
1554
+ assets?: Rspack.AssetModuleFilename;
1514
1555
  }
1515
1556
 
1516
1557
  /**
package/dist/index.js CHANGED
@@ -112,7 +112,7 @@ var __webpack_modules__ = {
112
112
  });
113
113
  var core_ = __webpack_require__("@rsbuild/core");
114
114
  var package_namespaceObject = {
115
- i8: "0.10.5"
115
+ i8: "0.10.7"
116
116
  };
117
117
  const version = package_namespaceObject.i8;
118
118
  const rspackVersion = core_.rspack.rspackVersion;
@@ -255,6 +255,7 @@ var external_node_path_ = __webpack_require__("node:path");
255
255
  var core_ = __webpack_require__("@rsbuild/core");
256
256
  var debug = __webpack_require__("./src/debug.ts");
257
257
  function applyDefaultRspeedyConfig(config) {
258
+ const enableChunkSplitting = config.performance?.chunkSplit?.strategy && config.performance?.chunkSplit?.strategy !== 'all-in-one';
258
259
  return (0, core_.mergeRsbuildConfig)({
259
260
  mode: (()=>{
260
261
  if (config.mode) return config.mode;
@@ -263,7 +264,7 @@ function applyDefaultRspeedyConfig(config) {
263
264
  })(),
264
265
  output: {
265
266
  filename: getFilename(config.output?.filename),
266
- inlineScripts: true
267
+ inlineScripts: !enableChunkSplitting
267
268
  },
268
269
  performance: {
269
270
  profile: (0, debug.L1)() ? true : void 0
@@ -332,7 +333,6 @@ function toRsbuildEntry(entry) {
332
333
  const defaultDataUriLimit = 2048;
333
334
  function toRsbuildConfig(config) {
334
335
  return {
335
- provider: config.provider,
336
336
  dev: {
337
337
  watchFiles: config.dev?.watchFiles,
338
338
  writeToDisk: config.dev?.writeToDisk ?? true,
@@ -472,8 +472,9 @@ async function loadConfig(loadConfigOptions) {
472
472
  let { configPath } = loadConfigOptions;
473
473
  if (!configPath || !(0, external_node_path_.isAbsolute)(configPath)) configPath = resolveConfigPath(loadConfigOptions.cwd ?? process.cwd(), configPath);
474
474
  const specifier = pathToFileURL(configPath).toString();
475
- const unregister = register({
476
- load: !shouldUseNativeImport(configPath),
475
+ let unregister;
476
+ unregister = shouldUseNativeImport(configPath) ? ()=>{} : register({
477
+ load: !hasNativeTSSupport(),
477
478
  resolve: true
478
479
  });
479
480
  try {
@@ -491,9 +492,10 @@ async function loadConfig(loadConfigOptions) {
491
492
  }
492
493
  }
493
494
  function shouldUseNativeImport(configPath) {
494
- return isJavaScriptPath(configPath) || hasNativeTSSupport();
495
+ return isJavaScriptPath(configPath) || isDeno();
495
496
  }
496
497
  function hasNativeTSSupport() {
498
+ if (isDeno()) return true;
497
499
  if (process.features.typescript) return true;
498
500
  if (false === process.features.typescript) return false;
499
501
  const { NODE_OPTIONS } = process.env;
@@ -508,6 +510,10 @@ function isJavaScriptPath(configPath) {
508
510
  '.cjs'
509
511
  ].includes(ext);
510
512
  }
513
+ function isDeno() {
514
+ if ('undefined' != typeof Deno || process.versions?.deno) return true;
515
+ return false;
516
+ }
511
517
  var version = __webpack_require__("./src/version.ts");
512
518
  var __webpack_exports__logger = core_.logger;
513
519
  var __webpack_exports__rsbuildVersion = version.Q0;
@@ -17,7 +17,8 @@ export const __webpack_modules__ = {
17
17
  try {
18
18
  const { createRspeedyOptions } = await (0, _init_js__WEBPACK_IMPORTED_MODULE_3__.S)(cwd, buildOptions);
19
19
  const rspeedy = await (0, _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_2__.S)(createRspeedyOptions);
20
- await rspeedy.build();
20
+ const { close } = await rspeedy.build();
21
+ await close();
21
22
  } catch (error) {
22
23
  _rsbuild_core__WEBPACK_IMPORTED_MODULE_0__.logger.error(error);
23
24
  if (shouldExit) return void (0, _exit_js__WEBPACK_IMPORTED_MODULE_1__.exit)(1);
@@ -66,8 +67,9 @@ export const __webpack_modules__ = {
66
67
  let { configPath } = loadConfigOptions;
67
68
  if (!configPath || !(0, external_node_path_.isAbsolute)(configPath)) configPath = resolveConfigPath(loadConfigOptions.cwd ?? process.cwd(), configPath);
68
69
  const specifier = (0, external_node_url_.pathToFileURL)(configPath).toString();
69
- const unregister = (0, register_.register)({
70
- load: !shouldUseNativeImport(configPath),
70
+ let unregister;
71
+ unregister = shouldUseNativeImport(configPath) ? ()=>{} : (0, register_.register)({
72
+ load: !hasNativeTSSupport(),
71
73
  resolve: true
72
74
  });
73
75
  try {
@@ -85,9 +87,10 @@ export const __webpack_modules__ = {
85
87
  }
86
88
  }
87
89
  function shouldUseNativeImport(configPath) {
88
- return isJavaScriptPath(configPath) || hasNativeTSSupport();
90
+ return isJavaScriptPath(configPath) || isDeno();
89
91
  }
90
92
  function hasNativeTSSupport() {
93
+ if (isDeno()) return true;
91
94
  if (process.features.typescript) return true;
92
95
  if (false === process.features.typescript) return false;
93
96
  const { NODE_OPTIONS } = process.env;
@@ -102,6 +105,10 @@ export const __webpack_modules__ = {
102
105
  '.cjs'
103
106
  ].includes(ext);
104
107
  }
108
+ function isDeno() {
109
+ if ('undefined' != typeof Deno || process.versions?.deno) return true;
110
+ return false;
111
+ }
105
112
  async function init(cwd, options) {
106
113
  const { content: rspeedyConfig, configPath } = await loadConfig({
107
114
  cwd,
@@ -145,6 +152,7 @@ export const __webpack_modules__ = {
145
152
  var core_ = __webpack_require__("@rsbuild/core");
146
153
  var debug = __webpack_require__("./src/debug.ts");
147
154
  function applyDefaultRspeedyConfig(config) {
155
+ const enableChunkSplitting = config.performance?.chunkSplit?.strategy && config.performance?.chunkSplit?.strategy !== 'all-in-one';
148
156
  return (0, core_.mergeRsbuildConfig)({
149
157
  mode: (()=>{
150
158
  if (config.mode) return config.mode;
@@ -153,7 +161,7 @@ export const __webpack_modules__ = {
153
161
  })(),
154
162
  output: {
155
163
  filename: getFilename(config.output?.filename),
156
- inlineScripts: true
164
+ inlineScripts: !enableChunkSplitting
157
165
  },
158
166
  performance: {
159
167
  profile: (0, debug.L1)() ? true : void 0
@@ -222,7 +230,6 @@ export const __webpack_modules__ = {
222
230
  const defaultDataUriLimit = 2048;
223
231
  function toRsbuildConfig(config) {
224
232
  return {
225
- provider: config.provider,
226
233
  dev: {
227
234
  watchFiles: config.dev?.watchFiles,
228
235
  writeToDisk: config.dev?.writeToDisk ?? true,
@@ -40,7 +40,7 @@ export const __webpack_modules__ = {
40
40
  });
41
41
  var core_ = __webpack_require__("@rsbuild/core");
42
42
  var package_namespaceObject = {
43
- i8: "0.10.5"
43
+ i8: "0.10.7"
44
44
  };
45
45
  const version = package_namespaceObject.i8;
46
46
  const rspackVersion = core_.rspack.rspackVersion;
@@ -109,8 +109,9 @@ export const __webpack_modules__ = {
109
109
  let { configPath } = loadConfigOptions;
110
110
  if (!configPath || !(0, external_node_path_.isAbsolute)(configPath)) configPath = resolveConfigPath(loadConfigOptions.cwd ?? process.cwd(), configPath);
111
111
  const specifier = (0, external_node_url_.pathToFileURL)(configPath).toString();
112
- const unregister = (0, register_.register)({
113
- load: !shouldUseNativeImport(configPath),
112
+ let unregister;
113
+ unregister = shouldUseNativeImport(configPath) ? ()=>{} : (0, register_.register)({
114
+ load: !hasNativeTSSupport(),
114
115
  resolve: true
115
116
  });
116
117
  try {
@@ -128,9 +129,10 @@ export const __webpack_modules__ = {
128
129
  }
129
130
  }
130
131
  function shouldUseNativeImport(configPath) {
131
- return isJavaScriptPath(configPath) || hasNativeTSSupport();
132
+ return isJavaScriptPath(configPath) || isDeno();
132
133
  }
133
134
  function hasNativeTSSupport() {
135
+ if (isDeno()) return true;
134
136
  if (process.features.typescript) return true;
135
137
  if (false === process.features.typescript) return false;
136
138
  const { NODE_OPTIONS } = process.env;
@@ -145,6 +147,10 @@ export const __webpack_modules__ = {
145
147
  '.cjs'
146
148
  ].includes(ext);
147
149
  }
150
+ function isDeno() {
151
+ if ('undefined' != typeof Deno || process.versions?.deno) return true;
152
+ return false;
153
+ }
148
154
  async function init(cwd, options) {
149
155
  const { content: rspeedyConfig, configPath } = await loadConfig({
150
156
  cwd,
@@ -188,6 +194,7 @@ export const __webpack_modules__ = {
188
194
  var core_ = __webpack_require__("@rsbuild/core");
189
195
  var debug = __webpack_require__("./src/debug.ts");
190
196
  function applyDefaultRspeedyConfig(config) {
197
+ const enableChunkSplitting = config.performance?.chunkSplit?.strategy && config.performance?.chunkSplit?.strategy !== 'all-in-one';
191
198
  return (0, core_.mergeRsbuildConfig)({
192
199
  mode: (()=>{
193
200
  if (config.mode) return config.mode;
@@ -196,7 +203,7 @@ export const __webpack_modules__ = {
196
203
  })(),
197
204
  output: {
198
205
  filename: getFilename(config.output?.filename),
199
- inlineScripts: true
206
+ inlineScripts: !enableChunkSplitting
200
207
  },
201
208
  performance: {
202
209
  profile: (0, debug.L1)() ? true : void 0
@@ -265,7 +272,6 @@ export const __webpack_modules__ = {
265
272
  const defaultDataUriLimit = 2048;
266
273
  function toRsbuildConfig(config) {
267
274
  return {
268
- provider: config.provider,
269
275
  dev: {
270
276
  watchFiles: config.dev?.watchFiles,
271
277
  writeToDisk: config.dev?.writeToDisk ?? true,
@@ -43,8 +43,9 @@ export const __webpack_modules__ = {
43
43
  let { configPath } = loadConfigOptions;
44
44
  if (!configPath || !(0, external_node_path_.isAbsolute)(configPath)) configPath = resolveConfigPath(loadConfigOptions.cwd ?? process.cwd(), configPath);
45
45
  const specifier = (0, external_node_url_.pathToFileURL)(configPath).toString();
46
- const unregister = (0, register_.register)({
47
- load: !shouldUseNativeImport(configPath),
46
+ let unregister;
47
+ unregister = shouldUseNativeImport(configPath) ? ()=>{} : (0, register_.register)({
48
+ load: !hasNativeTSSupport(),
48
49
  resolve: true
49
50
  });
50
51
  try {
@@ -62,9 +63,10 @@ export const __webpack_modules__ = {
62
63
  }
63
64
  }
64
65
  function shouldUseNativeImport(configPath) {
65
- return isJavaScriptPath(configPath) || hasNativeTSSupport();
66
+ return isJavaScriptPath(configPath) || isDeno();
66
67
  }
67
68
  function hasNativeTSSupport() {
69
+ if (isDeno()) return true;
68
70
  if (process.features.typescript) return true;
69
71
  if (false === process.features.typescript) return false;
70
72
  const { NODE_OPTIONS } = process.env;
@@ -79,6 +81,10 @@ export const __webpack_modules__ = {
79
81
  '.cjs'
80
82
  ].includes(ext);
81
83
  }
84
+ function isDeno() {
85
+ if ('undefined' != typeof Deno || process.versions?.deno) return true;
86
+ return false;
87
+ }
82
88
  async function init(cwd, options) {
83
89
  const { content: rspeedyConfig, configPath } = await loadConfig({
84
90
  cwd,
@@ -148,6 +154,7 @@ export const __webpack_modules__ = {
148
154
  var core_ = __webpack_require__("@rsbuild/core");
149
155
  var debug = __webpack_require__("./src/debug.ts");
150
156
  function applyDefaultRspeedyConfig(config) {
157
+ const enableChunkSplitting = config.performance?.chunkSplit?.strategy && config.performance?.chunkSplit?.strategy !== 'all-in-one';
151
158
  return (0, core_.mergeRsbuildConfig)({
152
159
  mode: (()=>{
153
160
  if (config.mode) return config.mode;
@@ -156,7 +163,7 @@ export const __webpack_modules__ = {
156
163
  })(),
157
164
  output: {
158
165
  filename: getFilename(config.output?.filename),
159
- inlineScripts: true
166
+ inlineScripts: !enableChunkSplitting
160
167
  },
161
168
  performance: {
162
169
  profile: (0, debug.L1)() ? true : void 0
@@ -225,7 +232,6 @@ export const __webpack_modules__ = {
225
232
  const defaultDataUriLimit = 2048;
226
233
  function toRsbuildConfig(config) {
227
234
  return {
228
- provider: config.provider,
229
235
  dev: {
230
236
  watchFiles: config.dev?.watchFiles,
231
237
  writeToDisk: config.dev?.writeToDisk ?? true,
@@ -43,8 +43,9 @@ export const __webpack_modules__ = {
43
43
  let { configPath } = loadConfigOptions;
44
44
  if (!configPath || !(0, external_node_path_.isAbsolute)(configPath)) configPath = resolveConfigPath(loadConfigOptions.cwd ?? process.cwd(), configPath);
45
45
  const specifier = (0, external_node_url_.pathToFileURL)(configPath).toString();
46
- const unregister = (0, register_.register)({
47
- load: !shouldUseNativeImport(configPath),
46
+ let unregister;
47
+ unregister = shouldUseNativeImport(configPath) ? ()=>{} : (0, register_.register)({
48
+ load: !hasNativeTSSupport(),
48
49
  resolve: true
49
50
  });
50
51
  try {
@@ -62,9 +63,10 @@ export const __webpack_modules__ = {
62
63
  }
63
64
  }
64
65
  function shouldUseNativeImport(configPath) {
65
- return isJavaScriptPath(configPath) || hasNativeTSSupport();
66
+ return isJavaScriptPath(configPath) || isDeno();
66
67
  }
67
68
  function hasNativeTSSupport() {
69
+ if (isDeno()) return true;
68
70
  if (process.features.typescript) return true;
69
71
  if (false === process.features.typescript) return false;
70
72
  const { NODE_OPTIONS } = process.env;
@@ -79,6 +81,10 @@ export const __webpack_modules__ = {
79
81
  '.cjs'
80
82
  ].includes(ext);
81
83
  }
84
+ function isDeno() {
85
+ if ('undefined' != typeof Deno || process.versions?.deno) return true;
86
+ return false;
87
+ }
82
88
  async function init(cwd, options) {
83
89
  const { content: rspeedyConfig, configPath } = await loadConfig({
84
90
  cwd,
@@ -150,6 +156,7 @@ export const __webpack_modules__ = {
150
156
  var core_ = __webpack_require__("@rsbuild/core");
151
157
  var debug = __webpack_require__("./src/debug.ts");
152
158
  function applyDefaultRspeedyConfig(config) {
159
+ const enableChunkSplitting = config.performance?.chunkSplit?.strategy && config.performance?.chunkSplit?.strategy !== 'all-in-one';
153
160
  return (0, core_.mergeRsbuildConfig)({
154
161
  mode: (()=>{
155
162
  if (config.mode) return config.mode;
@@ -158,7 +165,7 @@ export const __webpack_modules__ = {
158
165
  })(),
159
166
  output: {
160
167
  filename: getFilename(config.output?.filename),
161
- inlineScripts: true
168
+ inlineScripts: !enableChunkSplitting
162
169
  },
163
170
  performance: {
164
171
  profile: (0, debug.L1)() ? true : void 0
@@ -227,7 +234,6 @@ export const __webpack_modules__ = {
227
234
  const defaultDataUriLimit = 2048;
228
235
  function toRsbuildConfig(config) {
229
236
  return {
230
- provider: config.provider,
231
237
  dev: {
232
238
  watchFiles: config.dev?.watchFiles,
233
239
  writeToDisk: config.dev?.writeToDisk ?? true,