@lynx-js/rspeedy 0.8.7 → 0.9.1
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 +51 -0
- package/bin/rspeedy.js +2 -2
- package/dist/cli/main.js +414 -0
- package/dist/cli/start.js +171 -0
- package/dist/index.d.ts +2971 -0
- package/dist/index.js +39556 -0
- package/dist/register/hooks.js +552 -0
- package/dist/register/index.js +22 -0
- package/dist/src_cli_build_ts.js +47 -0
- package/dist/src_cli_commands_ts.js +60 -0
- package/dist/src_cli_dev_ts.js +87 -0
- package/dist/src_cli_exit_ts.js +111 -0
- package/dist/src_cli_inspect_ts.js +42 -0
- package/dist/src_cli_preview_ts.js +49 -0
- package/dist/src_config_loadConfig_ts-src_create-rspeedy_ts.js +39311 -0
- package/dist/src_plugins_api_plugin_ts.js +32 -0
- package/dist/src_plugins_chunkLoading_plugin_ts.js +35 -0
- package/dist/src_plugins_dev_plugin_ts.js +141 -0
- package/dist/src_plugins_index_ts.js +60 -0
- package/dist/src_plugins_inspect_plugin_ts.js +48 -0
- package/dist/src_plugins_minify_plugin_ts.js +85 -0
- package/dist/src_plugins_optimization_plugin_ts.js +25 -0
- package/dist/src_plugins_output_plugin_ts.js +46 -0
- package/dist/src_plugins_resolve_plugin_ts.js +21 -0
- package/dist/src_plugins_rsdoctor_plugin_ts.js +59 -0
- package/dist/src_plugins_sourcemap_plugin_ts.js +99 -0
- package/dist/src_plugins_stats_plugin_ts.js +26 -0
- package/dist/src_plugins_swc_plugin_ts.js +36 -0
- package/dist/src_plugins_target_plugin_ts.js +45 -0
- package/dist/src_version_ts.js +18 -0
- package/dist/vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js +1435 -0
- package/dist/vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js.LICENSE.txt +1 -0
- package/dist/vendors-node_modules_pnpm_commander_13_1_0_node_modules_commander_esm_mjs.js +1761 -0
- package/dist/vendors-node_modules_pnpm_ipaddr_js_2_2_0_node_modules_ipaddr_js_lib_ipaddr_js.js +1067 -0
- package/dist/vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-b558be.js +416 -0
- package/package.json +36 -23
- package/LICENSE +0 -202
- package/lib/api.d.ts +0 -46
- package/lib/api.js +0 -2
- package/lib/cli/build.d.ts +0 -4
- package/lib/cli/build.js +0 -32
- package/lib/cli/commands.d.ts +0 -5
- package/lib/cli/commands.js +0 -45
- package/lib/cli/dev.d.ts +0 -4
- package/lib/cli/dev.js +0 -75
- package/lib/cli/exit.d.ts +0 -1
- package/lib/cli/exit.js +0 -51
- package/lib/cli/inspect.d.ts +0 -8
- package/lib/cli/inspect.js +0 -30
- package/lib/cli/main.d.ts +0 -1
- package/lib/cli/main.js +0 -39
- package/lib/cli/preview.d.ts +0 -4
- package/lib/cli/preview.js +0 -31
- package/lib/cli/start.d.ts +0 -6
- package/lib/cli/start.js +0 -88
- package/lib/config/defaults.d.ts +0 -2
- package/lib/config/defaults.js +0 -32
- package/lib/config/defineConfig.d.ts +0 -22
- package/lib/config/defineConfig.js +0 -24
- package/lib/config/dev/client.d.ts +0 -15
- package/lib/config/dev/client.js +0 -2
- package/lib/config/dev/index.d.ts +0 -173
- package/lib/config/dev/index.js +0 -2
- package/lib/config/index.d.ts +0 -172
- package/lib/config/index.js +0 -2
- package/lib/config/loadConfig.d.ts +0 -50
- package/lib/config/loadConfig.js +0 -98
- package/lib/config/mergeRspeedyConfig.d.ts +0 -36
- package/lib/config/mergeRspeedyConfig.js +0 -42
- package/lib/config/output/css-modules.d.ts +0 -84
- package/lib/config/output/css-modules.js +0 -2
- package/lib/config/output/dist-path.d.ts +0 -19
- package/lib/config/output/dist-path.js +0 -2
- package/lib/config/output/filename.d.ts +0 -167
- package/lib/config/output/filename.js +0 -2
- package/lib/config/output/index.d.ts +0 -324
- package/lib/config/output/index.js +0 -2
- package/lib/config/output/minify.d.ts +0 -80
- package/lib/config/output/minify.js +0 -2
- package/lib/config/output/source-map.d.ts +0 -68
- package/lib/config/output/source-map.js +0 -2
- package/lib/config/performance/chunk-split.d.ts +0 -192
- package/lib/config/performance/chunk-split.js +0 -2
- package/lib/config/performance/index.d.ts +0 -165
- package/lib/config/performance/index.js +0 -2
- package/lib/config/rsbuild/entry.d.ts +0 -3
- package/lib/config/rsbuild/entry.js +0 -31
- package/lib/config/rsbuild/index.d.ts +0 -4
- package/lib/config/rsbuild/index.js +0 -75
- package/lib/config/server/index.d.ts +0 -91
- package/lib/config/server/index.js +0 -2
- package/lib/config/source/decorators.d.ts +0 -43
- package/lib/config/source/decorators.js +0 -2
- package/lib/config/source/entry.d.ts +0 -84
- package/lib/config/source/entry.js +0 -2
- package/lib/config/source/index.d.ts +0 -474
- package/lib/config/source/index.js +0 -2
- package/lib/config/source/transformImport.d.ts +0 -106
- package/lib/config/source/transformImport.js +0 -2
- package/lib/config/tools/css-extract.d.ts +0 -72
- package/lib/config/tools/css-extract.js +0 -2
- package/lib/config/tools/css-loader.d.ts +0 -130
- package/lib/config/tools/css-loader.js +0 -2
- package/lib/config/tools/index.d.ts +0 -170
- package/lib/config/tools/index.js +0 -2
- package/lib/config/validate.d.ts +0 -4
- package/lib/config/validate.js +0 -28877
- package/lib/create-rspeedy.d.ts +0 -52
- package/lib/create-rspeedy.js +0 -49
- package/lib/debug.d.ts +0 -3
- package/lib/debug.js +0 -25
- package/lib/index.d.ts +0 -46
- package/lib/index.js +0 -11
- package/lib/plugins/api.plugin.d.ts +0 -3
- package/lib/plugins/api.plugin.js +0 -25
- package/lib/plugins/chunkLoading.plugin.d.ts +0 -2
- package/lib/plugins/chunkLoading.plugin.js +0 -43
- package/lib/plugins/dev.plugin.d.ts +0 -5
- package/lib/plugins/dev.plugin.js +0 -137
- package/lib/plugins/index.d.ts +0 -3
- package/lib/plugins/index.js +0 -49
- package/lib/plugins/inspect.plugin.d.ts +0 -4
- package/lib/plugins/inspect.plugin.js +0 -39
- package/lib/plugins/minify.plugin.d.ts +0 -3
- package/lib/plugins/minify.plugin.js +0 -89
- package/lib/plugins/optimization.plugin.d.ts +0 -2
- package/lib/plugins/optimization.plugin.js +0 -31
- package/lib/plugins/output.plugin.d.ts +0 -3
- package/lib/plugins/output.plugin.js +0 -34
- package/lib/plugins/resolve.plugin.d.ts +0 -2
- package/lib/plugins/resolve.plugin.js +0 -38
- package/lib/plugins/rsdoctor.plugin.d.ts +0 -3
- package/lib/plugins/rsdoctor.plugin.js +0 -48
- package/lib/plugins/sourcemap.plugin.d.ts +0 -2
- package/lib/plugins/sourcemap.plugin.js +0 -86
- package/lib/plugins/stats.plugin.d.ts +0 -2
- package/lib/plugins/stats.plugin.js +0 -20
- package/lib/plugins/swc.plugin.d.ts +0 -2
- package/lib/plugins/swc.plugin.js +0 -21
- package/lib/plugins/target.plugin.d.ts +0 -2
- package/lib/plugins/target.plugin.js +0 -22
- package/lib/utils/getESVersionTarget.d.ts +0 -1
- package/lib/utils/getESVersionTarget.js +0 -7
- package/lib/utils/is-ci.d.ts +0 -1
- package/lib/utils/is-ci.js +0 -7
- package/lib/utils/is-lynx.d.ts +0 -2
- package/lib/utils/is-lynx.js +0 -6
- package/lib/utils/is-web.d.ts +0 -2
- package/lib/utils/is-web.js +0 -6
- package/lib/version.d.ts +0 -4
- package/lib/version.js +0 -15
- package/lib/webpack/CompilationIdPlugin.d.ts +0 -4
- package/lib/webpack/CompilationIdPlugin.js +0 -20
- package/lib/webpack/EvalSourceMapDevToolPlugin.d.ts +0 -9
- package/lib/webpack/EvalSourceMapDevToolPlugin.js +0 -15
- package/lib/webpack/ProvidePlugin.d.ts +0 -9
- package/lib/webpack/ProvidePlugin.js +0 -15
- package/lib/webpack/SourceMapDevToolPlugin.d.ts +0 -9
- package/lib/webpack/SourceMapDevToolPlugin.js +0 -15
- package/register/data.d.ts +0 -9
- package/register/hooks.js +0 -146
- package/register/index.js +0 -47
- /package/{register → dist/register}/index.d.ts +0 -0
package/LICENSE
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
Apache License
|
|
3
|
-
Version 2.0, January 2004
|
|
4
|
-
http://www.apache.org/licenses/
|
|
5
|
-
|
|
6
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
-
|
|
8
|
-
1. Definitions.
|
|
9
|
-
|
|
10
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
-
|
|
13
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
-
the copyright owner that is granting the License.
|
|
15
|
-
|
|
16
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
-
other entities that control, are controlled by, or are under common
|
|
18
|
-
control with that entity. For the purposes of this definition,
|
|
19
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
-
direction or management of such entity, whether by contract or
|
|
21
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
-
|
|
24
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
-
exercising permissions granted by this License.
|
|
26
|
-
|
|
27
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
-
including but not limited to software source code, documentation
|
|
29
|
-
source, and configuration files.
|
|
30
|
-
|
|
31
|
-
"Object" form shall mean any form resulting from mechanical
|
|
32
|
-
transformation or translation of a Source form, including but
|
|
33
|
-
not limited to compiled object code, generated documentation,
|
|
34
|
-
and conversions to other media types.
|
|
35
|
-
|
|
36
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
-
Object form, made available under the License, as indicated by a
|
|
38
|
-
copyright notice that is included in or attached to the work
|
|
39
|
-
(an example is provided in the Appendix below).
|
|
40
|
-
|
|
41
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
-
form, that is based on (or derived from) the Work and for which the
|
|
43
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
-
of this License, Derivative Works shall not include works that remain
|
|
46
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
-
the Work and Derivative Works thereof.
|
|
48
|
-
|
|
49
|
-
"Contribution" shall mean any work of authorship, including
|
|
50
|
-
the original version of the Work and any modifications or additions
|
|
51
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
-
means any form of electronic, verbal, or written communication sent
|
|
56
|
-
to the Licensor or its representatives, including but not limited to
|
|
57
|
-
communication on electronic mailing lists, source code control systems,
|
|
58
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
-
excluding communication that is conspicuously marked or otherwise
|
|
61
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
-
|
|
63
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
-
subsequently incorporated within the Work.
|
|
66
|
-
|
|
67
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
-
Work and such Derivative Works in Source or Object form.
|
|
73
|
-
|
|
74
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
-
(except as stated in this section) patent license to make, have made,
|
|
78
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
-
where such license applies only to those patent claims licensable
|
|
80
|
-
by such Contributor that are necessarily infringed by their
|
|
81
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
-
institute patent litigation against any entity (including a
|
|
84
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
-
or contributory patent infringement, then any patent licenses
|
|
87
|
-
granted to You under this License for that Work shall terminate
|
|
88
|
-
as of the date such litigation is filed.
|
|
89
|
-
|
|
90
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
-
modifications, and in Source or Object form, provided that You
|
|
93
|
-
meet the following conditions:
|
|
94
|
-
|
|
95
|
-
(a) You must give any other recipients of the Work or
|
|
96
|
-
Derivative Works a copy of this License; and
|
|
97
|
-
|
|
98
|
-
(b) You must cause any modified files to carry prominent notices
|
|
99
|
-
stating that You changed the files; and
|
|
100
|
-
|
|
101
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
-
that You distribute, all copyright, patent, trademark, and
|
|
103
|
-
attribution notices from the Source form of the Work,
|
|
104
|
-
excluding those notices that do not pertain to any part of
|
|
105
|
-
the Derivative Works; and
|
|
106
|
-
|
|
107
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
-
distribution, then any Derivative Works that You distribute must
|
|
109
|
-
include a readable copy of the attribution notices contained
|
|
110
|
-
within such NOTICE file, excluding those notices that do not
|
|
111
|
-
pertain to any part of the Derivative Works, in at least one
|
|
112
|
-
of the following places: within a NOTICE text file distributed
|
|
113
|
-
as part of the Derivative Works; within the Source form or
|
|
114
|
-
documentation, if provided along with the Derivative Works; or,
|
|
115
|
-
within a display generated by the Derivative Works, if and
|
|
116
|
-
wherever such third-party notices normally appear. The contents
|
|
117
|
-
of the NOTICE file are for informational purposes only and
|
|
118
|
-
do not modify the License. You may add Your own attribution
|
|
119
|
-
notices within Derivative Works that You distribute, alongside
|
|
120
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
-
that such additional attribution notices cannot be construed
|
|
122
|
-
as modifying the License.
|
|
123
|
-
|
|
124
|
-
You may add Your own copyright statement to Your modifications and
|
|
125
|
-
may provide additional or different license terms and conditions
|
|
126
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
-
the conditions stated in this License.
|
|
130
|
-
|
|
131
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
-
this License, without any additional terms or conditions.
|
|
135
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
-
the terms of any separate license agreement you may have executed
|
|
137
|
-
with Licensor regarding such Contributions.
|
|
138
|
-
|
|
139
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
-
except as required for reasonable and customary use in describing the
|
|
142
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
-
|
|
144
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
-
implied, including, without limitation, any warranties or conditions
|
|
149
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
-
appropriateness of using or redistributing the Work and assume any
|
|
152
|
-
risks associated with Your exercise of permissions under this License.
|
|
153
|
-
|
|
154
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
-
unless required by applicable law (such as deliberate and grossly
|
|
157
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
-
liable to You for damages, including any direct, indirect, special,
|
|
159
|
-
incidental, or consequential damages of any character arising as a
|
|
160
|
-
result of this License or out of the use or inability to use the
|
|
161
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
-
other commercial damages or losses), even if such Contributor
|
|
164
|
-
has been advised of the possibility of such damages.
|
|
165
|
-
|
|
166
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
-
or other liability obligations and/or rights consistent with this
|
|
170
|
-
License. However, in accepting such obligations, You may act only
|
|
171
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
-
defend, and hold each Contributor harmless for any liability
|
|
174
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
-
of your accepting any such warranty or additional liability.
|
|
176
|
-
|
|
177
|
-
END OF TERMS AND CONDITIONS
|
|
178
|
-
|
|
179
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
-
|
|
181
|
-
To apply the Apache License to your work, attach the following
|
|
182
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
-
replaced with your own identifying information. (Don't include
|
|
184
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
-
comment syntax for the file format. We also recommend that a
|
|
186
|
-
file or class name and description of purpose be included on the
|
|
187
|
-
same "printed page" as the copyright notice for easier
|
|
188
|
-
identification within third-party archives.
|
|
189
|
-
|
|
190
|
-
Copyright [yyyy] [name of copyright owner]
|
|
191
|
-
|
|
192
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
-
you may not use this file except in compliance with the License.
|
|
194
|
-
You may obtain a copy of the License at
|
|
195
|
-
|
|
196
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
-
|
|
198
|
-
Unless required by applicable law or agreed to in writing, software
|
|
199
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
-
See the License for the specific language governing permissions and
|
|
202
|
-
limitations under the License.
|
package/lib/api.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { logger } from '@rsbuild/core';
|
|
2
|
-
import type { Config } from './config/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* The exposed API of Rspeedy. Can be used in Rsbuild plugin with {@link https://rsbuild.dev/plugins/dev/core#apiuseexposed | api.useExposed}.
|
|
5
|
-
*
|
|
6
|
-
* @public
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* import type { ExposedAPI } from '@lynx-js/rspeedy'
|
|
12
|
-
* const RsbuildPlugin = {
|
|
13
|
-
* name: 'my-rsbuild-plugin',
|
|
14
|
-
* pre: ['lynx:rsbuild:plugin-api'],
|
|
15
|
-
* setup(api) {
|
|
16
|
-
* const rspeedyAPI = api.useExposed<ExposedAPI>(Symbol.for('rspeedy.api'))
|
|
17
|
-
* },
|
|
18
|
-
* }
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export interface ExposedAPI {
|
|
22
|
-
/**
|
|
23
|
-
* The user config.
|
|
24
|
-
*/
|
|
25
|
-
config: Config;
|
|
26
|
-
/**
|
|
27
|
-
* Print debug logs.
|
|
28
|
-
*
|
|
29
|
-
* @param message - The printed message.
|
|
30
|
-
*/
|
|
31
|
-
debug: (message: string | (() => string)) => void;
|
|
32
|
-
/**
|
|
33
|
-
* Exit the process.
|
|
34
|
-
*
|
|
35
|
-
* @param code - The exit code.
|
|
36
|
-
*/
|
|
37
|
-
exit: (code?: number) => Promise<void> | void;
|
|
38
|
-
/**
|
|
39
|
-
* Get the Rspeedy logger.
|
|
40
|
-
*/
|
|
41
|
-
logger: typeof logger;
|
|
42
|
-
/**
|
|
43
|
-
* The version of Rspeedy.
|
|
44
|
-
*/
|
|
45
|
-
version: string;
|
|
46
|
-
}
|
package/lib/api.js
DELETED
package/lib/cli/build.d.ts
DELETED
package/lib/cli/build.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
-
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
-
// LICENSE file in the root directory of this source tree.
|
|
4
|
-
import { logger } from '@rsbuild/core';
|
|
5
|
-
import { exit } from './exit.js';
|
|
6
|
-
import { loadConfig } from '../config/loadConfig.js';
|
|
7
|
-
import { createRspeedy } from '../create-rspeedy.js';
|
|
8
|
-
import { isCI } from '../utils/is-ci.js';
|
|
9
|
-
export async function build(cwd, buildOptions) {
|
|
10
|
-
// We always exit on CI since `sass-embedded` will have child_processes that never exit.
|
|
11
|
-
// Otherwise, we do not exit when Rsdoctor is enabled.
|
|
12
|
-
const shouldExit = process.env['RSDOCTOR'] !== 'true' || isCI();
|
|
13
|
-
try {
|
|
14
|
-
const { content: rspeedyConfig } = await loadConfig({
|
|
15
|
-
cwd,
|
|
16
|
-
configPath: buildOptions.config,
|
|
17
|
-
});
|
|
18
|
-
const rspeedy = await createRspeedy({ cwd, rspeedyConfig });
|
|
19
|
-
await rspeedy.build();
|
|
20
|
-
}
|
|
21
|
-
catch (error) {
|
|
22
|
-
logger.error(error);
|
|
23
|
-
if (shouldExit) {
|
|
24
|
-
exit(1);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
if (shouldExit) {
|
|
29
|
-
exit();
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=build.js.map
|
package/lib/cli/commands.d.ts
DELETED
package/lib/cli/commands.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { version } from '../version.js';
|
|
2
|
-
function applyCommonOptions(command) {
|
|
3
|
-
command
|
|
4
|
-
.option('-c --config <config>', 'specify the configuration file, can be a relative or absolute path');
|
|
5
|
-
}
|
|
6
|
-
export function apply(program) {
|
|
7
|
-
// TODO(cli): support custom cwd
|
|
8
|
-
const cwd = process.cwd();
|
|
9
|
-
program
|
|
10
|
-
.name('rspeedy')
|
|
11
|
-
.usage('<command> [options]')
|
|
12
|
-
.version(version)
|
|
13
|
-
.option('--unmanaged', 'Force to use the unmanaged version of Rspeedy, instead of the locally installed.')
|
|
14
|
-
.showHelpAfterError(true)
|
|
15
|
-
.showSuggestionAfterError(true)
|
|
16
|
-
.exitOverride(); // Avoid calling `process.exit` by commander
|
|
17
|
-
const buildCommand = program.command('build');
|
|
18
|
-
buildCommand
|
|
19
|
-
.description('Build the project in production mode')
|
|
20
|
-
.action((buildOptions) => import('./build.js').then(({ build }) => build.call(buildCommand, cwd, buildOptions)));
|
|
21
|
-
const devCommand = program.command('dev');
|
|
22
|
-
devCommand
|
|
23
|
-
.description('Run the dev server and watch for source file changes while serving.')
|
|
24
|
-
.action((devOptions) => import('./dev.js').then(({ dev }) => dev.call(devCommand, cwd, devOptions)));
|
|
25
|
-
const inspectCommand = program.command('inspect');
|
|
26
|
-
inspectCommand
|
|
27
|
-
.description('View the Rsbuild config and Rspack config of the project.')
|
|
28
|
-
.option('--mode <mode>', 'specify the mode of Rsbuild', 'development')
|
|
29
|
-
.option('--output <output>', 'specify inspect content output path')
|
|
30
|
-
.option('--verbose', 'show full function definitions in output')
|
|
31
|
-
.action((inspectOptions) => import('./inspect.js').then(({ inspect }) => inspect.call(inspectCommand, cwd, inspectOptions)));
|
|
32
|
-
const previewCommand = program.command('preview');
|
|
33
|
-
previewCommand
|
|
34
|
-
.description('Preview the production build outputs locally.')
|
|
35
|
-
.action((previewOptions) => import('./preview.js').then(({ preview }) => preview.call(previewCommand, cwd, previewOptions)));
|
|
36
|
-
const commonCommands = [
|
|
37
|
-
devCommand,
|
|
38
|
-
buildCommand,
|
|
39
|
-
inspectCommand,
|
|
40
|
-
previewCommand,
|
|
41
|
-
];
|
|
42
|
-
commonCommands.forEach((command) => applyCommonOptions(command));
|
|
43
|
-
return program;
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=commands.js.map
|
package/lib/cli/dev.d.ts
DELETED
package/lib/cli/dev.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
-
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
-
// LICENSE file in the root directory of this source tree.
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import { logger } from '@rsbuild/core';
|
|
6
|
-
import color from 'picocolors';
|
|
7
|
-
import { loadConfig, resolveConfigPath } from '../config/loadConfig.js';
|
|
8
|
-
import { createRspeedy } from '../create-rspeedy.js';
|
|
9
|
-
import { exit } from './exit.js';
|
|
10
|
-
export async function dev(cwd, devOptions) {
|
|
11
|
-
let onBeforeRestart = [];
|
|
12
|
-
try {
|
|
13
|
-
const configPath = resolveConfigPath(cwd, devOptions.config);
|
|
14
|
-
const { content: rspeedyConfig } = await loadConfig({
|
|
15
|
-
cwd,
|
|
16
|
-
configPath,
|
|
17
|
-
});
|
|
18
|
-
const watchedFiles = [configPath];
|
|
19
|
-
if (Array.isArray(rspeedyConfig.dev?.watchFiles)) {
|
|
20
|
-
watchedFiles.push(...rspeedyConfig.dev.watchFiles
|
|
21
|
-
.filter(item => item.type === 'reload-server')
|
|
22
|
-
.flatMap(item => item.paths));
|
|
23
|
-
}
|
|
24
|
-
else if (rspeedyConfig.dev?.watchFiles?.type === 'reload-server') {
|
|
25
|
-
const { paths } = rspeedyConfig.dev.watchFiles;
|
|
26
|
-
watchedFiles.push(...Array.isArray(paths) ? paths : [paths]);
|
|
27
|
-
}
|
|
28
|
-
await watchFiles(watchedFiles.map(filePath => path.isAbsolute(filePath) ? filePath : path.join(cwd, filePath)), async (filename) => {
|
|
29
|
-
logger.info(`Restart because ${color.yellow(filename)} is changed.\n`);
|
|
30
|
-
const cleanup = onBeforeRestart.map(f => f());
|
|
31
|
-
onBeforeRestart = [];
|
|
32
|
-
await Promise.all(cleanup);
|
|
33
|
-
await dev.call(this, cwd, devOptions);
|
|
34
|
-
});
|
|
35
|
-
const rspeedy = await createRspeedy({ cwd, rspeedyConfig });
|
|
36
|
-
const server = await rspeedy.createDevServer();
|
|
37
|
-
const { server: { close } } = await server.listen();
|
|
38
|
-
onBeforeRestart.push(close);
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
logger.error(error);
|
|
42
|
-
exit(1);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
async function watchFiles(files, callback) {
|
|
46
|
-
const chokidar = await import('chokidar');
|
|
47
|
-
const watcher = chokidar.default.watch(files, {
|
|
48
|
-
// do not trigger add for initial files
|
|
49
|
-
ignoreInitial: true,
|
|
50
|
-
// If watching fails due to read permissions, the errors will be suppressed silently.
|
|
51
|
-
ignorePermissionErrors: true,
|
|
52
|
-
});
|
|
53
|
-
const cb = debounce((event, filePath) => {
|
|
54
|
-
const startTime = Date.now();
|
|
55
|
-
void watcher.close().then(() => callback(filePath, startTime, event));
|
|
56
|
-
},
|
|
57
|
-
// set 300ms debounce to avoid restart frequently
|
|
58
|
-
300);
|
|
59
|
-
watcher.once('add', cb.bind(null, 'add'));
|
|
60
|
-
watcher.once('change', cb.bind(null, 'change'));
|
|
61
|
-
watcher.once('unlink', cb.bind(null, 'unlink'));
|
|
62
|
-
}
|
|
63
|
-
// biome-ignore lint/suspicious/noExplicitAny: Make TS happy
|
|
64
|
-
function debounce(func, wait) {
|
|
65
|
-
let timeoutId = null;
|
|
66
|
-
return (...args) => {
|
|
67
|
-
if (timeoutId !== null) {
|
|
68
|
-
clearTimeout(timeoutId);
|
|
69
|
-
}
|
|
70
|
-
timeoutId = setTimeout(() => {
|
|
71
|
-
func(...args);
|
|
72
|
-
}, wait);
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
//# sourceMappingURL=dev.js.map
|
package/lib/cli/exit.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const exit: (signal?: number | undefined) => void;
|
package/lib/cli/exit.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
-
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
-
// LICENSE file in the root directory of this source tree.
|
|
4
|
-
import { logger } from '@rsbuild/core';
|
|
5
|
-
import { asyncExitHook, gracefulExit } from 'exit-hook';
|
|
6
|
-
import color from 'picocolors';
|
|
7
|
-
import { debug } from '../debug.js';
|
|
8
|
-
const start = Date.now();
|
|
9
|
-
const exitPromises = [];
|
|
10
|
-
const unsubscribe = asyncExitHook(onExit, { wait: 1000 });
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
12
|
-
process.on('unhandledRejection', async (reason) => {
|
|
13
|
-
logger.error('Unhandled Rejection with reason:', reason instanceof Error ? reason : new Error(JSON.stringify(reason)));
|
|
14
|
-
// Here we do not directly use `gracefulExit` since it will wait until
|
|
15
|
-
// the compilation finished.
|
|
16
|
-
unsubscribe();
|
|
17
|
-
await onExit(1);
|
|
18
|
-
// eslint-disable-next-line n/no-process-exit
|
|
19
|
-
process.exit(1);
|
|
20
|
-
});
|
|
21
|
-
let interrupted = false;
|
|
22
|
-
process.on('SIGINT', () => {
|
|
23
|
-
if (interrupted) {
|
|
24
|
-
logger.info(`Force exiting Rspeedy.`);
|
|
25
|
-
// The `exit` is not complete, yet.
|
|
26
|
-
// But the `Ctrl + C` has been pressed again, we make a force exit here.
|
|
27
|
-
// eslint-disable-next-line n/no-process-exit
|
|
28
|
-
return process.exit(/** 128 + 2(kill) */ 130);
|
|
29
|
-
}
|
|
30
|
-
interrupted = true;
|
|
31
|
-
logger.info(`Gracefully shutting down. Please wait... (Press ${color.cyan('Ctrl+C')} again to force exit)`);
|
|
32
|
-
// Graceful exit with code 130
|
|
33
|
-
// see: https://nodejs.org/docs/latest/api/process.html#signal-events
|
|
34
|
-
exit(/** 128 + 2(kill) */ 130);
|
|
35
|
-
});
|
|
36
|
-
let previousSignal = null;
|
|
37
|
-
export const exit = (signal = 0) => {
|
|
38
|
-
if (previousSignal !== null) {
|
|
39
|
-
debug(`graceful exit called multiple times, current: ${signal}, previous: ${previousSignal}`);
|
|
40
|
-
}
|
|
41
|
-
previousSignal = signal;
|
|
42
|
-
debug(`graceful exit process with signal: ${signal}`);
|
|
43
|
-
gracefulExit(signal);
|
|
44
|
-
};
|
|
45
|
-
async function onExit(signal) {
|
|
46
|
-
const duration = Date.now() - start;
|
|
47
|
-
debug(`exit hook fired with signal: ${signal}, duration: ${duration}`);
|
|
48
|
-
debug(`awaiting exit promises(length: ${exitPromises.length})...`);
|
|
49
|
-
await Promise.allSettled(exitPromises);
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=exit.js.map
|
package/lib/cli/inspect.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Command } from 'commander';
|
|
2
|
-
import type { CommonOptions } from './commands.js';
|
|
3
|
-
export interface InspectOptions extends CommonOptions {
|
|
4
|
-
mode?: 'production' | 'development' | undefined;
|
|
5
|
-
verbose?: boolean | undefined;
|
|
6
|
-
output?: string | undefined;
|
|
7
|
-
}
|
|
8
|
-
export declare function inspect(this: Command, cwd: string, inspectOptions: InspectOptions): Promise<void>;
|
package/lib/cli/inspect.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
-
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
-
// LICENSE file in the root directory of this source tree.
|
|
4
|
-
import { logger } from '@rsbuild/core';
|
|
5
|
-
import { exit } from './exit.js';
|
|
6
|
-
import { loadConfig } from '../config/loadConfig.js';
|
|
7
|
-
import { createRspeedy } from '../create-rspeedy.js';
|
|
8
|
-
export async function inspect(cwd, inspectOptions) {
|
|
9
|
-
try {
|
|
10
|
-
const { content: rspeedyConfig } = await loadConfig({
|
|
11
|
-
cwd,
|
|
12
|
-
configPath: inspectOptions.config,
|
|
13
|
-
});
|
|
14
|
-
const rspeedy = await createRspeedy({ cwd, rspeedyConfig });
|
|
15
|
-
await rspeedy.inspectConfig({
|
|
16
|
-
mode: inspectOptions.mode
|
|
17
|
-
?? process.env['NODE_ENV']
|
|
18
|
-
?? 'development',
|
|
19
|
-
verbose: inspectOptions.verbose ?? false,
|
|
20
|
-
outputPath: inspectOptions.output,
|
|
21
|
-
writeToDisk: true,
|
|
22
|
-
});
|
|
23
|
-
return exit();
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
logger.error(error);
|
|
27
|
-
logger.error();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=inspect.js.map
|
package/lib/cli/main.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function main(argv: string[]): Promise<void>;
|
package/lib/cli/main.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
-
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
-
// LICENSE file in the root directory of this source tree.
|
|
4
|
-
import { logger } from '@rsbuild/core';
|
|
5
|
-
import { exit } from './exit.js';
|
|
6
|
-
import { debug } from '../debug.js';
|
|
7
|
-
function initNodeEnv(argv) {
|
|
8
|
-
if (!process.env['NODE_ENV']) {
|
|
9
|
-
const NODE_ENV = (argv.includes('dev') || argv.includes('preview'))
|
|
10
|
-
? 'development'
|
|
11
|
-
: 'production';
|
|
12
|
-
process.env['NODE_ENV'] = NODE_ENV;
|
|
13
|
-
debug(`No NODE_ENV found, set to ${NODE_ENV}`);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export async function main(argv) {
|
|
17
|
-
initNodeEnv(argv);
|
|
18
|
-
// If not called through a package manager,
|
|
19
|
-
// output a blank line to keep the greet log nice.
|
|
20
|
-
const { npm_execpath } = process.env;
|
|
21
|
-
if (!npm_execpath || npm_execpath.includes('npm-cli.js')
|
|
22
|
-
|| npm_execpath.includes('npx-cli.js')) {
|
|
23
|
-
// biome-ignore lint/suspicious/noConsoleLog: <explanation>
|
|
24
|
-
console.log();
|
|
25
|
-
}
|
|
26
|
-
const { version, rsbuildVersion, rspackVersion } = await import('../version.js');
|
|
27
|
-
logger.greet(` Rspeedy v${version} (Rsbuild v${rsbuildVersion}, Rspack v${rspackVersion})\n`);
|
|
28
|
-
try {
|
|
29
|
-
const [{ Command }, { apply },] = await Promise.all([
|
|
30
|
-
import('commander'),
|
|
31
|
-
import('./commands.js'),
|
|
32
|
-
]);
|
|
33
|
-
apply(new Command('rspeedy')).parse(argv);
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
return exit(1);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=main.js.map
|
package/lib/cli/preview.d.ts
DELETED
package/lib/cli/preview.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
-
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
-
// LICENSE file in the root directory of this source tree.
|
|
4
|
-
import fs from 'node:fs';
|
|
5
|
-
import { logger } from '@rsbuild/core';
|
|
6
|
-
import color from 'picocolors';
|
|
7
|
-
import { exit } from './exit.js';
|
|
8
|
-
import { loadConfig } from '../config/loadConfig.js';
|
|
9
|
-
import { createRspeedy } from '../create-rspeedy.js';
|
|
10
|
-
export async function preview(cwd, options) {
|
|
11
|
-
try {
|
|
12
|
-
const { content: rspeedyConfig } = await loadConfig({
|
|
13
|
-
cwd,
|
|
14
|
-
configPath: options.config,
|
|
15
|
-
});
|
|
16
|
-
const rspeedy = await createRspeedy({ cwd, rspeedyConfig });
|
|
17
|
-
await rspeedy.initConfigs();
|
|
18
|
-
const { distPath } = rspeedy.context;
|
|
19
|
-
if (!fs.existsSync(distPath)) {
|
|
20
|
-
throw new Error(`The output directory ${color.yellow(distPath)} does not exist, please build the project before previewing.`);
|
|
21
|
-
}
|
|
22
|
-
await rspeedy.preview();
|
|
23
|
-
}
|
|
24
|
-
catch (error) {
|
|
25
|
-
logger.error('Failed to start preview server.');
|
|
26
|
-
logger.error(error);
|
|
27
|
-
exit(1);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=preview.js.map
|
package/lib/cli/start.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* When rspeedy is invoked via the shell path, we examine the project's package.json dependencies and try to load
|
|
3
|
-
* the locally installed version of rspeedy. This avoids accidentally building using the wrong version of rspeedy.
|
|
4
|
-
* Use "rspeedy --unmanaged" to bypass this feature.
|
|
5
|
-
*/
|
|
6
|
-
export declare function tryStartLocalRspeedy(root?: string): false | Promise<void>;
|