@rsbuild/core 0.0.24 → 0.0.26
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/bin/rsbuild.js +4 -25
- package/compiled/jiti/index.js +1885 -0
- package/compiled/jiti/license +21 -0
- package/compiled/jiti/package.json +1 -0
- package/compiled/jiti/types/jiti.d.ts +19 -0
- package/compiled/jiti/types/types.d.ts +31 -0
- package/compiled/sirv/index.js +1 -0
- package/compiled/sirv/package.json +1 -0
- package/compiled/sirv/sirv.d.ts +27 -0
- package/dist/cli/commands.d.ts +8 -4
- package/dist/cli/commands.js +49 -10
- package/dist/cli/config.d.ts +2 -2
- package/dist/cli/config.js +15 -6
- package/dist/cli/prepare.d.ts +1 -0
- package/dist/cli/{run.js → prepare.js} +19 -17
- package/dist/createRsbuild.d.ts +1 -2
- package/dist/createRsbuild.js +4 -10
- package/dist/index.d.ts +9 -4
- package/dist/index.js +2 -4
- package/dist/plugins/asset.d.ts +2 -2
- package/dist/plugins/bundleAnalyzer.d.ts +2 -2
- package/dist/plugins/cache.d.ts +2 -2
- package/dist/plugins/cache.js +0 -3
- package/dist/plugins/cleanOutput.d.ts +2 -2
- package/dist/plugins/define.d.ts +2 -2
- package/dist/plugins/devtool.d.ts +2 -2
- package/dist/plugins/entry.d.ts +1 -1
- package/dist/plugins/externals.d.ts +2 -2
- package/dist/plugins/fileSize.d.ts +2 -2
- package/dist/plugins/fileSize.js +2 -2
- package/dist/plugins/html.d.ts +3 -2
- package/dist/plugins/inlineChunk.d.ts +2 -2
- package/dist/plugins/moment.d.ts +2 -2
- package/dist/plugins/networkPerformance.d.ts +2 -2
- package/dist/plugins/nodeAddons.d.ts +2 -2
- package/dist/plugins/performance.d.ts +2 -2
- package/dist/plugins/preloadOrPrefetch.d.ts +2 -2
- package/dist/plugins/splitChunks.d.ts +2 -2
- package/dist/plugins/startUrl.d.ts +2 -2
- package/dist/plugins/target.d.ts +2 -2
- package/dist/plugins/toml.d.ts +2 -2
- package/dist/plugins/wasm.d.ts +2 -2
- package/dist/plugins/yaml.d.ts +2 -2
- package/dist/{rspack-provider/rspackPlugin/removeCssSourcemapPlugin.js → rspack-plugins/RemoveCssSourcemapPlugin.js} +3 -3
- package/dist/rspack-provider/config.d.ts +9 -0
- package/dist/rspack-provider/{config/defaults.js → config.js} +9 -3
- package/dist/rspack-provider/core/createCompiler.d.ts +1 -1
- package/dist/rspack-provider/core/createContext.d.ts +8 -2
- package/dist/rspack-provider/core/createContext.js +90 -5
- package/dist/rspack-provider/core/initConfigs.d.ts +1 -1
- package/dist/rspack-provider/core/initConfigs.js +4 -3
- package/dist/rspack-provider/core/initHooks.d.ts +2 -2
- package/dist/rspack-provider/core/initPlugins.d.ts +1 -1
- package/dist/rspack-provider/core/initPlugins.js +2 -1
- package/dist/rspack-provider/core/rspackConfig.d.ts +1 -1
- package/dist/rspack-provider/index.d.ts +3 -3
- package/dist/rspack-provider/index.js +11 -4
- package/dist/rspack-provider/plugins/basic.d.ts +1 -1
- package/dist/rspack-provider/plugins/css.d.ts +1 -1
- package/dist/rspack-provider/plugins/css.js +3 -11
- package/dist/rspack-provider/plugins/hmr.d.ts +1 -1
- package/dist/rspack-provider/plugins/less.d.ts +1 -1
- package/dist/rspack-provider/plugins/minimize.d.ts +1 -1
- package/dist/rspack-provider/plugins/output.d.ts +1 -1
- package/dist/rspack-provider/plugins/progress.d.ts +1 -1
- package/dist/rspack-provider/plugins/resolve.d.ts +1 -1
- package/dist/rspack-provider/plugins/rspackProfile.d.ts +1 -1
- package/dist/rspack-provider/plugins/sass.d.ts +1 -1
- package/dist/rspack-provider/plugins/swc.d.ts +1 -1
- package/dist/rspack-provider/plugins/transition.d.ts +1 -1
- package/dist/rspack-provider/provider.d.ts +1 -1
- package/dist/rspack-provider/provider.js +5 -6
- package/dist/rspack-provider/shared.d.ts +8 -0
- package/dist/rspack-provider/shared.js +116 -0
- package/dist/server/prodServer.js +1 -1
- package/dist/server/restart.js +2 -4
- package/dist/types.d.ts +19 -0
- package/dist/{rspack-provider/types/plugin.js → types.js} +2 -2
- package/package.json +5 -7
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.js +0 -31
- package/dist/cli/run.d.ts +0 -5
- package/dist/rspack-provider/config/defaults.d.ts +0 -3
- package/dist/rspack-provider/config/normalize.d.ts +0 -7
- package/dist/rspack-provider/config/normalize.js +0 -33
- package/dist/rspack-provider/shared/constants.d.ts +0 -1
- package/dist/rspack-provider/shared/constants.js +0 -28
- package/dist/rspack-provider/shared/fs.d.ts +0 -1
- package/dist/rspack-provider/shared/fs.js +0 -38
- package/dist/rspack-provider/shared/index.d.ts +0 -3
- package/dist/rspack-provider/shared/index.js +0 -26
- package/dist/rspack-provider/shared/plugin.d.ts +0 -3
- package/dist/rspack-provider/shared/plugin.js +0 -75
- package/dist/rspack-provider/shared/rspackVersion.d.ts +0 -3
- package/dist/rspack-provider/shared/rspackVersion.js +0 -61
- package/dist/rspack-provider/types/context.d.ts +0 -16
- package/dist/rspack-provider/types/context.js +0 -16
- package/dist/rspack-provider/types/index.d.ts +0 -3
- package/dist/rspack-provider/types/index.js +0 -24
- package/dist/rspack-provider/types/plugin.d.ts +0 -4
- /package/dist/{rspack-provider/rspackPlugin/removeCssSourcemapPlugin.d.ts → rspack-plugins/RemoveCssSourcemapPlugin.d.ts} +0 -0
- /package/dist/rspack-provider/{rspackLoader/css-modules-typescript-pre-loader → css-modules-typescript-pre-loader}/index.d.ts +0 -0
- /package/dist/rspack-provider/{rspackLoader/css-modules-typescript-pre-loader → css-modules-typescript-pre-loader}/index.js +0 -0
- /package/dist/rspack-provider/{rspackLoader/css-modules-typescript-pre-loader → css-modules-typescript-pre-loader}/postcss-icss-extract-plugin.d.ts +0 -0
- /package/dist/rspack-provider/{rspackLoader/css-modules-typescript-pre-loader → css-modules-typescript-pre-loader}/postcss-icss-extract-plugin.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { RsbuildPlugin } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* This method is modified based on source found in
|
|
4
4
|
* https://github.com/facebook/create-react-app
|
|
@@ -9,4 +9,4 @@ import { type DefaultRsbuildPlugin } from '@rsbuild/shared';
|
|
|
9
9
|
*/
|
|
10
10
|
export declare function openBrowser(url: string): Promise<boolean>;
|
|
11
11
|
export declare const replacePlaceholder: (url: string, port: number) => string;
|
|
12
|
-
export declare function pluginStartUrl():
|
|
12
|
+
export declare function pluginStartUrl(): RsbuildPlugin;
|
package/dist/plugins/target.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const pluginTarget: () =>
|
|
1
|
+
import type { RsbuildPlugin } from '../types';
|
|
2
|
+
export declare const pluginTarget: () => RsbuildPlugin;
|
package/dist/plugins/toml.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const pluginToml: () =>
|
|
1
|
+
import type { RsbuildPlugin } from '../types';
|
|
2
|
+
export declare const pluginToml: () => RsbuildPlugin;
|
package/dist/plugins/wasm.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const pluginWasm: () =>
|
|
1
|
+
import type { RsbuildPlugin } from '../types';
|
|
2
|
+
export declare const pluginWasm: () => RsbuildPlugin;
|
package/dist/plugins/yaml.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const pluginYaml: () =>
|
|
1
|
+
import type { RsbuildPlugin } from '../types';
|
|
2
|
+
export declare const pluginYaml: () => RsbuildPlugin;
|
|
@@ -16,11 +16,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var RemoveCssSourcemapPlugin_exports = {};
|
|
20
|
+
__export(RemoveCssSourcemapPlugin_exports, {
|
|
21
21
|
RemoveCssSourcemapPlugin: () => RemoveCssSourcemapPlugin
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(RemoveCssSourcemapPlugin_exports);
|
|
24
24
|
var import_shared = require("@rsbuild/shared");
|
|
25
25
|
class RemoveCssSourcemapPlugin {
|
|
26
26
|
constructor(htmlPlugin) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type RsbuildConfig, type NormalizedConfig } from '@rsbuild/shared';
|
|
2
|
+
export declare const createDefaultConfig: () => RsbuildConfig;
|
|
3
|
+
export declare const withDefaultConfig: (config: RsbuildConfig) => RsbuildConfig;
|
|
4
|
+
/** #__PURE__
|
|
5
|
+
* 1. May used by multiple plugins.
|
|
6
|
+
* 2. Object value that should not be empty.
|
|
7
|
+
* 3. Meaningful and can be filled by constant value.
|
|
8
|
+
*/
|
|
9
|
+
export declare const normalizeConfig: (config: RsbuildConfig) => NormalizedConfig;
|
|
@@ -16,12 +16,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var config_exports = {};
|
|
20
|
+
__export(config_exports, {
|
|
21
21
|
createDefaultConfig: () => createDefaultConfig,
|
|
22
|
+
normalizeConfig: () => normalizeConfig,
|
|
22
23
|
withDefaultConfig: () => withDefaultConfig
|
|
23
24
|
});
|
|
24
|
-
module.exports = __toCommonJS(
|
|
25
|
+
module.exports = __toCommonJS(config_exports);
|
|
25
26
|
var import_shared = require("@rsbuild/shared");
|
|
26
27
|
const createDefaultConfig = () => ({
|
|
27
28
|
dev: (0, import_shared.getDefaultDevConfig)(),
|
|
@@ -33,8 +34,13 @@ const createDefaultConfig = () => ({
|
|
|
33
34
|
performance: (0, import_shared.getDefaultPerformanceConfig)()
|
|
34
35
|
});
|
|
35
36
|
const withDefaultConfig = (config) => (0, import_shared.mergeRsbuildConfig)(createDefaultConfig(), config);
|
|
37
|
+
const normalizeConfig = (config) => (0, import_shared.mergeRsbuildConfig)(
|
|
38
|
+
createDefaultConfig(),
|
|
39
|
+
config
|
|
40
|
+
);
|
|
36
41
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
42
|
0 && (module.exports = {
|
|
38
43
|
createDefaultConfig,
|
|
44
|
+
normalizeConfig,
|
|
39
45
|
withDefaultConfig
|
|
40
46
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type RspackConfig } from '@rsbuild/shared';
|
|
2
2
|
import { type RspackCompiler, type RspackMultiCompiler } from '@rsbuild/shared';
|
|
3
3
|
import { type InitConfigsOptions } from './initConfigs';
|
|
4
|
-
import type { Context } from '
|
|
4
|
+
import type { Context } from '../../types';
|
|
5
5
|
export declare function createCompiler({
|
|
6
6
|
context,
|
|
7
7
|
rspackConfigs
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import { type CreateRsbuildOptions } from '@rsbuild/shared';
|
|
2
|
-
import type { Context
|
|
1
|
+
import { RsbuildConfig, type Context as BaseContext, type BundlerType, type SourceConfig, type OutputConfig, type NormalizedConfig, type CreateRsbuildOptions } from '@rsbuild/shared';
|
|
2
|
+
import type { Context } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Create context by config.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createContextByConfig(options: Required<CreateRsbuildOptions>, bundlerType: BundlerType, sourceConfig?: SourceConfig, outputConfig?: OutputConfig): BaseContext;
|
|
7
|
+
export declare function updateContextByNormalizedConfig(context: BaseContext, config: NormalizedConfig): void;
|
|
8
|
+
export declare function createPublicContext(context: BaseContext): Readonly<BaseContext>;
|
|
3
9
|
/**
|
|
4
10
|
* Generate the actual context used in the build,
|
|
5
11
|
* which can have a lot of overhead and take some side effects.
|
|
@@ -18,16 +18,98 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var createContext_exports = {};
|
|
20
20
|
__export(createContext_exports, {
|
|
21
|
-
createContext: () => createContext
|
|
21
|
+
createContext: () => createContext,
|
|
22
|
+
createContextByConfig: () => createContextByConfig,
|
|
23
|
+
createPublicContext: () => createPublicContext,
|
|
24
|
+
updateContextByNormalizedConfig: () => updateContextByNormalizedConfig
|
|
22
25
|
});
|
|
23
26
|
module.exports = __toCommonJS(createContext_exports);
|
|
24
27
|
var import_path = require("path");
|
|
25
28
|
var import_shared = require("@rsbuild/shared");
|
|
26
29
|
var import_initHooks = require("./initHooks");
|
|
27
|
-
var
|
|
30
|
+
var import_config = require("../config");
|
|
31
|
+
function getDefaultEntry(root) {
|
|
32
|
+
const files = [
|
|
33
|
+
// Most projects are using typescript now.
|
|
34
|
+
// So we put `.ts` as the first one to improve performance.
|
|
35
|
+
"ts",
|
|
36
|
+
"js",
|
|
37
|
+
"tsx",
|
|
38
|
+
"jsx",
|
|
39
|
+
".mjs",
|
|
40
|
+
".cjs"
|
|
41
|
+
].map((ext) => (0, import_path.join)(root, `src/index.${ext}`));
|
|
42
|
+
const entryFile = (0, import_shared.findExists)(files);
|
|
43
|
+
if (entryFile) {
|
|
44
|
+
return {
|
|
45
|
+
index: entryFile
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return {};
|
|
49
|
+
}
|
|
50
|
+
function createContextByConfig(options, bundlerType, sourceConfig = {}, outputConfig = {}) {
|
|
51
|
+
const { cwd, target } = options;
|
|
52
|
+
const rootPath = cwd;
|
|
53
|
+
const distPath = (0, import_shared.getAbsoluteDistPath)(cwd, outputConfig);
|
|
54
|
+
const cachePath = (0, import_path.join)(rootPath, "node_modules", ".cache");
|
|
55
|
+
if (sourceConfig.entries) {
|
|
56
|
+
import_shared.logger.warn(
|
|
57
|
+
"[Rsbuild] `source.entries` option has been renamed to `source.entry`, please update the Rsbuild config."
|
|
58
|
+
);
|
|
59
|
+
import_shared.logger.warn(
|
|
60
|
+
"[Rsbuild] `source.entries` option will be removed in Rsbuild v0.2.0."
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
const context = {
|
|
64
|
+
entry: sourceConfig.entry || // TODO: remove sourceConfig.entries in v0.2.0
|
|
65
|
+
// compat with previous config
|
|
66
|
+
sourceConfig.entries || getDefaultEntry(rootPath),
|
|
67
|
+
version: "0.0.26",
|
|
68
|
+
target,
|
|
69
|
+
rootPath,
|
|
70
|
+
distPath,
|
|
71
|
+
cachePath,
|
|
72
|
+
bundlerType
|
|
73
|
+
};
|
|
74
|
+
return context;
|
|
75
|
+
}
|
|
76
|
+
function updateContextByNormalizedConfig(context, config) {
|
|
77
|
+
context.distPath = (0, import_shared.getAbsoluteDistPath)(context.rootPath, config.output);
|
|
78
|
+
if (config.source.entry) {
|
|
79
|
+
context.entry = config.source.entry;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function createPublicContext(context) {
|
|
83
|
+
const exposedKeys = [
|
|
84
|
+
"entry",
|
|
85
|
+
"target",
|
|
86
|
+
"version",
|
|
87
|
+
"rootPath",
|
|
88
|
+
"distPath",
|
|
89
|
+
"devServer",
|
|
90
|
+
"cachePath",
|
|
91
|
+
"configPath",
|
|
92
|
+
"tsconfigPath",
|
|
93
|
+
"bundlerType"
|
|
94
|
+
];
|
|
95
|
+
return new Proxy(context, {
|
|
96
|
+
get(target, prop) {
|
|
97
|
+
if (exposedKeys.includes(prop)) {
|
|
98
|
+
return target[prop];
|
|
99
|
+
}
|
|
100
|
+
return void 0;
|
|
101
|
+
},
|
|
102
|
+
set(_, prop) {
|
|
103
|
+
import_shared.logger.error(
|
|
104
|
+
`Context is readonly, you can not assign to the "context.${prop}" prop.`
|
|
105
|
+
);
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
28
110
|
async function createContext(options, userRsbuildConfig) {
|
|
29
|
-
const rsbuildConfig = (0,
|
|
30
|
-
const context =
|
|
111
|
+
const rsbuildConfig = (0, import_config.withDefaultConfig)(userRsbuildConfig);
|
|
112
|
+
const context = createContextByConfig(
|
|
31
113
|
options,
|
|
32
114
|
"rspack",
|
|
33
115
|
rsbuildConfig.source,
|
|
@@ -44,5 +126,8 @@ async function createContext(options, userRsbuildConfig) {
|
|
|
44
126
|
}
|
|
45
127
|
// Annotate the CommonJS export names for ESM import in node:
|
|
46
128
|
0 && (module.exports = {
|
|
47
|
-
createContext
|
|
129
|
+
createContext,
|
|
130
|
+
createContextByConfig,
|
|
131
|
+
createPublicContext,
|
|
132
|
+
updateContextByNormalizedConfig
|
|
48
133
|
});
|
|
@@ -22,9 +22,10 @@ __export(initConfigs_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(initConfigs_exports);
|
|
24
24
|
var import_shared = require("@rsbuild/shared");
|
|
25
|
+
var import_createContext = require("./createContext");
|
|
25
26
|
var import_inspectConfig = require("./inspectConfig");
|
|
26
27
|
var import_rspackConfig = require("./rspackConfig");
|
|
27
|
-
var
|
|
28
|
+
var import_config = require("../config");
|
|
28
29
|
async function modifyRsbuildConfig(context) {
|
|
29
30
|
(0, import_shared.debug)("modify Rsbuild config");
|
|
30
31
|
const [modified] = await context.hooks.modifyRsbuildConfigHook.call(
|
|
@@ -44,8 +45,8 @@ async function initConfigs({
|
|
|
44
45
|
pluginStore
|
|
45
46
|
});
|
|
46
47
|
await modifyRsbuildConfig(context);
|
|
47
|
-
context.normalizedConfig = (0,
|
|
48
|
-
(0,
|
|
48
|
+
context.normalizedConfig = (0, import_config.normalizeConfig)(context.config);
|
|
49
|
+
(0, import_createContext.updateContextByNormalizedConfig)(context, context.normalizedConfig);
|
|
49
50
|
const targets = (0, import_shared.castArray)(rsbuildOptions.target);
|
|
50
51
|
const rspackConfigs = await Promise.all(
|
|
51
52
|
targets.map((target) => (0, import_rspackConfig.generateRspackConfig)({ target, context }))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { OnExitFn, OnAfterBuildFn, OnBeforeBuildFn, OnDevCompileDoneFn, ModifyRsbuildConfigFn, OnAfterStartDevServerFn, OnBeforeStartDevServerFn, OnAfterCreateCompilerFn, OnBeforeCreateCompilerFn, ModifyBundlerChainFn, type RspackConfig, type ModifyRspackConfigFn } from '@rsbuild/shared';
|
|
2
|
-
import type { RsbuildConfig } from '
|
|
1
|
+
import { type OnExitFn, type OnAfterBuildFn, type OnBeforeBuildFn, type OnDevCompileDoneFn, type ModifyRsbuildConfigFn, type OnAfterStartDevServerFn, type OnBeforeStartDevServerFn, type OnAfterCreateCompilerFn, type OnBeforeCreateCompilerFn, type ModifyBundlerChainFn, type RspackConfig, type ModifyRspackConfigFn } from '@rsbuild/shared';
|
|
2
|
+
import type { RsbuildConfig } from '../../types';
|
|
3
3
|
import type { Compiler, MultiCompiler } from '@rspack/core';
|
|
4
4
|
export declare function initHooks(): {
|
|
5
5
|
/** parameters are not bundler-related */
|
|
@@ -22,12 +22,13 @@ __export(initPlugins_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(initPlugins_exports);
|
|
24
24
|
var import_shared = require("@rsbuild/shared");
|
|
25
|
+
var import_createContext = require("./createContext");
|
|
25
26
|
function getPluginAPI({
|
|
26
27
|
context,
|
|
27
28
|
pluginStore
|
|
28
29
|
}) {
|
|
29
30
|
const { hooks } = context;
|
|
30
|
-
const publicContext = (0,
|
|
31
|
+
const publicContext = (0, import_createContext.createPublicContext)(context);
|
|
31
32
|
const getRsbuildConfig = () => {
|
|
32
33
|
if (!context.normalizedConfig) {
|
|
33
34
|
throw new Error(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { getRspackVersion } from './shared
|
|
1
|
+
export { getRspackVersion } from './shared';
|
|
2
2
|
export { rspackProvider } from './provider';
|
|
3
3
|
export type { RspackProvider } from './provider';
|
|
4
|
-
export type {
|
|
5
|
-
export
|
|
4
|
+
export type { Rspack, RspackConfig } from '@rsbuild/shared';
|
|
5
|
+
export { createPublicContext, createContextByConfig, updateContextByNormalizedConfig } from './core/createContext';
|
|
@@ -18,14 +18,21 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var rspack_provider_exports = {};
|
|
20
20
|
__export(rspack_provider_exports, {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
createContextByConfig: () => import_createContext.createContextByConfig,
|
|
22
|
+
createPublicContext: () => import_createContext.createPublicContext,
|
|
23
|
+
getRspackVersion: () => import_shared.getRspackVersion,
|
|
24
|
+
rspackProvider: () => import_provider.rspackProvider,
|
|
25
|
+
updateContextByNormalizedConfig: () => import_createContext.updateContextByNormalizedConfig
|
|
23
26
|
});
|
|
24
27
|
module.exports = __toCommonJS(rspack_provider_exports);
|
|
25
|
-
var
|
|
28
|
+
var import_shared = require("./shared");
|
|
26
29
|
var import_provider = require("./provider");
|
|
30
|
+
var import_createContext = require("./core/createContext");
|
|
27
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28
32
|
0 && (module.exports = {
|
|
33
|
+
createContextByConfig,
|
|
34
|
+
createPublicContext,
|
|
29
35
|
getRspackVersion,
|
|
30
|
-
rspackProvider
|
|
36
|
+
rspackProvider,
|
|
37
|
+
updateContextByNormalizedConfig
|
|
31
38
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type BundlerChain, type Context, type RspackRule, type ModifyBundlerChainUtils } from '@rsbuild/shared';
|
|
2
|
-
import type { RsbuildPlugin, NormalizedConfig } from '
|
|
2
|
+
import type { RsbuildPlugin, NormalizedConfig } from '../../types';
|
|
3
3
|
export declare const enableNativeCss: (config: NormalizedConfig) => boolean;
|
|
4
4
|
export declare function applyBaseCSSRule({
|
|
5
5
|
rule,
|
|
@@ -45,7 +45,6 @@ async function applyBaseCSSRule({
|
|
|
45
45
|
utils: { target, isProd, isServer, isWebWorker, CHAIN_ID },
|
|
46
46
|
importLoaders = 1
|
|
47
47
|
}) {
|
|
48
|
-
const enableExtractCSS = (0, import_shared.isUseCssExtract)(config, target);
|
|
49
48
|
const enableSourceMap = (0, import_shared.isUseCssSourceMap)(config);
|
|
50
49
|
const enableCSSModuleTS = Boolean(config.output.enableCssModuleTSDeclaration);
|
|
51
50
|
const browserslist = await (0, import_shared.getBrowserslistWithDefault)(
|
|
@@ -53,7 +52,6 @@ async function applyBaseCSSRule({
|
|
|
53
52
|
config,
|
|
54
53
|
target
|
|
55
54
|
);
|
|
56
|
-
const enableCssMinify = !enableExtractCSS && isProd;
|
|
57
55
|
if (!enableNativeCss(config)) {
|
|
58
56
|
const localIdentName = (0, import_shared.getCssModuleLocalIdentName)(config, isProd);
|
|
59
57
|
const cssLoaderOptions = (0, import_shared.getCssLoaderOptions)({
|
|
@@ -91,12 +89,7 @@ async function applyBaseCSSRule({
|
|
|
91
89
|
} else {
|
|
92
90
|
if (!isServer && !isWebWorker && enableCSSModuleTS) {
|
|
93
91
|
const { cssModules } = config.output;
|
|
94
|
-
rule.use(CHAIN_ID.USE.CSS_MODULES_TS).loader(
|
|
95
|
-
import_path.default.resolve(
|
|
96
|
-
__dirname,
|
|
97
|
-
"../rspackLoader/css-modules-typescript-pre-loader"
|
|
98
|
-
)
|
|
99
|
-
).options({
|
|
92
|
+
rule.use(CHAIN_ID.USE.CSS_MODULES_TS).loader(import_path.default.resolve(__dirname, "../css-modules-typescript-pre-loader")).options({
|
|
100
93
|
modules: {
|
|
101
94
|
exportLocalsConvention: cssModules.exportLocalsConvention,
|
|
102
95
|
auto: cssModules.auto
|
|
@@ -109,8 +102,7 @@ async function applyBaseCSSRule({
|
|
|
109
102
|
const postcssLoaderOptions = (0, import_shared.getPostcssConfig)({
|
|
110
103
|
enableSourceMap,
|
|
111
104
|
browserslist,
|
|
112
|
-
config
|
|
113
|
-
enableCssMinify
|
|
105
|
+
config
|
|
114
106
|
});
|
|
115
107
|
rule.use(CHAIN_ID.USE.POSTCSS).loader((0, import_shared2.getCompiledPath)("postcss-loader")).options(postcssLoaderOptions).end();
|
|
116
108
|
}
|
|
@@ -166,7 +158,7 @@ const pluginCss = () => {
|
|
|
166
158
|
const enableSourceMap = (0, import_shared.isUseCssSourceMap)(config);
|
|
167
159
|
const enableExtractCSS = (0, import_shared.isUseCssExtract)(config, utils.target);
|
|
168
160
|
if (!enableSourceMap && enableExtractCSS) {
|
|
169
|
-
const { RemoveCssSourcemapPlugin } = await Promise.resolve().then(() => __toESM(require("
|
|
161
|
+
const { RemoveCssSourcemapPlugin } = await Promise.resolve().then(() => __toESM(require("../../rspack-plugins/RemoveCssSourcemapPlugin")));
|
|
170
162
|
chain.plugin("remove-css-sourcemap").use(RemoveCssSourcemapPlugin, [utils.HtmlPlugin]);
|
|
171
163
|
}
|
|
172
164
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { RsbuildPlugin } from '
|
|
1
|
+
import type { RsbuildPlugin } from '../../types';
|
|
2
2
|
export declare const pluginHMR: () => RsbuildPlugin;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { RsbuildPlugin } from '
|
|
1
|
+
import type { RsbuildPlugin } from '../../types';
|
|
2
2
|
export declare function pluginLess(): RsbuildPlugin;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type BundlerChain } from '@rsbuild/shared';
|
|
2
|
-
import type { RsbuildPlugin, NormalizedConfig } from '
|
|
2
|
+
import type { RsbuildPlugin, NormalizedConfig } from '../../types';
|
|
3
3
|
export declare function applyJSMinimizer(chain: BundlerChain, config: NormalizedConfig): void;
|
|
4
4
|
export declare function applyCSSMinimizer(chain: BundlerChain): void;
|
|
5
5
|
export declare const pluginMinimize: () => RsbuildPlugin;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { RsbuildPlugin } from '
|
|
1
|
+
import type { RsbuildPlugin } from '../../types';
|
|
2
2
|
export declare const pluginOutput: () => RsbuildPlugin;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { RsbuildPlugin } from '
|
|
1
|
+
import type { RsbuildPlugin } from '../../types';
|
|
2
2
|
export declare const pluginProgress: () => RsbuildPlugin;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { RsbuildPlugin } from '
|
|
1
|
+
import type { RsbuildPlugin } from '../../types';
|
|
2
2
|
export declare const pluginResolve: () => RsbuildPlugin;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RsbuildPlugin } from '
|
|
1
|
+
import type { RsbuildPlugin } from '../../types';
|
|
2
2
|
import inspector from 'inspector';
|
|
3
3
|
export declare const stopProfiler: (output: string, profileSession?: inspector.Session) => void;
|
|
4
4
|
export declare const pluginRspackProfile: () => RsbuildPlugin;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { RsbuildPlugin } from '
|
|
1
|
+
import type { RsbuildPlugin } from '../../types';
|
|
2
2
|
export declare function pluginSass(): RsbuildPlugin;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type RsbuildTarget, type BuiltinSwcLoaderOptions } from '@rsbuild/shared';
|
|
2
|
-
import type { RsbuildPlugin, NormalizedConfig } from '
|
|
2
|
+
import type { RsbuildPlugin, NormalizedConfig } from '../../types';
|
|
3
3
|
export declare function getDefaultSwcConfig(config: NormalizedConfig, rootPath: string, target: RsbuildTarget): Promise<BuiltinSwcLoaderOptions>;
|
|
4
4
|
/**
|
|
5
5
|
* Provide some swc configs of rspack
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type RsbuildProvider, type RspackConfig, type RspackCompiler, type RspackMultiCompiler } from '@rsbuild/shared';
|
|
2
|
-
import type { RsbuildConfig, NormalizedConfig } from '
|
|
2
|
+
import type { RsbuildConfig, NormalizedConfig } from '../types';
|
|
3
3
|
export type RspackProvider = RsbuildProvider<RsbuildConfig, RspackConfig, NormalizedConfig, RspackCompiler | RspackMultiCompiler>;
|
|
4
4
|
export declare function rspackProvider({
|
|
5
5
|
rsbuildConfig: originalRsbuildConfig
|
|
@@ -35,17 +35,16 @@ var import_shared = require("@rsbuild/shared");
|
|
|
35
35
|
var import_createContext = require("./core/createContext");
|
|
36
36
|
var import_initConfigs = require("./core/initConfigs");
|
|
37
37
|
var import_initPlugins = require("./core/initPlugins");
|
|
38
|
-
var
|
|
39
|
-
var import_rspackVersion = require("./shared/rspackVersion");
|
|
38
|
+
var import_shared2 = require("./shared");
|
|
40
39
|
function rspackProvider({
|
|
41
40
|
rsbuildConfig: originalRsbuildConfig
|
|
42
41
|
}) {
|
|
43
42
|
const rsbuildConfig = (0, import_shared.pickRsbuildConfig)(originalRsbuildConfig);
|
|
44
43
|
return async ({ pluginStore, rsbuildOptions, plugins }) => {
|
|
45
|
-
if (!await (0,
|
|
44
|
+
if (!await (0, import_shared2.isSatisfyRspackMinimumVersion)()) {
|
|
46
45
|
throw new Error(
|
|
47
46
|
`The current Rspack version does not meet the requirements, the minimum supported version of Rspack is ${import_shared.color.green(
|
|
48
|
-
|
|
47
|
+
import_shared2.supportedRspackMinimumVersion
|
|
49
48
|
)}`
|
|
50
49
|
);
|
|
51
50
|
}
|
|
@@ -55,9 +54,9 @@ function rspackProvider({
|
|
|
55
54
|
return {
|
|
56
55
|
bundler: "rspack",
|
|
57
56
|
pluginAPI,
|
|
58
|
-
publicContext: (0,
|
|
57
|
+
publicContext: (0, import_createContext.createPublicContext)(context),
|
|
59
58
|
async applyDefaultPlugins() {
|
|
60
|
-
pluginStore.addPlugins(await (0,
|
|
59
|
+
pluginStore.addPlugins(await (0, import_shared2.applyDefaultPlugins)(plugins));
|
|
61
60
|
},
|
|
62
61
|
async createCompiler() {
|
|
63
62
|
const { createCompiler } = await Promise.resolve().then(() => __toESM(require("./core/createCompiler")));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RsbuildPlugin } from '../types';
|
|
2
|
+
import { Plugins } from '@rsbuild/shared';
|
|
3
|
+
export declare const applyDefaultPlugins: (plugins: Plugins) => import("@rsbuild/shared").AwaitableGetter<RsbuildPlugin>;
|
|
4
|
+
export declare const getRspackVersion: () => Promise<string>;
|
|
5
|
+
export declare const supportedRspackMinimumVersion = "0.3.6";
|
|
6
|
+
export declare const isSatisfyRspackMinimumVersion: (customVersion?: string) => Promise<boolean>;
|
|
7
|
+
export declare const getCompiledPath: (packageName: string) => string;
|
|
8
|
+
export declare const BUILTIN_LOADER = "builtin:";
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var shared_exports = {};
|
|
30
|
+
__export(shared_exports, {
|
|
31
|
+
BUILTIN_LOADER: () => BUILTIN_LOADER,
|
|
32
|
+
applyDefaultPlugins: () => applyDefaultPlugins,
|
|
33
|
+
getCompiledPath: () => getCompiledPath,
|
|
34
|
+
getRspackVersion: () => getRspackVersion,
|
|
35
|
+
isSatisfyRspackMinimumVersion: () => isSatisfyRspackMinimumVersion,
|
|
36
|
+
supportedRspackMinimumVersion: () => supportedRspackMinimumVersion
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(shared_exports);
|
|
39
|
+
var import_path = require("path");
|
|
40
|
+
var import_shared = require("@rsbuild/shared");
|
|
41
|
+
var import_shared2 = require("@rsbuild/shared");
|
|
42
|
+
var import_shared3 = require("@rsbuild/shared");
|
|
43
|
+
const applyDefaultPlugins = (plugins) => (0, import_shared3.awaitableGetter)([
|
|
44
|
+
Promise.resolve().then(() => __toESM(require("./plugins/transition"))).then((m) => m.pluginTransition()),
|
|
45
|
+
Promise.resolve().then(() => __toESM(require("./plugins/basic"))).then((m) => m.pluginBasic()),
|
|
46
|
+
plugins.entry(),
|
|
47
|
+
// plugins.cache(),
|
|
48
|
+
plugins.target(),
|
|
49
|
+
Promise.resolve().then(() => __toESM(require("./plugins/output"))).then((m) => m.pluginOutput()),
|
|
50
|
+
plugins.devtool(),
|
|
51
|
+
Promise.resolve().then(() => __toESM(require("./plugins/resolve"))).then((m) => m.pluginResolve()),
|
|
52
|
+
plugins.fileSize(),
|
|
53
|
+
// cleanOutput plugin should before the html plugin
|
|
54
|
+
plugins.cleanOutput(),
|
|
55
|
+
plugins.asset(),
|
|
56
|
+
plugins.html(),
|
|
57
|
+
plugins.wasm(),
|
|
58
|
+
plugins.moment(),
|
|
59
|
+
plugins.nodeAddons(),
|
|
60
|
+
plugins.define(),
|
|
61
|
+
Promise.resolve().then(() => __toESM(require("./plugins/css"))).then((m) => m.pluginCss()),
|
|
62
|
+
Promise.resolve().then(() => __toESM(require("./plugins/less"))).then((m) => m.pluginLess()),
|
|
63
|
+
Promise.resolve().then(() => __toESM(require("./plugins/sass"))).then((m) => m.pluginSass()),
|
|
64
|
+
Promise.resolve().then(() => __toESM(require("./plugins/minimize"))).then((m) => m.pluginMinimize()),
|
|
65
|
+
Promise.resolve().then(() => __toESM(require("./plugins/hmr"))).then((m) => m.pluginHMR()),
|
|
66
|
+
Promise.resolve().then(() => __toESM(require("./plugins/progress"))).then((m) => m.pluginProgress()),
|
|
67
|
+
Promise.resolve().then(() => __toESM(require("./plugins/swc"))).then((m) => m.pluginSwc()),
|
|
68
|
+
plugins.externals(),
|
|
69
|
+
plugins.toml(),
|
|
70
|
+
plugins.yaml(),
|
|
71
|
+
plugins.splitChunks(),
|
|
72
|
+
plugins.startUrl(),
|
|
73
|
+
plugins.inlineChunk(),
|
|
74
|
+
plugins.bundleAnalyzer(),
|
|
75
|
+
plugins.networkPerformance(),
|
|
76
|
+
plugins.preloadOrPrefetch(),
|
|
77
|
+
plugins.performance(),
|
|
78
|
+
Promise.resolve().then(() => __toESM(require("./plugins/rspackProfile"))).then((m) => m.pluginRspackProfile())
|
|
79
|
+
]);
|
|
80
|
+
const getRspackVersion = async () => {
|
|
81
|
+
try {
|
|
82
|
+
const core = require.resolve("@rspack/core");
|
|
83
|
+
const pkg = await Promise.resolve().then(() => __toESM(require((0, import_path.join)(core, "../../package.json"))));
|
|
84
|
+
return pkg == null ? void 0 : pkg.version;
|
|
85
|
+
} catch (err) {
|
|
86
|
+
console.error(err);
|
|
87
|
+
return "";
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const supportedRspackMinimumVersion = "0.3.6";
|
|
91
|
+
const isSatisfyRspackMinimumVersion = async (customVersion) => {
|
|
92
|
+
let version = customVersion || await getRspackVersion();
|
|
93
|
+
const semver = await Promise.resolve().then(() => __toESM(require("semver")));
|
|
94
|
+
if (version.includes("-canary")) {
|
|
95
|
+
version = version.split("-canary")[0];
|
|
96
|
+
}
|
|
97
|
+
return version ? semver.lte(supportedRspackMinimumVersion, version) : true;
|
|
98
|
+
};
|
|
99
|
+
const getCompiledPath = (packageName) => {
|
|
100
|
+
const providerCompilerPath = (0, import_path.join)(__dirname, "../../compiled", packageName);
|
|
101
|
+
if (import_shared2.fse.existsSync(providerCompilerPath)) {
|
|
102
|
+
return providerCompilerPath;
|
|
103
|
+
} else {
|
|
104
|
+
return (0, import_shared.getSharedPkgCompiledPath)(packageName);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
const BUILTIN_LOADER = "builtin:";
|
|
108
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
109
|
+
0 && (module.exports = {
|
|
110
|
+
BUILTIN_LOADER,
|
|
111
|
+
applyDefaultPlugins,
|
|
112
|
+
getCompiledPath,
|
|
113
|
+
getRspackVersion,
|
|
114
|
+
isSatisfyRspackMinimumVersion,
|
|
115
|
+
supportedRspackMinimumVersion
|
|
116
|
+
});
|