@lynx-js/rspeedy 0.8.6 → 0.9.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 (159) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/bin/rspeedy.js +2 -2
  3. package/dist/cli/main.js +414 -0
  4. package/dist/cli/start.js +171 -0
  5. package/dist/index.d.ts +2971 -0
  6. package/dist/index.js +39472 -0
  7. package/dist/register/hooks.js +552 -0
  8. package/dist/register/index.js +22 -0
  9. package/dist/src_cli_build_ts.js +47 -0
  10. package/dist/src_cli_commands_ts.js +60 -0
  11. package/dist/src_cli_dev_ts.js +87 -0
  12. package/dist/src_cli_exit_ts.js +111 -0
  13. package/dist/src_cli_inspect_ts.js +42 -0
  14. package/dist/src_cli_preview_ts.js +49 -0
  15. package/dist/src_config_loadConfig_ts-src_create-rspeedy_ts.js +39227 -0
  16. package/dist/src_plugins_api_plugin_ts.js +32 -0
  17. package/dist/src_plugins_chunkLoading_plugin_ts.js +35 -0
  18. package/dist/src_plugins_dev_plugin_ts.js +141 -0
  19. package/dist/src_plugins_index_ts.js +60 -0
  20. package/dist/src_plugins_inspect_plugin_ts.js +48 -0
  21. package/dist/src_plugins_minify_plugin_ts.js +85 -0
  22. package/dist/src_plugins_optimization_plugin_ts.js +25 -0
  23. package/dist/src_plugins_output_plugin_ts.js +46 -0
  24. package/dist/src_plugins_resolve_plugin_ts.js +21 -0
  25. package/dist/src_plugins_rsdoctor_plugin_ts.js +59 -0
  26. package/dist/src_plugins_sourcemap_plugin_ts.js +99 -0
  27. package/dist/src_plugins_stats_plugin_ts.js +26 -0
  28. package/dist/src_plugins_swc_plugin_ts.js +36 -0
  29. package/dist/src_plugins_target_plugin_ts.js +45 -0
  30. package/dist/src_version_ts.js +18 -0
  31. package/dist/vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js +1435 -0
  32. package/dist/vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js.LICENSE.txt +1 -0
  33. package/dist/vendors-node_modules_pnpm_commander_13_1_0_node_modules_commander_esm_mjs.js +1761 -0
  34. package/dist/vendors-node_modules_pnpm_ipaddr_js_2_2_0_node_modules_ipaddr_js_lib_ipaddr_js.js +1067 -0
  35. package/dist/vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-b558be.js +416 -0
  36. package/package.json +37 -24
  37. package/LICENSE +0 -202
  38. package/lib/api.d.ts +0 -46
  39. package/lib/api.js +0 -2
  40. package/lib/cli/build.d.ts +0 -4
  41. package/lib/cli/build.js +0 -32
  42. package/lib/cli/commands.d.ts +0 -5
  43. package/lib/cli/commands.js +0 -45
  44. package/lib/cli/dev.d.ts +0 -4
  45. package/lib/cli/dev.js +0 -75
  46. package/lib/cli/exit.d.ts +0 -1
  47. package/lib/cli/exit.js +0 -51
  48. package/lib/cli/inspect.d.ts +0 -8
  49. package/lib/cli/inspect.js +0 -30
  50. package/lib/cli/main.d.ts +0 -1
  51. package/lib/cli/main.js +0 -39
  52. package/lib/cli/preview.d.ts +0 -4
  53. package/lib/cli/preview.js +0 -31
  54. package/lib/cli/start.d.ts +0 -6
  55. package/lib/cli/start.js +0 -88
  56. package/lib/config/defaults.d.ts +0 -2
  57. package/lib/config/defaults.js +0 -32
  58. package/lib/config/defineConfig.d.ts +0 -22
  59. package/lib/config/defineConfig.js +0 -24
  60. package/lib/config/dev/client.d.ts +0 -15
  61. package/lib/config/dev/client.js +0 -2
  62. package/lib/config/dev/index.d.ts +0 -173
  63. package/lib/config/dev/index.js +0 -2
  64. package/lib/config/index.d.ts +0 -172
  65. package/lib/config/index.js +0 -2
  66. package/lib/config/loadConfig.d.ts +0 -50
  67. package/lib/config/loadConfig.js +0 -98
  68. package/lib/config/mergeRspeedyConfig.d.ts +0 -36
  69. package/lib/config/mergeRspeedyConfig.js +0 -42
  70. package/lib/config/output/css-modules.d.ts +0 -84
  71. package/lib/config/output/css-modules.js +0 -2
  72. package/lib/config/output/dist-path.d.ts +0 -68
  73. package/lib/config/output/dist-path.js +0 -2
  74. package/lib/config/output/filename.d.ts +0 -167
  75. package/lib/config/output/filename.js +0 -2
  76. package/lib/config/output/index.d.ts +0 -320
  77. package/lib/config/output/index.js +0 -2
  78. package/lib/config/output/minify.d.ts +0 -80
  79. package/lib/config/output/minify.js +0 -2
  80. package/lib/config/output/source-map.d.ts +0 -68
  81. package/lib/config/output/source-map.js +0 -2
  82. package/lib/config/performance/chunk-split.d.ts +0 -192
  83. package/lib/config/performance/chunk-split.js +0 -2
  84. package/lib/config/performance/index.d.ts +0 -50
  85. package/lib/config/performance/index.js +0 -2
  86. package/lib/config/rsbuild/entry.d.ts +0 -3
  87. package/lib/config/rsbuild/entry.js +0 -31
  88. package/lib/config/rsbuild/index.d.ts +0 -4
  89. package/lib/config/rsbuild/index.js +0 -73
  90. package/lib/config/server/index.d.ts +0 -75
  91. package/lib/config/server/index.js +0 -2
  92. package/lib/config/source/decorators.d.ts +0 -43
  93. package/lib/config/source/decorators.js +0 -2
  94. package/lib/config/source/entry.d.ts +0 -84
  95. package/lib/config/source/entry.js +0 -2
  96. package/lib/config/source/index.d.ts +0 -474
  97. package/lib/config/source/index.js +0 -2
  98. package/lib/config/source/transformImport.d.ts +0 -106
  99. package/lib/config/source/transformImport.js +0 -2
  100. package/lib/config/tools/css-extract.d.ts +0 -72
  101. package/lib/config/tools/css-extract.js +0 -2
  102. package/lib/config/tools/css-loader.d.ts +0 -130
  103. package/lib/config/tools/css-loader.js +0 -2
  104. package/lib/config/tools/index.d.ts +0 -170
  105. package/lib/config/tools/index.js +0 -2
  106. package/lib/config/validate.d.ts +0 -4
  107. package/lib/config/validate.js +0 -29259
  108. package/lib/create-rspeedy.d.ts +0 -52
  109. package/lib/create-rspeedy.js +0 -49
  110. package/lib/debug.d.ts +0 -3
  111. package/lib/debug.js +0 -25
  112. package/lib/index.d.ts +0 -46
  113. package/lib/index.js +0 -11
  114. package/lib/plugins/api.plugin.d.ts +0 -3
  115. package/lib/plugins/api.plugin.js +0 -25
  116. package/lib/plugins/chunkLoading.plugin.d.ts +0 -2
  117. package/lib/plugins/chunkLoading.plugin.js +0 -30
  118. package/lib/plugins/dev.plugin.d.ts +0 -5
  119. package/lib/plugins/dev.plugin.js +0 -137
  120. package/lib/plugins/index.d.ts +0 -3
  121. package/lib/plugins/index.js +0 -49
  122. package/lib/plugins/inspect.plugin.d.ts +0 -4
  123. package/lib/plugins/inspect.plugin.js +0 -39
  124. package/lib/plugins/minify.plugin.d.ts +0 -3
  125. package/lib/plugins/minify.plugin.js +0 -89
  126. package/lib/plugins/optimization.plugin.d.ts +0 -2
  127. package/lib/plugins/optimization.plugin.js +0 -31
  128. package/lib/plugins/output.plugin.d.ts +0 -3
  129. package/lib/plugins/output.plugin.js +0 -34
  130. package/lib/plugins/resolve.plugin.d.ts +0 -2
  131. package/lib/plugins/resolve.plugin.js +0 -38
  132. package/lib/plugins/rsdoctor.plugin.d.ts +0 -3
  133. package/lib/plugins/rsdoctor.plugin.js +0 -48
  134. package/lib/plugins/sourcemap.plugin.d.ts +0 -2
  135. package/lib/plugins/sourcemap.plugin.js +0 -84
  136. package/lib/plugins/stats.plugin.d.ts +0 -2
  137. package/lib/plugins/stats.plugin.js +0 -20
  138. package/lib/plugins/swc.plugin.d.ts +0 -2
  139. package/lib/plugins/swc.plugin.js +0 -21
  140. package/lib/plugins/target.plugin.d.ts +0 -2
  141. package/lib/plugins/target.plugin.js +0 -12
  142. package/lib/utils/getESVersionTarget.d.ts +0 -1
  143. package/lib/utils/getESVersionTarget.js +0 -7
  144. package/lib/utils/is-ci.d.ts +0 -1
  145. package/lib/utils/is-ci.js +0 -7
  146. package/lib/version.d.ts +0 -4
  147. package/lib/version.js +0 -15
  148. package/lib/webpack/CompilationIdPlugin.d.ts +0 -4
  149. package/lib/webpack/CompilationIdPlugin.js +0 -20
  150. package/lib/webpack/EvalSourceMapDevToolPlugin.d.ts +0 -9
  151. package/lib/webpack/EvalSourceMapDevToolPlugin.js +0 -15
  152. package/lib/webpack/ProvidePlugin.d.ts +0 -9
  153. package/lib/webpack/ProvidePlugin.js +0 -15
  154. package/lib/webpack/SourceMapDevToolPlugin.d.ts +0 -9
  155. package/lib/webpack/SourceMapDevToolPlugin.js +0 -15
  156. package/register/data.d.ts +0 -9
  157. package/register/hooks.js +0 -146
  158. package/register/index.js +0 -47
  159. /package/{register → dist/register}/index.d.ts +0 -0
