@lynx-js/rspeedy 0.8.4 → 0.8.6
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 +24 -0
- package/README.md +1 -1
- package/lib/config/dev/index.d.ts +40 -0
- package/lib/config/rsbuild/index.js +2 -0
- package/lib/config/server/index.d.ts +6 -0
- package/lib/config/validate.js +3460 -3392
- package/lib/create-rspeedy.d.ts +9 -2
- package/lib/create-rspeedy.js +2 -1
- package/lib/plugins/rsdoctor.plugin.js +12 -5
- package/package.json +4 -4
package/lib/create-rspeedy.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RsbuildInstance } from '@rsbuild/core';
|
|
1
|
+
import type { CreateRsbuildOptions, RsbuildInstance } from '@rsbuild/core';
|
|
2
2
|
import type { Config } from './config/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* The instance of Rspeedy.
|
|
@@ -22,6 +22,13 @@ export interface CreateRspeedyOptions {
|
|
|
22
22
|
* The config of Rspeedy.
|
|
23
23
|
*/
|
|
24
24
|
rspeedyConfig?: Config;
|
|
25
|
+
/**
|
|
26
|
+
* Rspeedy automatically loads the .env file by default, utilizing the [Rsbuild API](https://rsbuild.dev/api/javascript-api/core#load-env-variables).
|
|
27
|
+
* You can use the environment variables defined in the .env file within your code by accessing them via `import.meta.env.FOO` or `process.env.Foo`.
|
|
28
|
+
* @see https://rsbuild.dev/guide/advanced/env-vars#env-file
|
|
29
|
+
* @defaultValue true
|
|
30
|
+
*/
|
|
31
|
+
loadEnv?: CreateRsbuildOptions['loadEnv'];
|
|
25
32
|
}
|
|
26
33
|
/**
|
|
27
34
|
* The `createRspeedy` method can let you create a Rspeedy instance and you can customize the build or development process in Node.js Runtime.
|
|
@@ -42,4 +49,4 @@ export interface CreateRspeedyOptions {
|
|
|
42
49
|
*
|
|
43
50
|
* @public
|
|
44
51
|
*/
|
|
45
|
-
export declare function createRspeedy({ cwd, rspeedyConfig }: CreateRspeedyOptions): Promise<RspeedyInstance>;
|
|
52
|
+
export declare function createRspeedy({ cwd, rspeedyConfig, loadEnv }: CreateRspeedyOptions): Promise<RspeedyInstance>;
|
package/lib/create-rspeedy.js
CHANGED
|
@@ -24,11 +24,12 @@ import { toRsbuildConfig } from './config/rsbuild/index.js';
|
|
|
24
24
|
*
|
|
25
25
|
* @public
|
|
26
26
|
*/
|
|
27
|
-
export async function createRspeedy({ cwd = process.cwd(), rspeedyConfig = {} }) {
|
|
27
|
+
export async function createRspeedy({ cwd = process.cwd(), rspeedyConfig = {}, loadEnv = true }) {
|
|
28
28
|
const config = applyDefaultRspeedyConfig(rspeedyConfig);
|
|
29
29
|
const [rspeedy, { applyDefaultPlugins }] = await Promise.all([
|
|
30
30
|
createRsbuild({
|
|
31
31
|
cwd,
|
|
32
|
+
loadEnv,
|
|
32
33
|
rsbuildConfig: toRsbuildConfig(config),
|
|
33
34
|
}),
|
|
34
35
|
import('./plugins/index.js'),
|
|
@@ -1,7 +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
|
-
import { logger } from '@rsbuild/core';
|
|
4
|
+
import { logger, mergeRsbuildConfig } from '@rsbuild/core';
|
|
5
5
|
import { isCI } from '../utils/is-ci.js';
|
|
6
6
|
export function pluginRsdoctor(options) {
|
|
7
7
|
return {
|
|
@@ -22,16 +22,23 @@ export function pluginRsdoctor(options) {
|
|
|
22
22
|
continue;
|
|
23
23
|
}
|
|
24
24
|
config.plugins ??= [];
|
|
25
|
-
|
|
25
|
+
const defaultOptions = {
|
|
26
26
|
// We disable client server on CI by default.
|
|
27
27
|
// But it can be overridden by `tools.rsdoctor`.
|
|
28
28
|
disableClientServer: isCI(),
|
|
29
|
-
...options,
|
|
30
29
|
supports: {
|
|
31
|
-
...options?.supports,
|
|
32
30
|
banner: true, // We must enable `supports.banner` since we have runtime wrapper enabled
|
|
33
31
|
},
|
|
34
|
-
|
|
32
|
+
linter: {
|
|
33
|
+
rules: {
|
|
34
|
+
'ecma-version-check': options?.linter?.rules?.['ecma-version-check'] ?? [
|
|
35
|
+
'Warn',
|
|
36
|
+
{ ecmaVersion: 2019 },
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
config.plugins.push(new RsdoctorRspackPlugin(mergeRsbuildConfig(defaultOptions, options)));
|
|
35
42
|
}
|
|
36
43
|
logger.info(`Rsdoctor is enabled.`);
|
|
37
44
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/rspeedy",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.6",
|
|
4
4
|
"description": "A webpack/rspack-based frontend toolchain for Lynx",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@microsoft/api-extractor": "7.51.1",
|
|
52
52
|
"@rsbuild/core": "1.2.19",
|
|
53
53
|
"@rsbuild/plugin-css-minimizer": "1.0.2",
|
|
54
|
-
"@rsdoctor/rspack-plugin": "1.0.0
|
|
54
|
+
"@rsdoctor/rspack-plugin": "1.0.0",
|
|
55
55
|
"chokidar": "^4.0.3",
|
|
56
56
|
"commander": "^13.1.0",
|
|
57
57
|
"exit-hook": "^4.0.0",
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
70
70
|
"@rsbuild/webpack": "1.2.3",
|
|
71
71
|
"eventemitter3": "^5.0.1",
|
|
72
|
-
"type-fest": "^4.
|
|
73
|
-
"vitest": "^3.0.
|
|
72
|
+
"type-fest": "^4.38.0",
|
|
73
|
+
"vitest": "^3.0.9",
|
|
74
74
|
"webpack": "^5.98.0",
|
|
75
75
|
"@lynx-js/vitest-setup": "0.0.0"
|
|
76
76
|
},
|