@lynx-js/rspeedy-canary 0.10.4 → 0.10.5-canary-20250803-d2b124c1

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,11 @@
1
1
  # @lynx-js/rspeedy
2
2
 
3
+ ## 0.10.5-canary-20250803093757-d2b124c1ce2f196f850b1f0d9f001e86011f4e06
4
+
5
+ ### Patch Changes
6
+
7
+ - Should support using `.js` extensions when loading configuration with Node.js [builtin type stripping](https://nodejs.org/api/typescript.html#type-stripping). ([#1407](https://github.com/lynx-family/lynx-stack/pull/1407))
8
+
3
9
  ## 0.10.4
4
10
 
5
11
  ### Patch Changes
@@ -49,28 +55,28 @@
49
55
 
50
56
  ```ts
51
57
  type InlineChunkTestFunction = (params: {
52
- size: number
53
- name: string
54
- }) => boolean
58
+ size: number;
59
+ name: string;
60
+ }) => boolean;
55
61
 
56
- type InlineChunkTest = RegExp | InlineChunkTestFunction
62
+ type InlineChunkTest = RegExp | InlineChunkTestFunction;
57
63
 
58
64
  type InlineChunkConfig =
59
65
  | boolean
60
66
  | InlineChunkTest
61
- | { enable?: boolean | 'auto', test: InlineChunkTest }
67
+ | { enable?: boolean | "auto"; test: InlineChunkTest };
62
68
  ```
63
69
 
64
70
  ```ts
65
- import { defineConfig } from '@lynx-js/rspeedy'
71
+ import { defineConfig } from "@lynx-js/rspeedy";
66
72
 
67
73
  export default defineConfig({
68
74
  output: {
69
75
  inlineScripts: ({ name, size }) => {
70
- return name.includes('foo') && size < 1000
76
+ return name.includes("foo") && size < 1000;
71
77
  },
72
78
  },
73
- })
79
+ });
74
80
  ```
75
81
 
76
82
  - docs: remove chunks: 'all' in comments ([#1168](https://github.com/lynx-family/lynx-stack/pull/1168))
@@ -113,13 +119,13 @@
113
119
  example:
114
120
 
115
121
  ```js
116
- import { defineConfig } from '@lynx-js/rspeedy'
122
+ import { defineConfig } from "@lynx-js/rspeedy";
117
123
 
118
124
  export default defineConfig({
119
125
  output: {
120
126
  inlineScripts: false,
121
127
  },
122
- })
128
+ });
123
129
  ```
124
130
 
125
131
  - Bump Rsbuild v1.3.21 with Rspack v1.3.11. ([#863](https://github.com/lynx-family/lynx-stack/pull/863))
@@ -139,12 +145,12 @@
139
145
  example:
140
146
 
141
147
  ```js
142
- import { defineConfig } from '@lynx-js/rspeedy'
148
+ import { defineConfig } from "@lynx-js/rspeedy";
143
149
  export default defineConfig({
144
150
  source: {
145
- preEntry: './src/polyfill.ts',
151
+ preEntry: "./src/polyfill.ts",
146
152
  },
147
- })
153
+ });
148
154
  ```
149
155
 
150
156
  - Bump Rsbuild v1.3.20 with Rspack v1.3.10. ([#799](https://github.com/lynx-family/lynx-stack/pull/799))
@@ -155,17 +161,17 @@
155
161
 
156
162
  ```js
157
163
  export const myPlugin = {
158
- name: 'my-plugin',
164
+ name: "my-plugin",
159
165
  setup(api) {
160
- const { callerName } = api.context
166
+ const { callerName } = api.context;
161
167
 
162
- if (callerName === 'rslib') {
168
+ if (callerName === "rslib") {
163
169
  // ...
164
- } else if (callerName === 'rspeedy') {
170
+ } else if (callerName === "rspeedy") {
165
171
  // ...
166
172
  }
167
173
  },
168
- }
174
+ };
169
175
  ```
170
176
 
171
177
  - Support `performance.buildCache`. ([#766](https://github.com/lynx-family/lynx-stack/pull/766))
@@ -188,7 +194,7 @@
188
194
  Set `tools.rsdoctor.experiments.enableNativePlugin` to `false` to use the old JS plugin.
189
195
 
190
196
  ```js
191
- import { defineConfig } from '@lynx-js/rspeedy'
197
+ import { defineConfig } from "@lynx-js/rspeedy";
192
198
 
193
199
  export default defineConfig({
194
200
  tools: {
@@ -198,7 +204,7 @@
198
204
  },
199
205
  },
200
206
  },
201
- })
207
+ });
202
208
  ```
203
209
 
204
210
  See [Rsdoctor - 1.0](https://rsdoctor.dev/blog/release/release-note-1_0#-faster-analysis) for more details.
@@ -330,12 +336,12 @@
330
336
  example:
331
337
 
332
338
  ```js
333
- import { defineConfig } from '@lynx-js/rspeedy'
339
+ import { defineConfig } from "@lynx-js/rspeedy";
334
340
  export default defineConfig({
335
341
  server: {
336
- base: '/dist',
342
+ base: "/dist",
337
343
  },
338
- })
344
+ });
339
345
  ```
340
346
 
341
347
  - Updated dependencies [[`b026c8b`](https://github.com/lynx-family/lynx-stack/commit/b026c8bdcbf7bdcda73e170477297213b447d876)]:
@@ -388,11 +394,11 @@
388
394
  You can switch to other tools by using:
389
395
 
390
396
  ```js
391
- import { defineConfig } from '@lynx-js/rspeedy'
397
+ import { defineConfig } from "@lynx-js/rspeedy";
392
398
  import {
393
399
  CssMinimizerWebpackPlugin,
394
400
  pluginCssMinimizer,
395
- } from '@rsbuild/plugin-css-minimizer'
401
+ } from "@rsbuild/plugin-css-minimizer";
396
402
 
397
403
  export default defineConfig({
398
404
  plugins: [
@@ -405,7 +411,7 @@
405
411
  },
406
412
  }),
407
413
  ],
408
- })
414
+ });
409
415
  ```
410
416
 
411
417
  See [@rsbuild/plugin-css-minimizer](https://github.com/rspack-contrib/rsbuild-plugin-css-minimizer) for details.
@@ -415,8 +421,8 @@
415
421
  You can use custom options with [@rsbuild/plugin-css-minimizer](https://github.com/rspack-contrib/rsbuild-plugin-css-minimizer):
416
422
 
417
423
  ```js
418
- import { defineConfig } from '@lynx-js/rspeedy'
419
- import { pluginCssMinimizer } from '@rsbuild/plugin-css-minimizer'
424
+ import { defineConfig } from "@lynx-js/rspeedy";
425
+ import { pluginCssMinimizer } from "@rsbuild/plugin-css-minimizer";
420
426
 
421
427
  export default defineConfig({
422
428
  plugins: [
@@ -428,7 +434,7 @@
428
434
  },
429
435
  }),
430
436
  ],
431
- })
437
+ });
432
438
  ```
433
439
 
434
440
  ## 0.7.1
@@ -448,7 +454,7 @@
448
454
  You may turn it off using `output.minify.css: false`:
449
455
 
450
456
  ```js
451
- import { defineConfig } from '@lynx-js/rspeedy'
457
+ import { defineConfig } from "@lynx-js/rspeedy";
452
458
 
453
459
  export default defineConfig({
454
460
  output: {
@@ -456,18 +462,18 @@
456
462
  css: false,
457
463
  },
458
464
  },
459
- })
465
+ });
460
466
  ```
461
467
 
462
468
  Or you may use [@rsbuild/plugin-css-minimizer](https://github.com/rspack-contrib/rsbuild-plugin-css-minimizer) to use `cssnano` as CSS minimizer.
463
469
 
464
470
  ```js
465
- import { defineConfig } from '@lynx-js/rspeedy'
466
- import { pluginCssMinimizer } from '@rsbuild/plugin-css-minimizer'
471
+ import { defineConfig } from "@lynx-js/rspeedy";
472
+ import { pluginCssMinimizer } from "@rsbuild/plugin-css-minimizer";
467
473
 
468
474
  export default defineConfig({
469
475
  plugins: [pluginCssMinimizer()],
470
- })
476
+ });
471
477
  ```
472
478
 
473
479
  - 525554c: **BREAKING CHANGE**: Bump ts-blank-space to ^0.6.0.
@@ -494,22 +500,22 @@
494
500
  - The new `type: 'reload-server'` will restart the development server when it detects changes in the specified files.
495
501
 
496
502
  ```js
497
- import { defineConfig } from '@lynx-js/rspeedy'
503
+ import { defineConfig } from "@lynx-js/rspeedy";
498
504
 
499
505
  export default defineConfig({
500
506
  dev: {
501
507
  watchFiles: [
502
508
  {
503
- type: 'reload-server',
504
- paths: ['public/**/*.txt'],
509
+ type: "reload-server",
510
+ paths: ["public/**/*.txt"],
505
511
  },
506
512
  {
507
- type: 'reload-page',
508
- paths: ['public/**/*.json'],
513
+ type: "reload-page",
514
+ paths: ["public/**/*.json"],
509
515
  },
510
516
  ],
511
517
  },
512
- })
518
+ });
513
519
  ```
514
520
 
515
521
  - be9b003: Add `source.exclude`.
package/dist/index.js CHANGED
@@ -472,7 +472,10 @@ 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 = shouldUseNativeImport(configPath) ? ()=>void 0 : register();
475
+ const unregister = register({
476
+ load: !shouldUseNativeImport(configPath),
477
+ resolve: true
478
+ });
476
479
  try {
477
480
  const [exports, { validate }] = await Promise.all([
478
481
  import(`${specifier}?t=${Date.now()}`),
@@ -503,13 +503,16 @@ function getClosingParenthesisPos(node) {
503
503
  }
504
504
  const state = {
505
505
  active: true,
506
- port: null
506
+ port: null,
507
+ options: null
507
508
  };
508
509
  const hooks_initialize = function(data) {
510
+ state.options = data.options;
509
511
  state.port = data.port;
510
512
  data.port.on('message', onMessage);
511
513
  };
512
514
  const hooks_resolve = async function(specifier, context, nextResolve) {
515
+ if (!state.options?.resolve) return nextResolve(specifier, context);
513
516
  try {
514
517
  return await nextResolve(specifier, context);
515
518
  } catch (err) {
@@ -521,6 +524,7 @@ const hooks_resolve = async function(specifier, context, nextResolve) {
521
524
  }
522
525
  };
523
526
  const hooks_load = async function(url, context, nextLoad) {
527
+ if (!state.options?.load) return nextLoad(url, context);
524
528
  const fullURL = parseURL(url);
525
529
  if (!fullURL) return nextLoad(url, context);
526
530
  const { pathname } = fullURL;
@@ -1,4 +1,7 @@
1
1
  // Copyright 2024 The Lynx Authors. All rights reserved.
2
2
  // Licensed under the Apache License Version 2.0 that can be found in the
3
3
  // LICENSE file in the root directory of this source tree.
4
- export function register(): () => void
4
+
5
+ import type { Options } from './data.js'
6
+
7
+ export function register(options: Options): () => void
@@ -1,5 +1,5 @@
1
1
  import node_module from "node:module";
2
- function register() {
2
+ function register(options) {
3
3
  if (!node_module.register) throw new Error([
4
4
  `This version of Node.js (${process.version}) does not support module.register(). You can either:`,
5
5
  " - Upgrade to Node.js v18.19 or v20.6 and above",
@@ -9,6 +9,7 @@ function register() {
9
9
  node_module.register(`./hooks.js?${Date.now()}`, import.meta.url, {
10
10
  parentURL: import.meta.url,
11
11
  data: {
12
+ options,
12
13
  port: port2
13
14
  },
14
15
  transferList: [
@@ -66,7 +66,10 @@ export const __webpack_modules__ = {
66
66
  let { configPath } = loadConfigOptions;
67
67
  if (!configPath || !(0, external_node_path_.isAbsolute)(configPath)) configPath = resolveConfigPath(loadConfigOptions.cwd ?? process.cwd(), configPath);
68
68
  const specifier = (0, external_node_url_.pathToFileURL)(configPath).toString();
69
- const unregister = shouldUseNativeImport(configPath) ? ()=>void 0 : (0, register_.register)();
69
+ const unregister = (0, register_.register)({
70
+ load: !shouldUseNativeImport(configPath),
71
+ resolve: true
72
+ });
70
73
  try {
71
74
  const [exports, { validate }] = await Promise.all([
72
75
  import(`${specifier}?t=${Date.now()}`),
@@ -109,7 +109,10 @@ 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 = shouldUseNativeImport(configPath) ? ()=>void 0 : (0, register_.register)();
112
+ const unregister = (0, register_.register)({
113
+ load: !shouldUseNativeImport(configPath),
114
+ resolve: true
115
+ });
113
116
  try {
114
117
  const [exports, { validate }] = await Promise.all([
115
118
  import(`${specifier}?t=${Date.now()}`),
@@ -43,7 +43,10 @@ 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 = shouldUseNativeImport(configPath) ? ()=>void 0 : (0, register_.register)();
46
+ const unregister = (0, register_.register)({
47
+ load: !shouldUseNativeImport(configPath),
48
+ resolve: true
49
+ });
47
50
  try {
48
51
  const [exports, { validate }] = await Promise.all([
49
52
  import(`${specifier}?t=${Date.now()}`),
@@ -43,7 +43,10 @@ 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 = shouldUseNativeImport(configPath) ? ()=>void 0 : (0, register_.register)();
46
+ const unregister = (0, register_.register)({
47
+ load: !shouldUseNativeImport(configPath),
48
+ resolve: true
49
+ });
47
50
  try {
48
51
  const [exports, { validate }] = await Promise.all([
49
52
  import(`${specifier}?t=${Date.now()}`),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/rspeedy-canary",
3
- "version": "0.10.4",
3
+ "version": "0.10.5-canary-20250803-d2b124c1",
4
4
  "description": "A webpack/rspack-based frontend toolchain for Lynx",
5
5
  "keywords": [
6
6
  "webpack",