@@ -1,50 +0,0 @@
1
- import type { ChunkSplit, ChunkSplitBySize, ChunkSplitCustom } from './chunk-split.js';
2
- /**
3
- * The type of the console method.
4
- *
5
- * @public
6
- */
7
- export type ConsoleType = 'log' | 'warn' | 'error' | 'info' | 'debug' | 'profile' | 'profileEnd' | (string & Record<never, never>);
8
- /**
9
- * {@inheritdoc Config.performance}
10
- *
11
- * @public
12
- */
13
- export interface Performance {
14
- /**
15
- * {@link Performance.chunkSplit} is used to configure the chunk splitting strategy.
16
- */
17
- chunkSplit?: ChunkSplit | ChunkSplitBySize | ChunkSplitCustom | undefined;
18
- /**
19
- * Whether to remove `console.[methodName]` in production build.
20
- *
21
- * @example
22
- *
23
- * - Remove all `console` methods
24
- *
25
- * ```ts
26
- * import { defineConfig } from '@lynx-js/rspeedy'
27
- *
28
- * export default defineConfig({
29
- * performance: {
30
- * removeConsole: true,
31
- * },
32
- * })
33
- * ```
34
- *
35
- * @example
36
- *
37
- * - Remove specific `console` methods
38
- *
39
- * ```ts
40
- * import { defineConfig } from '@lynx-js/rspeedy'
41
- *
42
- * export default defineConfig({
43
- * performance: {
44
- * removeConsole: ['log', 'warn']
45
- * },
46
- * })
47
- * ```
48
- */
49
- removeConsole?: boolean | ConsoleType[] | undefined;
50
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.js.map
@@ -1,3 +0,0 @@
1
- import type { RsbuildEntry } from '@rsbuild/core';
2
- import type { Entry } from '../source/entry.js';
3
- export declare function toRsbuildEntry(entry: Entry | undefined): RsbuildEntry;
@@ -1,31 +0,0 @@
1
- import { debug, debugList } from '../../debug.js';
2
- const DEFAULT_ENTRY = './src/index.js';
3
- export function toRsbuildEntry(entry) {
4
- // Default value
5
- if (entry === undefined) {
6
- debug(`Using default entry ${DEFAULT_ENTRY}`);
7
- return {
8
- main: DEFAULT_ENTRY,
9
- };
10
- }
11
- // Single entry
12
- if (Array.isArray(entry) || typeof entry === 'string') {
13
- debug(() => `Using single entry ${[''].concat(entry).join('\n - ')}`);
14
- return { main: entry };
15
- }
16
- return Object.fromEntries(Object.entries(entry).map(([key, value]) => {
17
- if (Array.isArray(value) || typeof value === 'string') {
18
- debugList(`Using multiple entries - ${key}`, value);
19
- return [key, { import: value }];
20
- }
21
- debugList(`Using multiple entries - ${key}`, value.import ?? DEFAULT_ENTRY);
22
- if (value.import === undefined) {
23
- return [
24
- key,
25
- { ...value, import: DEFAULT_ENTRY },
26
- ];
27
- }
28
- return [key, value];
29
- }));
30
- }
31
- //# sourceMappingURL=entry.js.map
@@ -1,4 +0,0 @@
1
- import type { RsbuildConfig } from '@rsbuild/core';
2
- import type { UndefinedOnPartialDeep } from 'type-fest';
3
- import type { Config } from '../index.js';
4
- export declare function toRsbuildConfig(config: Config): UndefinedOnPartialDeep<RsbuildConfig>;
@@ -1,73 +0,0 @@
1
- import { toRsbuildEntry } from './entry.js';
2
- // This is the default value from lynx-speedy.
3
- // We may change it based on new benchmarks.
4
- const defaultDataUriLimit = 2 * 1024;
5
- export function toRsbuildConfig(config) {
6
- return {
7
- provider: config.provider,
8
- dev: {
9
- watchFiles: config.dev?.watchFiles,
10
- // We expect to use different default writeToDisk with Rsbuild
11
- writeToDisk: config.dev?.writeToDisk ?? true,
12
- progressBar: config.dev?.progressBar ?? true,
13
- },
14
- environments: config.environments ?? { lynx: {} },
15
- mode: config.mode,
16
- output: {
17
- assetPrefix: config.output?.assetPrefix,
18
- charset: 'utf8',
19
- cleanDistPath: config.output?.cleanDistPath,
20
- copy: config.output?.copy,
21
- cssModules: config.output?.cssModules,
22
- // We expect to use different default dataUriLimit with Rsbuild
23
- dataUriLimit: config.output?.dataUriLimit ?? defaultDataUriLimit,
24
- distPath: config.output?.distPath,
25
- filenameHash: config.output?.filenameHash,
26
- // TODO(OSS): change the default value to `linked`(or `undefined`) when OSS.
27
- // We expect to use different default legalComments with Rsbuild
28
- legalComments: config.output?.legalComments ?? 'none',
29
- polyfill: 'off',
30
- sourceMap: config.output?.sourceMap,
31
- },
32
- source: {
33
- alias: config.source?.alias,
34
- assetsInclude: config.source?.assetsInclude,
35
- decorators: config.source?.decorators,
36
- define: config.source?.define,
37
- entry: toRsbuildEntry(config.source?.entry),
38
- exclude: config.source?.exclude,
39
- include: config.source?.include,
40
- transformImport: config.source?.transformImport,
41
- tsconfigPath: config.source?.tsconfigPath,
42
- },
43
- server: {
44
- base: config.server?.base,
45
- headers: config.server?.headers,
46
- host: config.server?.host,
47
- port: config.server?.port,
48
- strictPort: config.server?.strictPort,
49
- },
50
- plugins: config.plugins,
51
- performance: {
52
- chunkSplit: config.performance?.chunkSplit,
53
- removeConsole: toRsbuildRemoveConsole(config),
54
- },
55
- tools: {
56
- bundlerChain: config.tools?.bundlerChain,
57
- cssExtract: config.tools?.cssExtract,
58
- cssLoader: config.tools?.cssLoader,
59
- htmlPlugin: false,
60
- rspack: config.tools?.rspack,
61
- swc: config.tools?.swc,
62
- },
63
- };
64
- }
65
- function toRsbuildRemoveConsole(config) {
66
- if (config.performance?.removeConsole === true) {
67
- // Lynx use console as a parameter in the runtime-wrapper
68
- // So we need to use all the console methods instead of `true` to make sure Rsbuild can remove all the console methods
69
- return ['log', 'warn', 'error', 'info', 'debug', 'profile', 'profileEnd'];
70
- }
71
- return config.performance?.removeConsole;
72
- }
73
- //# sourceMappingURL=index.js.map
@@ -1,75 +0,0 @@
1
- /**
2
- * {@inheritdoc Config.server}
3
- * @public
4
- */
5
- export interface Server {
6
- /**
7
- * Configure the base path of the server.
8
- *
9
- * @remarks
10
- * By default, the base path of the server is `/`, and users can access lynx bundle through `http://<host>:<port>/main.lynx.bundle`
11
- *
12
- * If you want to access lynx bundle through `http://<host>:<port>/foo/main.lynx.bundle`, you can change `server.base` to `/foo`
13
- *
14
- * you can refer to {@link https://rsbuild.dev/config/server/base | server.base } for more information.
15
- *
16
- * @example
17
- *
18
- * ```js
19
- * import { defineConfig } from '@lynx-js/rspeedy'
20
- * export default defineConfig({
21
- * server: {
22
- * base: '/dist'
23
- * },
24
- * })
25
- * ```
26
- */
27
- base?: string | undefined;
28
- /**
29
- * Adds headers to all responses.
30
- *
31
- * @example
32
- *
33
- * ```js
34
- * import { defineConfig } from '@lynx-js/rspeedy'
35
- * export default defineConfig({
36
- * server: {
37
- * headers: {
38
- * 'Access-Control-Allow-Origin': '**',
39
- * },
40
- * },
41
- * })
42
- * ```
43
- */
44
- headers?: Record<string, string | string[]> | undefined;
45
- /**
46
- * Specify the host that the Rspeedy Server listens to.
47
- */
48
- host?: string | undefined;
49
- /**
50
- * Specify the port that the Rspeedy Server listens to.
51
- *
52
- * @remarks
53
- * By default, the server listens on port `3000` and automatically increments the port number when the port is occupied.
54
- *
55
- * @example
56
- *
57
- * Set the port to a custom value:
58
- *
59
- * ```js
60
- * import { defineConfig } from '@lynx-js/rspeedy'
61
- * export default defineConfig({
62
- * server: {
63
- * port: 3470,
64
- * },
65
- * })
66
- * ```
67
- */
68
- port?: number | undefined;
69
- /**
70
- * When a port is occupied, Rspeedy will automatically increment the port number until an available port is found.
71
- *
72
- * Set strictPort to true and Rspeedy will throw an exception when the port is occupied.
73
- */
74
- strictPort?: boolean | undefined;
75
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.js.map
@@ -1,43 +0,0 @@
1
- /**
2
- * {@inheritdoc Source.decorators}
3
- *
4
- * @public
5
- */
6
- export interface Decorators {
7
- /**
8
- * Specify the decorator syntax version to be used.
9
- *
10
- * @remarks
11
- *
12
- * If you want to know the differences between different decorators versions, you can refer to: {@link https://github.com/tc39/proposal-decorators?tab=readme-ov-file#how-does-this-proposal-compare-to-other-versions-of-decorators | How does this proposal compare to other versions of decorators?}
13
- *
14
- * @example
15
- *
16
- * `'2022-03'` corresponds to the Stage 3 decorator proposal, equivalent to the decorator syntax supported by TypeScript 5.0 by default.
17
- *
18
- * ```js
19
- * import { defineConfig } from '@lynx-js/rspeedy'
20
- *
21
- * export default defineConfig({
22
- * source: {
23
- * decorators: { version: '2022-03' },
24
- * },
25
- * })
26
- * ```
27
- *
28
- * @example
29
- *
30
- * `'legacy'` corresponds to TypeScript's `experimentalDecorators: true`.
31
- *
32
- * ```js
33
- * import { defineConfig } from '@lynx-js/rspeedy'
34
- *
35
- * export default defineConfig({
36
- * source: {
37
- * decorators: { version: 'legacy' },
38
- * },
39
- * })
40
- * ```
41
- */
42
- version?: 'legacy' | '2022-03';
43
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=decorators.js.map
@@ -1,84 +0,0 @@
1
- /**
2
- * The `EntryDescription` describes a entry. It is useful when the project has multiple entries with different configuration.
3
- *
4
- * @remarks
5
- * It is similar with the {@link https://www.rspack.dev/config/entry#entry-description-object | Entry Description Object} of Rspack.
6
- * But only a few properties that Lynx supports is allowed.
7
- *
8
- * @public
9
- */
10
- export interface EntryDescription {
11
- /**
12
- * The path to the entry module(s).
13
- *
14
- * @remarks
15
- *
16
- * If no value is provided, the default value `src/index.js` will be used.
17
- *
18
- * @defaultValue `'./src/index.js'`
19
- */
20
- import?: string | string[] | undefined;
21
- /**
22
- * This is an important option when using on-demand-loading or loading external resources like images, files, etc. If an incorrect value is specified you'll receive 404 errors while loading these resources.
23
- *
24
- * @see https://webpack.js.org/configuration/output/#outputpublicpath
25
- */
26
- publicPath?: string | undefined;
27
- }
28
- /**
29
- * {@inheritdoc Source.entry}
30
- *
31
- * @example
32
- *
33
- * - Use a single entry:
34
- *
35
- * ```js
36
- * import { defineConfig } from '@lynx-js/rspeedy'
37
- * export default defineConfig({
38
- * entry: './src/pages/main/index.js',
39
- * })
40
- * ```
41
- *
42
- * @example
43
- *
44
- * - Use a single entry with multiple entry modules:
45
- *
46
- * ```js
47
- * import { defineConfig } from '@lynx-js/rspeedy'
48
- * export default defineConfig({
49
- * entry: ['./src/prefetch.js', './src/pages/main/index.js'],
50
- * })
51
- * ```
52
- *
53
- * @example
54
- *
55
- * - Use multiple entries(with multiple entry modules):
56
- *
57
- * ```js
58
- * import { defineConfig } from '@lynx-js/rspeedy'
59
- * export default defineConfig({
60
- * entry: {
61
- * foo: './src/pages/foo/index.js',
62
- * bar: ['./src/pages/bar/index.js', './src/post.js'], // multiple entry modules is allowed
63
- * },
64
- * })
65
- * ```
66
- *
67
- * @example
68
- *
69
- * - Use multiple entries with {@link EntryDescription}:
70
- *
71
- * ```js
72
- * import { defineConfig } from '@lynx-js/rspeedy'
73
- * export default defineConfig({
74
- * entry: {
75
- * foo: './src/pages/foo/index.js',
76
- * bar: {
77
- * import: ['./src/prefetch.js', './src/pages/bar'],
78
- * },
79
- * },
80
- * })
81
- * ```
82
- * @public
83
- */
84
- export type Entry = string | string[] | Record<string, string | string[] | EntryDescription>;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=entry.js.map