@rsbuild/core 0.1.8 → 0.2.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.
- package/compiled/commander/package.json +1 -1
- package/compiled/connect-history-api-fallback/package.json +1 -1
- package/compiled/dotenv/package.json +1 -1
- package/compiled/dotenv-expand/package.json +1 -1
- package/compiled/http-compression/package.json +1 -1
- package/compiled/open/package.json +1 -1
- package/compiled/sirv/package.json +1 -1
- package/compiled/ws/package.json +1 -1
- package/dist/cli/commands.js +6 -3
- package/dist/cli/config.d.ts +7 -1
- package/dist/cli/config.js +7 -4
- package/dist/cli/prepare.js +1 -1
- package/dist/createRsbuild.js +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -0
- package/dist/loadEnv.d.ts +2 -2
- package/dist/loadEnv.js +2 -2
- package/dist/plugins/asset.js +2 -2
- package/dist/plugins/basic.d.ts +5 -0
- package/dist/plugins/basic.js +68 -0
- package/dist/plugins/fileSize.js +1 -1
- package/dist/plugins/html.d.ts +1 -2
- package/dist/plugins/html.js +8 -8
- package/dist/plugins/index.js +2 -3
- package/dist/plugins/inlineChunk.js +25 -28
- package/dist/plugins/networkPerformance.js +3 -11
- package/dist/plugins/nodeAddons.js +1 -1
- package/dist/plugins/preloadOrPrefetch.js +4 -10
- package/dist/plugins/wasm.js +1 -1
- package/dist/provider/core/createCompiler.js +17 -9
- package/dist/provider/core/createContext.d.ts +3 -3
- package/dist/provider/core/createContext.js +13 -27
- package/dist/provider/core/initConfigs.d.ts +2 -2
- package/dist/provider/core/initConfigs.js +4 -3
- package/dist/provider/core/initPlugins.js +15 -12
- package/dist/provider/core/inspectConfig.d.ts +2 -20
- package/dist/provider/core/inspectConfig.js +6 -6
- package/dist/provider/css-modules-typescript-pre-loader/index.js +1 -1
- package/dist/provider/css-modules-typescript-pre-loader/{postcss-icss-extract-plugin.js → postcssIcssExtractPlugin.js} +5 -5
- package/dist/provider/index.d.ts +1 -2
- package/dist/provider/index.js +4 -7
- package/dist/provider/plugins/css.js +5 -10
- package/dist/provider/plugins/less.js +2 -2
- package/dist/provider/plugins/minimize.d.ts +1 -4
- package/dist/provider/plugins/minimize.js +18 -15
- package/dist/provider/plugins/output.js +2 -2
- package/dist/provider/plugins/resolve.js +0 -5
- package/dist/provider/plugins/rspackProfile.js +7 -4
- package/dist/provider/plugins/sass.js +2 -2
- package/dist/provider/plugins/server.d.ts +2 -0
- package/dist/provider/plugins/server.js +70 -0
- package/dist/provider/plugins/swc.js +1 -8
- package/dist/provider/provider.js +15 -1
- package/dist/provider/shared.d.ts +2 -3
- package/dist/provider/shared.js +4 -18
- package/dist/rspack/HtmlAppIconPlugin.d.ts +0 -3
- package/dist/rspack/HtmlAppIconPlugin.js +2 -2
- package/dist/rspack/HtmlBasicPlugin.d.ts +0 -3
- package/dist/rspack/HtmlBasicPlugin.js +24 -10
- package/dist/rspack/HtmlCrossOriginPlugin.d.ts +0 -3
- package/dist/rspack/HtmlCrossOriginPlugin.js +12 -2
- package/dist/rspack/HtmlNetworkPerformancePlugin.d.ts +1 -3
- package/dist/rspack/HtmlNetworkPerformancePlugin.js +13 -3
- package/dist/rspack/HtmlNoncePlugin.d.ts +0 -3
- package/dist/rspack/HtmlNoncePlugin.js +12 -2
- package/dist/rspack/HtmlTagsPlugin.d.ts +1 -7
- package/dist/rspack/HtmlTagsPlugin.js +12 -1
- package/dist/rspack/InlineChunkHtmlPlugin.d.ts +2 -3
- package/dist/rspack/InlineChunkHtmlPlugin.js +17 -3
- package/dist/rspack/RemoveCssSourcemapPlugin.d.ts +1 -3
- package/dist/rspack/RemoveCssSourcemapPlugin.js +1 -2
- package/dist/rspack/{HtmlPreloadOrPrefetchPlugin/index.d.ts → preload/HtmlPreloadOrPrefetchPlugin.d.ts} +3 -4
- package/dist/rspack/{HtmlPreloadOrPrefetchPlugin/index.js → preload/HtmlPreloadOrPrefetchPlugin.js} +17 -7
- package/dist/server/{dev-middleware → compiler-dev-middleware}/index.d.ts +2 -2
- package/dist/server/{dev-middleware → compiler-dev-middleware}/index.js +3 -3
- package/dist/server/{dev-middleware → compiler-dev-middleware}/socketServer.d.ts +2 -2
- package/dist/server/devMiddlewares.d.ts +7 -0
- package/dist/server/devMiddlewares.js +156 -0
- package/dist/server/devServer.d.ts +10 -23
- package/dist/server/devServer.js +77 -162
- package/dist/server/httpServer.d.ts +8 -0
- package/dist/server/httpServer.js +48 -0
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +2 -0
- package/dist/server/prodServer.d.ts +0 -5
- package/dist/server/prodServer.js +13 -27
- package/package.json +5 -4
- package/compiled/jiti/index.js +0 -1885
- package/compiled/jiti/license +0 -21
- package/compiled/jiti/package.json +0 -1
- package/compiled/jiti/types/jiti.d.ts +0 -19
- package/compiled/jiti/types/types.d.ts +0 -31
- package/dist/plugins/devtool.d.ts +0 -2
- package/dist/plugins/devtool.js +0 -46
- package/dist/plugins/server.d.ts +0 -2
- package/dist/plugins/server.js +0 -56
- package/dist/provider/plugins/basic.d.ts +0 -5
- package/dist/provider/plugins/basic.js +0 -34
- /package/dist/provider/css-modules-typescript-pre-loader/{postcss-icss-extract-plugin.d.ts → postcssIcssExtractPlugin.d.ts} +0 -0
- /package/dist/rspack/{HtmlPreloadOrPrefetchPlugin → preload}/helpers/determineAsValue.d.ts +0 -0
- /package/dist/rspack/{HtmlPreloadOrPrefetchPlugin → preload}/helpers/determineAsValue.js +0 -0
- /package/dist/rspack/{HtmlPreloadOrPrefetchPlugin → preload}/helpers/doesChunkBelongToHtml.d.ts +0 -0
- /package/dist/rspack/{HtmlPreloadOrPrefetchPlugin → preload}/helpers/doesChunkBelongToHtml.js +0 -0
- /package/dist/rspack/{HtmlPreloadOrPrefetchPlugin → preload}/helpers/extractChunks.d.ts +0 -0
- /package/dist/rspack/{HtmlPreloadOrPrefetchPlugin → preload}/helpers/extractChunks.js +0 -0
- /package/dist/rspack/{HtmlPreloadOrPrefetchPlugin → preload}/helpers/index.d.ts +0 -0
- /package/dist/rspack/{HtmlPreloadOrPrefetchPlugin → preload}/helpers/index.js +0 -0
- /package/dist/rspack/{HtmlPreloadOrPrefetchPlugin → preload}/helpers/type.d.ts +0 -0
- /package/dist/rspack/{HtmlPreloadOrPrefetchPlugin → preload}/helpers/type.js +0 -0
- /package/dist/server/{dev-middleware → compiler-dev-middleware}/socketServer.js +0 -0
|
@@ -47,29 +47,19 @@ function getDefaultEntry(root) {
|
|
|
47
47
|
}
|
|
48
48
|
return {};
|
|
49
49
|
}
|
|
50
|
-
function getAbsoluteDistPath(cwd,
|
|
51
|
-
const root = (0, import_shared.getDistPath)(
|
|
50
|
+
function getAbsoluteDistPath(cwd, config) {
|
|
51
|
+
const root = (0, import_shared.getDistPath)(config, "root");
|
|
52
52
|
return (0, import_path.isAbsolute)(root) ? root : (0, import_path.join)(cwd, root);
|
|
53
53
|
}
|
|
54
|
-
function createContextByConfig(options, bundlerType,
|
|
55
|
-
const { cwd
|
|
54
|
+
function createContextByConfig(options, bundlerType, config = {}) {
|
|
55
|
+
const { cwd } = options;
|
|
56
56
|
const rootPath = cwd;
|
|
57
|
-
const distPath = getAbsoluteDistPath(cwd,
|
|
57
|
+
const distPath = getAbsoluteDistPath(cwd, config);
|
|
58
58
|
const cachePath = (0, import_path.join)(rootPath, "node_modules", ".cache");
|
|
59
|
-
if (sourceConfig.entries) {
|
|
60
|
-
import_shared.logger.warn(
|
|
61
|
-
"[Rsbuild] `source.entries` option has been renamed to `source.entry`, please update the Rsbuild config."
|
|
62
|
-
);
|
|
63
|
-
import_shared.logger.warn(
|
|
64
|
-
"[Rsbuild] `source.entries` option will be removed in Rsbuild v0.2.0."
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
59
|
const context = {
|
|
68
|
-
entry:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
version: "0.1.8",
|
|
72
|
-
target,
|
|
60
|
+
entry: config.source?.entry || getDefaultEntry(rootPath),
|
|
61
|
+
targets: config.output?.targets || [],
|
|
62
|
+
version: "0.2.0",
|
|
73
63
|
rootPath,
|
|
74
64
|
distPath,
|
|
75
65
|
cachePath,
|
|
@@ -78,7 +68,8 @@ function createContextByConfig(options, bundlerType, sourceConfig = {}, outputCo
|
|
|
78
68
|
return context;
|
|
79
69
|
}
|
|
80
70
|
function updateContextByNormalizedConfig(context, config) {
|
|
81
|
-
context.
|
|
71
|
+
context.targets = config.output.targets;
|
|
72
|
+
context.distPath = getAbsoluteDistPath(context.rootPath, config);
|
|
82
73
|
if (config.source.entry) {
|
|
83
74
|
context.entry = config.source.entry;
|
|
84
75
|
}
|
|
@@ -86,7 +77,7 @@ function updateContextByNormalizedConfig(context, config) {
|
|
|
86
77
|
function createPublicContext(context) {
|
|
87
78
|
const exposedKeys = [
|
|
88
79
|
"entry",
|
|
89
|
-
"
|
|
80
|
+
"targets",
|
|
90
81
|
"version",
|
|
91
82
|
"rootPath",
|
|
92
83
|
"distPath",
|
|
@@ -111,14 +102,9 @@ function createPublicContext(context) {
|
|
|
111
102
|
}
|
|
112
103
|
});
|
|
113
104
|
}
|
|
114
|
-
async function createContext(options, userRsbuildConfig) {
|
|
105
|
+
async function createContext(options, userRsbuildConfig, bundlerType) {
|
|
115
106
|
const rsbuildConfig = (0, import_config.withDefaultConfig)(userRsbuildConfig);
|
|
116
|
-
const context = createContextByConfig(
|
|
117
|
-
options,
|
|
118
|
-
"rspack",
|
|
119
|
-
rsbuildConfig.source,
|
|
120
|
-
rsbuildConfig.output
|
|
121
|
-
);
|
|
107
|
+
const context = createContextByConfig(options, bundlerType, rsbuildConfig);
|
|
122
108
|
const tsconfigPath = (0, import_path.join)(context.rootPath, import_shared.TS_CONFIG_FILE);
|
|
123
109
|
return {
|
|
124
110
|
...context,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type PluginStore, type RspackConfig, type CreateRsbuildOptions } from '@rsbuild/shared';
|
|
2
|
-
import type { Context } from '../../types';
|
|
2
|
+
import type { Context, NormalizedConfig } from '../../types';
|
|
3
3
|
export type InitConfigsOptions = {
|
|
4
4
|
context: Context;
|
|
5
5
|
pluginStore: PluginStore;
|
|
@@ -8,7 +8,7 @@ export type InitConfigsOptions = {
|
|
|
8
8
|
export declare function initRsbuildConfig({
|
|
9
9
|
context,
|
|
10
10
|
pluginStore
|
|
11
|
-
}: Pick<InitConfigsOptions, 'context' | 'pluginStore'>): Promise<
|
|
11
|
+
}: Pick<InitConfigsOptions, 'context' | 'pluginStore'>): Promise<NormalizedConfig>;
|
|
12
12
|
export declare function initConfigs({
|
|
13
13
|
context,
|
|
14
14
|
pluginStore,
|
|
@@ -41,7 +41,7 @@ async function initRsbuildConfig({
|
|
|
41
41
|
pluginStore
|
|
42
42
|
}) {
|
|
43
43
|
if (context.normalizedConfig) {
|
|
44
|
-
return;
|
|
44
|
+
return context.normalizedConfig;
|
|
45
45
|
}
|
|
46
46
|
await (0, import_shared.initPlugins)({
|
|
47
47
|
pluginAPI: context.pluginAPI,
|
|
@@ -50,14 +50,15 @@ async function initRsbuildConfig({
|
|
|
50
50
|
await modifyRsbuildConfig(context);
|
|
51
51
|
context.normalizedConfig = (0, import_config.normalizeConfig)(context.config);
|
|
52
52
|
(0, import_createContext.updateContextByNormalizedConfig)(context, context.normalizedConfig);
|
|
53
|
+
return context.normalizedConfig;
|
|
53
54
|
}
|
|
54
55
|
async function initConfigs({
|
|
55
56
|
context,
|
|
56
57
|
pluginStore,
|
|
57
58
|
rsbuildOptions
|
|
58
59
|
}) {
|
|
59
|
-
await initRsbuildConfig({ context, pluginStore });
|
|
60
|
-
const targets =
|
|
60
|
+
const normalizedConfig = await initRsbuildConfig({ context, pluginStore });
|
|
61
|
+
const { targets } = normalizedConfig.output;
|
|
61
62
|
const rspackConfigs = await Promise.all(
|
|
62
63
|
targets.map((target) => (0, import_rspackConfig.generateRspackConfig)({ target, context }))
|
|
63
64
|
);
|
|
@@ -29,21 +29,24 @@ function getPluginAPI({
|
|
|
29
29
|
}) {
|
|
30
30
|
const { hooks } = context;
|
|
31
31
|
const publicContext = (0, import_createContext.createPublicContext)(context);
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
"Cannot access Rsbuild config until modifyRsbuildConfig is called."
|
|
36
|
-
);
|
|
32
|
+
const getNormalizedConfig = () => {
|
|
33
|
+
if (context.normalizedConfig) {
|
|
34
|
+
return context.normalizedConfig;
|
|
37
35
|
}
|
|
38
|
-
|
|
36
|
+
throw new Error(
|
|
37
|
+
"Cannot access normalized config until modifyRsbuildConfig is called."
|
|
38
|
+
);
|
|
39
39
|
};
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
const getRsbuildConfig = (type = "current") => {
|
|
41
|
+
switch (type) {
|
|
42
|
+
case "original":
|
|
43
|
+
return context.originalConfig;
|
|
44
|
+
case "current":
|
|
45
|
+
return context.config;
|
|
46
|
+
case "normalized":
|
|
47
|
+
return getNormalizedConfig();
|
|
45
48
|
}
|
|
46
|
-
|
|
49
|
+
throw new Error("`getRsbuildConfig` get an invalid type param.");
|
|
47
50
|
};
|
|
48
51
|
const getHTMLPaths = () => {
|
|
49
52
|
return Object.keys(context.entry).reduce(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type InitConfigsOptions } from './initConfigs';
|
|
2
|
-
import { type RspackConfig, type InspectConfigOptions } from '@rsbuild/shared';
|
|
2
|
+
import { type RspackConfig, type InspectConfigResult, type InspectConfigOptions } from '@rsbuild/shared';
|
|
3
3
|
export declare function inspectConfig({
|
|
4
4
|
context,
|
|
5
5
|
pluginStore,
|
|
@@ -9,22 +9,4 @@ export declare function inspectConfig({
|
|
|
9
9
|
}: InitConfigsOptions & {
|
|
10
10
|
inspectOptions?: InspectConfigOptions;
|
|
11
11
|
bundlerConfigs?: RspackConfig[];
|
|
12
|
-
}): Promise<
|
|
13
|
-
rsbuildConfig: string;
|
|
14
|
-
bundlerConfigs: string[];
|
|
15
|
-
origin: {
|
|
16
|
-
rsbuildConfig: {
|
|
17
|
-
pluginNames: string[];
|
|
18
|
-
dev?: import("@rsbuild/shared").DevConfig | undefined;
|
|
19
|
-
server?: import("@rsbuild/shared").ServerConfig | undefined;
|
|
20
|
-
html?: import("@rsbuild/shared").HtmlConfig | undefined;
|
|
21
|
-
tools?: import("@rsbuild/shared").ToolsConfig | undefined;
|
|
22
|
-
source?: import("@rsbuild/shared").SourceConfig | undefined;
|
|
23
|
-
output?: import("@rsbuild/shared").OutputConfig | undefined;
|
|
24
|
-
security?: import("@rsbuild/shared").SecurityConfig | undefined;
|
|
25
|
-
performance?: import("@rsbuild/shared").PerformanceConfig | undefined;
|
|
26
|
-
plugins?: import("@rsbuild/shared").RsbuildPlugin[] | undefined;
|
|
27
|
-
};
|
|
28
|
-
bundlerConfigs: RspackConfig[];
|
|
29
|
-
};
|
|
30
|
-
}>;
|
|
12
|
+
}): Promise<InspectConfigResult<'rspack'>>;
|
|
@@ -36,15 +36,15 @@ async function inspectConfig({
|
|
|
36
36
|
} else if (!process.env.NODE_ENV) {
|
|
37
37
|
process.env.NODE_ENV = "development";
|
|
38
38
|
}
|
|
39
|
-
const rsbuildDebugConfig = {
|
|
40
|
-
...context.config,
|
|
41
|
-
pluginNames: pluginStore.plugins.map((p) => p.name)
|
|
42
|
-
};
|
|
43
39
|
const rspackConfigs = bundlerConfigs || (await (0, import_initConfigs.initConfigs)({
|
|
44
40
|
context,
|
|
45
41
|
pluginStore,
|
|
46
42
|
rsbuildOptions
|
|
47
43
|
})).rspackConfigs;
|
|
44
|
+
const rsbuildDebugConfig = {
|
|
45
|
+
...context.normalizedConfig,
|
|
46
|
+
pluginNames: pluginStore.plugins.map((p) => p.name)
|
|
47
|
+
};
|
|
48
48
|
const rawRsbuildConfig = await (0, import_shared.stringifyConfig)(
|
|
49
49
|
rsbuildDebugConfig,
|
|
50
50
|
inspectOptions.verbose
|
|
@@ -60,13 +60,13 @@ async function inspectConfig({
|
|
|
60
60
|
}
|
|
61
61
|
if (inspectOptions.writeToDisk) {
|
|
62
62
|
await (0, import_shared.outputInspectConfigFiles)({
|
|
63
|
-
rsbuildConfig:
|
|
63
|
+
rsbuildConfig: context.normalizedConfig,
|
|
64
|
+
rawRsbuildConfig,
|
|
64
65
|
bundlerConfigs: rawBundlerConfigs,
|
|
65
66
|
inspectOptions: {
|
|
66
67
|
...inspectOptions,
|
|
67
68
|
outputPath
|
|
68
69
|
},
|
|
69
|
-
rsbuildOptions,
|
|
70
70
|
configType: "rspack"
|
|
71
71
|
});
|
|
72
72
|
}
|
|
@@ -39,7 +39,7 @@ async function processCss(inputSource, {
|
|
|
39
39
|
const { default: postcss } = await Promise.resolve().then(() => __toESM(require("postcss")));
|
|
40
40
|
const { default: localByDefault } = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared/postcss-modules-local-by-default")));
|
|
41
41
|
const { default: modulesScope } = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared/postcss-modules-scope")));
|
|
42
|
-
const { default: postcssICSSExtractPlugin } = await Promise.resolve().then(() => __toESM(require("./
|
|
42
|
+
const { default: postcssICSSExtractPlugin } = await Promise.resolve().then(() => __toESM(require("./postcssIcssExtractPlugin")));
|
|
43
43
|
const { default: extractImports } = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared/postcss-modules-extract-imports")));
|
|
44
44
|
const { default: modulesValues } = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared/postcss-modules-values")));
|
|
45
45
|
const parserOptions = {
|
|
@@ -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(
|
|
21
|
-
default: () =>
|
|
19
|
+
var postcssIcssExtractPlugin_exports = {};
|
|
20
|
+
__export(postcssIcssExtractPlugin_exports, {
|
|
21
|
+
default: () => postcssIcssExtractPlugin_default
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(postcssIcssExtractPlugin_exports);
|
|
24
24
|
var import_icss_utils = require("@rsbuild/shared/icss-utils");
|
|
25
25
|
var import_shared = require("@rsbuild/shared");
|
|
26
26
|
const dashesCamelCase = (str) => str.replace(/-+(\w)/g, (_match, firstLetter) => firstLetter.toUpperCase());
|
|
@@ -64,4 +64,4 @@ const plugin = (options) => {
|
|
|
64
64
|
};
|
|
65
65
|
};
|
|
66
66
|
plugin.postcss = true;
|
|
67
|
-
var
|
|
67
|
+
var postcssIcssExtractPlugin_default = plugin;
|
package/dist/provider/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export { getRspackVersion } from './shared';
|
|
2
1
|
export { rspackProvider } from './provider';
|
|
3
2
|
export type { Rspack, RspackConfig } from '@rsbuild/shared';
|
|
4
|
-
export {
|
|
3
|
+
export { createContext, createPublicContext } from './core/createContext';
|
|
5
4
|
export { initPlugins } from '@rsbuild/shared';
|
|
6
5
|
export { initHooks, type Hooks } from './core/initHooks';
|
|
7
6
|
export { withDefaultConfig } from './config';
|
package/dist/provider/index.js
CHANGED
|
@@ -20,21 +20,19 @@ var provider_exports = {};
|
|
|
20
20
|
__export(provider_exports, {
|
|
21
21
|
applyBaseCSSRule: () => import_css.applyBaseCSSRule,
|
|
22
22
|
applyCSSModuleRule: () => import_css.applyCSSModuleRule,
|
|
23
|
-
|
|
23
|
+
createContext: () => import_createContext.createContext,
|
|
24
24
|
createPublicContext: () => import_createContext.createPublicContext,
|
|
25
25
|
getPluginAPI: () => import_initPlugins.getPluginAPI,
|
|
26
|
-
getRspackVersion: () => import_shared.getRspackVersion,
|
|
27
26
|
initHooks: () => import_initHooks.initHooks,
|
|
28
|
-
initPlugins: () =>
|
|
27
|
+
initPlugins: () => import_shared.initPlugins,
|
|
29
28
|
initRsbuildConfig: () => import_initConfigs.initRsbuildConfig,
|
|
30
29
|
rspackProvider: () => import_provider.rspackProvider,
|
|
31
30
|
withDefaultConfig: () => import_config.withDefaultConfig
|
|
32
31
|
});
|
|
33
32
|
module.exports = __toCommonJS(provider_exports);
|
|
34
|
-
var import_shared = require("./shared");
|
|
35
33
|
var import_provider = require("./provider");
|
|
36
34
|
var import_createContext = require("./core/createContext");
|
|
37
|
-
var
|
|
35
|
+
var import_shared = require("@rsbuild/shared");
|
|
38
36
|
var import_initHooks = require("./core/initHooks");
|
|
39
37
|
var import_config = require("./config");
|
|
40
38
|
var import_initConfigs = require("./core/initConfigs");
|
|
@@ -44,10 +42,9 @@ var import_css = require("./plugins/css");
|
|
|
44
42
|
0 && (module.exports = {
|
|
45
43
|
applyBaseCSSRule,
|
|
46
44
|
applyCSSModuleRule,
|
|
47
|
-
|
|
45
|
+
createContext,
|
|
48
46
|
createPublicContext,
|
|
49
47
|
getPluginAPI,
|
|
50
|
-
getRspackVersion,
|
|
51
48
|
initHooks,
|
|
52
49
|
initPlugins,
|
|
53
50
|
initRsbuildConfig,
|
|
@@ -36,8 +36,7 @@ __export(css_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(css_exports);
|
|
37
37
|
var import_path = __toESM(require("path"));
|
|
38
38
|
var import_shared = require("@rsbuild/shared");
|
|
39
|
-
|
|
40
|
-
const enableNativeCss = (config) => !config.output.disableCssExtract;
|
|
39
|
+
const enableNativeCss = (config) => !config.output.injectStyles;
|
|
41
40
|
async function applyBaseCSSRule({
|
|
42
41
|
rule,
|
|
43
42
|
config,
|
|
@@ -45,7 +44,6 @@ async function applyBaseCSSRule({
|
|
|
45
44
|
utils: { target, isProd, isServer, isWebWorker, CHAIN_ID },
|
|
46
45
|
importLoaders = 1
|
|
47
46
|
}) {
|
|
48
|
-
const enableSourceMap = (0, import_shared.isUseCssSourceMap)(config);
|
|
49
47
|
const enableCSSModuleTS = Boolean(config.output.enableCssModuleTSDeclaration);
|
|
50
48
|
const browserslist = await (0, import_shared.getBrowserslistWithDefault)(
|
|
51
49
|
context.rootPath,
|
|
@@ -56,7 +54,6 @@ async function applyBaseCSSRule({
|
|
|
56
54
|
const localIdentName = (0, import_shared.getCssModuleLocalIdentName)(config, isProd);
|
|
57
55
|
const cssLoaderOptions = (0, import_shared.getCssLoaderOptions)({
|
|
58
56
|
config,
|
|
59
|
-
enableSourceMap,
|
|
60
57
|
importLoaders,
|
|
61
58
|
isServer,
|
|
62
59
|
isWebWorker,
|
|
@@ -85,7 +82,7 @@ async function applyBaseCSSRule({
|
|
|
85
82
|
} else {
|
|
86
83
|
rule.use(CHAIN_ID.USE.IGNORE_CSS).loader((0, import_shared.resolvePackage)("@rsbuild/shared/ignore-css-loader", __dirname)).end();
|
|
87
84
|
}
|
|
88
|
-
rule.use(CHAIN_ID.USE.CSS).loader((0,
|
|
85
|
+
rule.use(CHAIN_ID.USE.CSS).loader((0, import_shared.getSharedPkgCompiledPath)("css-loader")).options(cssLoaderOptions).end();
|
|
89
86
|
} else {
|
|
90
87
|
if (!isServer && !isWebWorker && enableCSSModuleTS) {
|
|
91
88
|
const { cssModules } = config.output;
|
|
@@ -100,11 +97,10 @@ async function applyBaseCSSRule({
|
|
|
100
97
|
}
|
|
101
98
|
if (!isServer && !isWebWorker) {
|
|
102
99
|
const postcssLoaderOptions = (0, import_shared.getPostcssConfig)({
|
|
103
|
-
enableSourceMap,
|
|
104
100
|
browserslist,
|
|
105
101
|
config
|
|
106
102
|
});
|
|
107
|
-
rule.use(CHAIN_ID.USE.POSTCSS).loader((0,
|
|
103
|
+
rule.use(CHAIN_ID.USE.POSTCSS).loader((0, import_shared.getSharedPkgCompiledPath)("postcss-loader")).options(postcssLoaderOptions).end();
|
|
108
104
|
}
|
|
109
105
|
rule.merge({ sideEffects: true });
|
|
110
106
|
rule.resolve.preferRelative(true);
|
|
@@ -155,11 +151,10 @@ const pluginCss = () => {
|
|
|
155
151
|
config,
|
|
156
152
|
context: api.context
|
|
157
153
|
});
|
|
158
|
-
const enableSourceMap = (0, import_shared.isUseCssSourceMap)(config);
|
|
159
154
|
const enableExtractCSS = (0, import_shared.isUseCssExtract)(config, utils.target);
|
|
160
|
-
if (!
|
|
155
|
+
if (!config.output.sourceMap.css && enableExtractCSS) {
|
|
161
156
|
const { RemoveCssSourcemapPlugin } = await Promise.resolve().then(() => __toESM(require("../../rspack/RemoveCssSourcemapPlugin")));
|
|
162
|
-
chain.plugin("remove-css-sourcemap").use(RemoveCssSourcemapPlugin, [
|
|
157
|
+
chain.plugin("remove-css-sourcemap").use(RemoveCssSourcemapPlugin, []);
|
|
163
158
|
}
|
|
164
159
|
});
|
|
165
160
|
api.modifyRspackConfig(
|
|
@@ -49,7 +49,7 @@ function pluginLess() {
|
|
|
49
49
|
});
|
|
50
50
|
const { excludes, options } = (0, import_shared.getLessLoaderOptions)(
|
|
51
51
|
config.tools.less,
|
|
52
|
-
|
|
52
|
+
config.output.sourceMap.css
|
|
53
53
|
);
|
|
54
54
|
excludes.forEach((item) => {
|
|
55
55
|
rule.exclude.add(item);
|
|
@@ -60,7 +60,7 @@ function pluginLess() {
|
|
|
60
60
|
config,
|
|
61
61
|
context: api.context
|
|
62
62
|
});
|
|
63
|
-
rule.use(utils.CHAIN_ID.USE.LESS).loader(
|
|
63
|
+
rule.use(utils.CHAIN_ID.USE.LESS).loader((0, import_shared.getSharedPkgCompiledPath)("less-loader")).options(options);
|
|
64
64
|
});
|
|
65
65
|
api.modifyRspackConfig(async (rspackConfig) => {
|
|
66
66
|
const { applyCSSModuleRule } = await Promise.resolve().then(() => __toESM(require("./css")));
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { RsbuildPlugin, NormalizedConfig } from '../../types';
|
|
3
|
-
export declare function applyJSMinimizer(chain: BundlerChain, config: NormalizedConfig): void;
|
|
4
|
-
export declare function applyCSSMinimizer(chain: BundlerChain): void;
|
|
1
|
+
import type { RsbuildPlugin } from '../../types';
|
|
5
2
|
export declare const pluginMinimize: () => RsbuildPlugin;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,17 +17,22 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
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
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var minimize_exports = {};
|
|
20
30
|
__export(minimize_exports, {
|
|
21
|
-
applyCSSMinimizer: () => applyCSSMinimizer,
|
|
22
|
-
applyJSMinimizer: () => applyJSMinimizer,
|
|
23
31
|
pluginMinimize: () => pluginMinimize
|
|
24
32
|
});
|
|
25
33
|
module.exports = __toCommonJS(minimize_exports);
|
|
26
34
|
var import_shared = require("@rsbuild/shared");
|
|
27
|
-
|
|
28
|
-
function applyJSMinimizer(chain, config) {
|
|
35
|
+
const getJsMinimizerOptions = (config) => {
|
|
29
36
|
const options = {};
|
|
30
37
|
const { removeConsole } = config.performance;
|
|
31
38
|
if (removeConsole === true) {
|
|
@@ -50,28 +57,24 @@ function applyJSMinimizer(chain, config) {
|
|
|
50
57
|
break;
|
|
51
58
|
}
|
|
52
59
|
options.asciiOnly = config.output.charset === "ascii";
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
function applyCSSMinimizer(chain) {
|
|
56
|
-
chain.optimization.minimizer(import_shared.CHAIN_ID.MINIMIZER.CSS).use(import_core.SwcCssMinimizerRspackPlugin, []).end();
|
|
57
|
-
}
|
|
60
|
+
return options;
|
|
61
|
+
};
|
|
58
62
|
const pluginMinimize = () => ({
|
|
59
63
|
name: "rsbuild:minimize",
|
|
60
64
|
setup(api) {
|
|
61
|
-
api.modifyBundlerChain((chain, { isProd }) => {
|
|
65
|
+
api.modifyBundlerChain(async (chain, { isProd }) => {
|
|
62
66
|
const config = api.getNormalizedConfig();
|
|
63
67
|
const isMinimize = isProd && !config.output.disableMinimize;
|
|
64
68
|
chain.optimization.minimize(isMinimize);
|
|
65
|
-
if (isMinimize) {
|
|
66
|
-
|
|
67
|
-
applyCSSMinimizer(chain);
|
|
69
|
+
if (!isMinimize) {
|
|
70
|
+
return;
|
|
68
71
|
}
|
|
72
|
+
const { SwcJsMinimizerRspackPlugin, SwcCssMinimizerRspackPlugin } = await Promise.resolve().then(() => __toESM(require("@rspack/core")));
|
|
73
|
+
chain.optimization.minimizer(import_shared.CHAIN_ID.MINIMIZER.JS).use(SwcJsMinimizerRspackPlugin, [getJsMinimizerOptions(config)]).end().minimizer(import_shared.CHAIN_ID.MINIMIZER.CSS).use(SwcCssMinimizerRspackPlugin, []).end();
|
|
69
74
|
});
|
|
70
75
|
}
|
|
71
76
|
});
|
|
72
77
|
// Annotate the CommonJS export names for ESM import in node:
|
|
73
78
|
0 && (module.exports = {
|
|
74
|
-
applyCSSMinimizer,
|
|
75
|
-
applyJSMinimizer,
|
|
76
79
|
pluginMinimize
|
|
77
80
|
});
|
|
@@ -48,8 +48,8 @@ const pluginOutput = () => ({
|
|
|
48
48
|
});
|
|
49
49
|
api.modifyRspackConfig(async (rspackConfig, { isProd }) => {
|
|
50
50
|
const config = api.getNormalizedConfig();
|
|
51
|
-
const cssPath = (0, import_shared.getDistPath)(config
|
|
52
|
-
const cssFilename = (0, import_shared.getFilename)(config
|
|
51
|
+
const cssPath = (0, import_shared.getDistPath)(config, "css");
|
|
52
|
+
const cssFilename = (0, import_shared.getFilename)(config, "css", isProd);
|
|
53
53
|
rspackConfig.output || (rspackConfig.output = {});
|
|
54
54
|
rspackConfig.output.cssFilename = import_path.posix.join(cssPath, cssFilename);
|
|
55
55
|
rspackConfig.output.cssChunkFilename = import_path.posix.join(
|
|
@@ -26,11 +26,6 @@ const pluginResolve = () => ({
|
|
|
26
26
|
name: "rsbuild:resolve",
|
|
27
27
|
setup(api) {
|
|
28
28
|
(0, import_shared.applyResolvePlugin)(api);
|
|
29
|
-
api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
|
|
30
|
-
if (chain.module.rules.get(CHAIN_ID.RULE.JS_DATA_URI)) {
|
|
31
|
-
chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).resolve.set("fullySpecified", false);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
29
|
api.modifyRspackConfig(async (rspackConfig, { isServer }) => {
|
|
35
30
|
const isTsProject = Boolean(api.context.tsconfigPath);
|
|
36
31
|
const config = api.getNormalizedConfig();
|
|
@@ -33,7 +33,6 @@ __export(rspackProfile_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(rspackProfile_exports);
|
|
35
35
|
var import_path = __toESM(require("path"));
|
|
36
|
-
var import_core = require("@rspack/core");
|
|
37
36
|
var import_inspector = __toESM(require("inspector"));
|
|
38
37
|
var import_shared = require("@rsbuild/shared");
|
|
39
38
|
var import_shared2 = require("@rsbuild/shared");
|
|
@@ -51,11 +50,15 @@ const stopProfiler = (output, profileSession) => {
|
|
|
51
50
|
};
|
|
52
51
|
const pluginRspackProfile = () => ({
|
|
53
52
|
name: "rsbuild:rspack-profile",
|
|
54
|
-
setup(api) {
|
|
53
|
+
async setup(api) {
|
|
55
54
|
const RSPACK_PROFILE = process.env.RSPACK_PROFILE?.toUpperCase();
|
|
56
55
|
if (!RSPACK_PROFILE) {
|
|
57
56
|
return;
|
|
58
57
|
}
|
|
58
|
+
const {
|
|
59
|
+
experimental_registerGlobalTrace: registerGlobalTrace,
|
|
60
|
+
experimental_cleanupGlobalTrace: cleanupGlobalTrace
|
|
61
|
+
} = await Promise.resolve().then(() => __toESM(require("@rspack/core")));
|
|
59
62
|
const timestamp = Date.now();
|
|
60
63
|
const profileDir = import_path.default.join(
|
|
61
64
|
api.context.distPath,
|
|
@@ -71,7 +74,7 @@ const pluginRspackProfile = () => ({
|
|
|
71
74
|
const onStart = () => {
|
|
72
75
|
import_shared.fse.ensureDirSync(profileDir);
|
|
73
76
|
if (enableProfileTrace) {
|
|
74
|
-
(
|
|
77
|
+
registerGlobalTrace("trace", "chrome", traceFilePath);
|
|
75
78
|
}
|
|
76
79
|
if (enableCPUProfile) {
|
|
77
80
|
profileSession = new import_inspector.default.Session();
|
|
@@ -93,7 +96,7 @@ const pluginRspackProfile = () => ({
|
|
|
93
96
|
}
|
|
94
97
|
});
|
|
95
98
|
api.onExit(() => {
|
|
96
|
-
enableProfileTrace && (
|
|
99
|
+
enableProfileTrace && cleanupGlobalTrace();
|
|
97
100
|
stopProfiler(cpuProfilePath, profileSession);
|
|
98
101
|
import_shared2.logger.info(`Saved Rspack profile file to ${profileDir}`);
|
|
99
102
|
});
|
|
@@ -59,13 +59,13 @@ function pluginSass() {
|
|
|
59
59
|
// postcss-loader, resolve-url-loader, sass-loader
|
|
60
60
|
importLoaders: 3
|
|
61
61
|
});
|
|
62
|
-
rule.use(utils.CHAIN_ID.USE.RESOLVE_URL_LOADER_FOR_SASS).loader(
|
|
62
|
+
rule.use(utils.CHAIN_ID.USE.RESOLVE_URL_LOADER_FOR_SASS).loader((0, import_shared.getSharedPkgCompiledPath)("resolve-url-loader")).options({
|
|
63
63
|
join: await (0, import_shared.getResolveUrlJoinFn)(),
|
|
64
64
|
// 'resolve-url-loader' relies on 'adjust-sourcemap-loader',
|
|
65
65
|
// it has performance regression issues in some scenarios,
|
|
66
66
|
// so we need to disable the sourceMap option.
|
|
67
67
|
sourceMap: false
|
|
68
|
-
}).end().use(utils.CHAIN_ID.USE.SASS).loader(
|
|
68
|
+
}).end().use(utils.CHAIN_ID.USE.SASS).loader((0, import_shared.getSharedPkgCompiledPath)("sass-loader")).options(options);
|
|
69
69
|
});
|
|
70
70
|
api.modifyRspackConfig(async (rspackConfig) => {
|
|
71
71
|
const { applyCSSModuleRule } = await Promise.resolve().then(() => __toESM(require("./css")));
|
|
@@ -0,0 +1,70 @@
|
|
|
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 server_exports = {};
|
|
30
|
+
__export(server_exports, {
|
|
31
|
+
pluginServer: () => pluginServer
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(server_exports);
|
|
34
|
+
var import_fs = __toESM(require("fs"));
|
|
35
|
+
var import_path = require("path");
|
|
36
|
+
const pluginServer = () => ({
|
|
37
|
+
name: "rsbuild:server",
|
|
38
|
+
setup(api) {
|
|
39
|
+
api.modifyBundlerChain(async (chain, { isProd }) => {
|
|
40
|
+
const config = api.getNormalizedConfig();
|
|
41
|
+
if (isProd && config.server?.publicDir) {
|
|
42
|
+
const { name, copyOnBuild } = config.server?.publicDir;
|
|
43
|
+
if (!copyOnBuild || !name) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const publicDir = (0, import_path.isAbsolute)(name) ? name : (0, import_path.join)(api.context.rootPath, name);
|
|
47
|
+
const publicPattern = [
|
|
48
|
+
{
|
|
49
|
+
from: publicDir,
|
|
50
|
+
to: "",
|
|
51
|
+
noErrorOnMissing: true
|
|
52
|
+
}
|
|
53
|
+
];
|
|
54
|
+
if (!import_fs.default.existsSync(publicDir)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const { CopyRspackPlugin } = await Promise.resolve().then(() => __toESM(require("@rspack/core")));
|
|
58
|
+
chain.plugin("public-dir").use(CopyRspackPlugin, [
|
|
59
|
+
{
|
|
60
|
+
patterns: publicPattern
|
|
61
|
+
}
|
|
62
|
+
]);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
68
|
+
0 && (module.exports = {
|
|
69
|
+
pluginServer
|
|
70
|
+
});
|
|
@@ -54,7 +54,7 @@ async function getDefaultSwcConfig(config, rootPath, target) {
|
|
|
54
54
|
env: {
|
|
55
55
|
targets: await (0, import_shared.getBrowserslistWithDefault)(rootPath, config, target)
|
|
56
56
|
},
|
|
57
|
-
sourceMaps: (0, import_shared.
|
|
57
|
+
sourceMaps: Boolean((0, import_shared.getJsSourceMap)(config)),
|
|
58
58
|
exclude: [],
|
|
59
59
|
inlineSourcesContent: true
|
|
60
60
|
};
|
|
@@ -101,13 +101,6 @@ const pluginSwc = () => ({
|
|
|
101
101
|
}).use(CHAIN_ID.USE.SWC).loader(builtinSwcLoaderName).options((0, import_shared.cloneDeep)(swcConfig));
|
|
102
102
|
}
|
|
103
103
|
);
|
|
104
|
-
api.modifyRspackConfig(async (config) => {
|
|
105
|
-
(0, import_shared.setConfig)(
|
|
106
|
-
config,
|
|
107
|
-
"experiments.rspackFuture.disableTransformByDefault",
|
|
108
|
-
true
|
|
109
|
-
);
|
|
110
|
-
});
|
|
111
104
|
}
|
|
112
105
|
});
|
|
113
106
|
async function applyCoreJs(swcConfig, chain, polyfillMode) {
|