@rsbuild/core 0.5.9 → 0.6.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/dist/cli/commands.js +1 -1
- package/dist/cli/prepare.js +1 -1
- package/dist/client/hmr/createSocketUrl.d.ts +2 -2
- package/dist/client/hmr/index.d.ts +6 -0
- package/dist/client/hmr.mjs +11 -275
- package/dist/client/overlay.d.ts +1 -0
- package/dist/client/overlay.mjs +250 -0
- package/dist/config.d.ts +8 -1
- package/dist/config.js +154 -3
- package/dist/createRsbuild.js +1 -1
- package/dist/{provider/htmlPluginUtil.js → htmlUtils.js} +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal.d.ts +20 -0
- package/dist/{provider/index.js → internal.js} +28 -18
- package/dist/plugins/fileSize.js +2 -0
- package/dist/provider/createCompiler.js +1 -1
- package/dist/provider/createContext.js +2 -2
- package/dist/provider/devMiddleware.js +19 -6
- package/dist/provider/initConfigs.js +1 -1
- package/dist/provider/plugins/css.js +11 -5
- package/dist/provider/rspackConfig.js +2 -2
- package/dist/provider/shared.d.ts +4 -3
- package/dist/provider/shared.js +27 -8
- package/dist/rspack/HtmlAppIconPlugin.js +2 -2
- package/dist/rspack/HtmlBasicPlugin.js +2 -2
- package/dist/rspack/HtmlCrossOriginPlugin.js +2 -2
- package/dist/rspack/HtmlNetworkPerformancePlugin.js +2 -2
- package/dist/rspack/HtmlNoncePlugin.js +2 -2
- package/dist/rspack/InlineChunkHtmlPlugin.js +2 -2
- package/dist/rspack/preload/HtmlPreloadOrPrefetchPlugin.js +3 -3
- package/dist/server/compilerDevMiddleware.d.ts +2 -2
- package/dist/server/compilerDevMiddleware.js +23 -15
- package/package.json +9 -13
- package/dist/client/hmr/overlay.d.ts +0 -2
- package/dist/provider/config.d.ts +0 -8
- package/dist/provider/config.js +0 -175
- package/dist/provider/index.d.ts +0 -14
- /package/dist/{provider/htmlPluginUtil.d.ts → htmlUtils.d.ts} +0 -0
package/dist/config.js
CHANGED
|
@@ -30,13 +30,162 @@ var config_exports = {};
|
|
|
30
30
|
__export(config_exports, {
|
|
31
31
|
defineConfig: () => defineConfig,
|
|
32
32
|
loadConfig: () => loadConfig,
|
|
33
|
-
|
|
33
|
+
normalizeConfig: () => normalizeConfig,
|
|
34
|
+
watchFiles: () => watchFiles,
|
|
35
|
+
withDefaultConfig: () => withDefaultConfig
|
|
34
36
|
});
|
|
35
37
|
module.exports = __toCommonJS(config_exports);
|
|
36
38
|
var import_node_fs = __toESM(require("node:fs"));
|
|
37
39
|
var import_node_path = require("node:path");
|
|
38
|
-
var import_shared = require("@rsbuild/shared");
|
|
39
40
|
var import_restart = require("./server/restart");
|
|
41
|
+
var import_shared = require("@rsbuild/shared");
|
|
42
|
+
var import_mergeConfig = require("./mergeConfig");
|
|
43
|
+
const getDefaultDevConfig = () => ({
|
|
44
|
+
hmr: true,
|
|
45
|
+
liveReload: true,
|
|
46
|
+
assetPrefix: import_shared.DEFAULT_ASSET_PREFIX,
|
|
47
|
+
startUrl: false,
|
|
48
|
+
client: {
|
|
49
|
+
overlay: true
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const getDefaultServerConfig = () => ({
|
|
53
|
+
port: import_shared.DEFAULT_PORT,
|
|
54
|
+
host: import_shared.DEFAULT_DEV_HOST,
|
|
55
|
+
htmlFallback: "index",
|
|
56
|
+
compress: true,
|
|
57
|
+
printUrls: true,
|
|
58
|
+
strictPort: false,
|
|
59
|
+
publicDir: {
|
|
60
|
+
name: "public",
|
|
61
|
+
copyOnBuild: true
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
const getDefaultSourceConfig = () => ({
|
|
65
|
+
alias: {},
|
|
66
|
+
define: {},
|
|
67
|
+
aliasStrategy: "prefer-tsconfig",
|
|
68
|
+
preEntry: [],
|
|
69
|
+
decorators: {
|
|
70
|
+
version: "legacy"
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
const getDefaultHtmlConfig = () => ({
|
|
74
|
+
meta: {
|
|
75
|
+
charset: { charset: "UTF-8" },
|
|
76
|
+
viewport: "width=device-width, initial-scale=1.0"
|
|
77
|
+
},
|
|
78
|
+
title: "Rsbuild App",
|
|
79
|
+
inject: "head",
|
|
80
|
+
mountId: import_shared.DEFAULT_MOUNT_ID,
|
|
81
|
+
crossorigin: false,
|
|
82
|
+
outputStructure: "flat",
|
|
83
|
+
scriptLoading: "defer"
|
|
84
|
+
});
|
|
85
|
+
const getDefaultSecurityConfig = () => ({
|
|
86
|
+
nonce: ""
|
|
87
|
+
});
|
|
88
|
+
const getDefaultToolsConfig = () => ({
|
|
89
|
+
cssExtract: {
|
|
90
|
+
loaderOptions: {},
|
|
91
|
+
pluginOptions: {}
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
const getDefaultPerformanceConfig = () => ({
|
|
95
|
+
profile: false,
|
|
96
|
+
buildCache: true,
|
|
97
|
+
printFileSize: true,
|
|
98
|
+
removeConsole: false,
|
|
99
|
+
removeMomentLocale: false,
|
|
100
|
+
chunkSplit: {
|
|
101
|
+
strategy: "split-by-experience"
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
const getDefaultOutputConfig = () => ({
|
|
105
|
+
targets: ["web"],
|
|
106
|
+
distPath: {
|
|
107
|
+
root: import_shared.ROOT_DIST_DIR,
|
|
108
|
+
js: import_shared.JS_DIST_DIR,
|
|
109
|
+
css: import_shared.CSS_DIST_DIR,
|
|
110
|
+
svg: import_shared.SVG_DIST_DIR,
|
|
111
|
+
font: import_shared.FONT_DIST_DIR,
|
|
112
|
+
html: import_shared.HTML_DIST_DIR,
|
|
113
|
+
wasm: import_shared.WASM_DIST_DIR,
|
|
114
|
+
image: import_shared.IMAGE_DIST_DIR,
|
|
115
|
+
media: import_shared.MEDIA_DIST_DIR,
|
|
116
|
+
server: import_shared.SERVER_DIST_DIR,
|
|
117
|
+
worker: import_shared.SERVICE_WORKER_DIST_DIR
|
|
118
|
+
},
|
|
119
|
+
assetPrefix: import_shared.DEFAULT_ASSET_PREFIX,
|
|
120
|
+
filename: {},
|
|
121
|
+
charset: "ascii",
|
|
122
|
+
polyfill: "usage",
|
|
123
|
+
dataUriLimit: {
|
|
124
|
+
svg: import_shared.DEFAULT_DATA_URL_SIZE,
|
|
125
|
+
font: import_shared.DEFAULT_DATA_URL_SIZE,
|
|
126
|
+
image: import_shared.DEFAULT_DATA_URL_SIZE,
|
|
127
|
+
media: import_shared.DEFAULT_DATA_URL_SIZE
|
|
128
|
+
},
|
|
129
|
+
legalComments: "linked",
|
|
130
|
+
injectStyles: false,
|
|
131
|
+
minify: true,
|
|
132
|
+
sourceMap: {
|
|
133
|
+
js: void 0,
|
|
134
|
+
css: false
|
|
135
|
+
},
|
|
136
|
+
filenameHash: true,
|
|
137
|
+
enableCssModuleTSDeclaration: false,
|
|
138
|
+
inlineScripts: false,
|
|
139
|
+
inlineStyles: false,
|
|
140
|
+
cssModules: {
|
|
141
|
+
auto: true,
|
|
142
|
+
exportLocalsConvention: "camelCase"
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
const createDefaultConfig = () => ({
|
|
146
|
+
dev: getDefaultDevConfig(),
|
|
147
|
+
server: getDefaultServerConfig(),
|
|
148
|
+
html: getDefaultHtmlConfig(),
|
|
149
|
+
source: getDefaultSourceConfig(),
|
|
150
|
+
output: getDefaultOutputConfig(),
|
|
151
|
+
tools: getDefaultToolsConfig(),
|
|
152
|
+
security: getDefaultSecurityConfig(),
|
|
153
|
+
performance: getDefaultPerformanceConfig()
|
|
154
|
+
});
|
|
155
|
+
function getDefaultEntry(root) {
|
|
156
|
+
const files = [
|
|
157
|
+
// Most projects are using typescript now.
|
|
158
|
+
// So we put `.ts` as the first one to improve performance.
|
|
159
|
+
"ts",
|
|
160
|
+
"js",
|
|
161
|
+
"tsx",
|
|
162
|
+
"jsx",
|
|
163
|
+
".mjs",
|
|
164
|
+
".cjs"
|
|
165
|
+
].map((ext) => (0, import_node_path.join)(root, `src/index.${ext}`));
|
|
166
|
+
const entryFile = (0, import_shared.findExists)(files);
|
|
167
|
+
if (entryFile) {
|
|
168
|
+
return {
|
|
169
|
+
index: entryFile
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
return {};
|
|
173
|
+
}
|
|
174
|
+
const withDefaultConfig = async (rootPath, config) => {
|
|
175
|
+
const merged = (0, import_mergeConfig.mergeRsbuildConfig)(createDefaultConfig(), config);
|
|
176
|
+
merged.source || (merged.source = {});
|
|
177
|
+
if (!merged.source.entry) {
|
|
178
|
+
merged.source.entry = getDefaultEntry(rootPath);
|
|
179
|
+
}
|
|
180
|
+
if (!merged.source.tsconfigPath) {
|
|
181
|
+
const tsconfigPath = (0, import_node_path.join)(rootPath, import_shared.TS_CONFIG_FILE);
|
|
182
|
+
if (await (0, import_shared.isFileExists)(tsconfigPath)) {
|
|
183
|
+
merged.source.tsconfigPath = tsconfigPath;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return merged;
|
|
187
|
+
};
|
|
188
|
+
const normalizeConfig = (config) => (0, import_mergeConfig.mergeRsbuildConfig)(createDefaultConfig(), config);
|
|
40
189
|
function defineConfig(config) {
|
|
41
190
|
return config;
|
|
42
191
|
}
|
|
@@ -149,5 +298,7 @@ async function loadConfig({
|
|
|
149
298
|
0 && (module.exports = {
|
|
150
299
|
defineConfig,
|
|
151
300
|
loadConfig,
|
|
152
|
-
|
|
301
|
+
normalizeConfig,
|
|
302
|
+
watchFiles,
|
|
303
|
+
withDefaultConfig
|
|
153
304
|
});
|
package/dist/createRsbuild.js
CHANGED
|
@@ -35,7 +35,7 @@ var import_shared = require("@rsbuild/shared");
|
|
|
35
35
|
var import_plugins = require("./plugins");
|
|
36
36
|
var import_pluginManager = require("./pluginManager");
|
|
37
37
|
const getRspackProvider = async () => {
|
|
38
|
-
const { rspackProvider } = await Promise.resolve().then(() => __toESM(require("./provider")));
|
|
38
|
+
const { rspackProvider } = await Promise.resolve().then(() => __toESM(require("./provider/provider")));
|
|
39
39
|
return rspackProvider;
|
|
40
40
|
};
|
|
41
41
|
async function createRsbuild(options = {}) {
|
|
@@ -16,12 +16,12 @@ 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 htmlUtils_exports = {};
|
|
20
|
+
__export(htmlUtils_exports, {
|
|
21
21
|
getHTMLPlugin: () => getHTMLPlugin,
|
|
22
22
|
setHTMLPlugin: () => setHTMLPlugin
|
|
23
23
|
});
|
|
24
|
-
module.exports = __toCommonJS(
|
|
24
|
+
module.exports = __toCommonJS(htmlUtils_exports);
|
|
25
25
|
let htmlPlugin;
|
|
26
26
|
const setHTMLPlugin = (plugin) => {
|
|
27
27
|
if (plugin) {
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,6 @@ export declare const version: any;
|
|
|
9
9
|
export { logger } from '@rsbuild/shared';
|
|
10
10
|
export { mergeRsbuildConfig } from './mergeConfig';
|
|
11
11
|
export { PLUGIN_SWC_NAME, PLUGIN_CSS_NAME, PLUGIN_SASS_NAME, PLUGIN_LESS_NAME, PLUGIN_STYLUS_NAME, } from './constants';
|
|
12
|
-
export type { Rspack } from '
|
|
12
|
+
export type { Rspack } from '@rsbuild/shared';
|
|
13
13
|
export type { RsbuildConfig, DevConfig, HtmlConfig, ToolsConfig, SourceConfig, ServerConfig, OutputConfig, SecurityConfig, PerformanceConfig, ModuleFederationConfig, NormalizedConfig, NormalizedDevConfig, NormalizedHtmlConfig, NormalizedToolsConfig, NormalizedSourceConfig, NormalizedServerConfig, NormalizedOutputConfig, NormalizedSecurityConfig, NormalizedPerformanceConfig, NormalizedModuleFederationConfig, RsbuildPlugin, RsbuildPlugins, RsbuildPluginAPI, } from './types';
|
|
14
14
|
export type { RsbuildMode, RsbuildEntry, RsbuildTarget, RsbuildContext, RsbuildInstance, CreateRsbuildOptions, InspectConfigOptions, OnExitFn, OnAfterBuildFn, OnAfterCreateCompilerFn, OnAfterStartDevServerFn, OnAfterStartProdServerFn, OnBeforeBuildFn, OnBeforeStartDevServerFn, OnBeforeStartProdServerFn, OnBeforeCreateCompilerFn, OnCloseDevServerFn, OnDevCompileDoneFn, ModifyBundlerChainFn, ModifyRspackConfigFn, ModifyRsbuildConfigFn, TransformFn, TransformHandler, } from '@rsbuild/shared';
|
package/dist/index.js
CHANGED
|
@@ -38,7 +38,7 @@ var import_config = require("./config");
|
|
|
38
38
|
var import_shared = require("@rsbuild/shared");
|
|
39
39
|
var import_mergeConfig = require("./mergeConfig");
|
|
40
40
|
var import_constants = require("./constants");
|
|
41
|
-
const version = "0.
|
|
41
|
+
const version = "0.6.0";
|
|
42
42
|
// Annotate the CommonJS export names for ESM import in node:
|
|
43
43
|
0 && (module.exports = {
|
|
44
44
|
PLUGIN_CSS_NAME,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @private
|
|
3
|
+
* Some internal methods of Rsbuild.
|
|
4
|
+
* Please do not use them in your Rsbuild project or plugins.
|
|
5
|
+
*/
|
|
6
|
+
export { rspackProvider } from './provider/provider';
|
|
7
|
+
export { createContext, createPublicContext } from './provider/createContext';
|
|
8
|
+
export { initPlugins, createPluginManager } from './pluginManager';
|
|
9
|
+
export { initHooks, type Hooks } from './initHooks';
|
|
10
|
+
export { initRsbuildConfig } from './provider/initConfigs';
|
|
11
|
+
export { getPluginAPI } from './provider/initPlugins';
|
|
12
|
+
export { applyBaseCSSRule, applyCSSModuleRule } from './provider/plugins/css';
|
|
13
|
+
export type { InternalContext } from './types';
|
|
14
|
+
export { setHTMLPlugin, getHTMLPlugin } from './htmlUtils';
|
|
15
|
+
export { formatStats, getStatsOptions } from './provider/shared';
|
|
16
|
+
export { getChainUtils } from './provider/rspackConfig';
|
|
17
|
+
export { applySwcDecoratorConfig } from './provider/plugins/swc';
|
|
18
|
+
export { getDevMiddleware } from './provider/devMiddleware';
|
|
19
|
+
export { createDevServer, startProdServer } from './server';
|
|
20
|
+
export { plugins } from './plugins';
|
|
@@ -16,44 +16,51 @@ 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 internal_exports = {};
|
|
20
|
+
__export(internal_exports, {
|
|
21
21
|
applyBaseCSSRule: () => import_css.applyBaseCSSRule,
|
|
22
22
|
applyCSSModuleRule: () => import_css.applyCSSModuleRule,
|
|
23
23
|
applySwcDecoratorConfig: () => import_swc.applySwcDecoratorConfig,
|
|
24
24
|
createContext: () => import_createContext.createContext,
|
|
25
|
+
createDevServer: () => import_server.createDevServer,
|
|
25
26
|
createPluginManager: () => import_pluginManager.createPluginManager,
|
|
26
27
|
createPublicContext: () => import_createContext.createPublicContext,
|
|
27
28
|
formatStats: () => import_shared.formatStats,
|
|
28
29
|
getChainUtils: () => import_rspackConfig.getChainUtils,
|
|
29
30
|
getDevMiddleware: () => import_devMiddleware.getDevMiddleware,
|
|
30
|
-
getHTMLPlugin: () =>
|
|
31
|
+
getHTMLPlugin: () => import_htmlUtils.getHTMLPlugin,
|
|
31
32
|
getPluginAPI: () => import_initPlugins.getPluginAPI,
|
|
33
|
+
getStatsOptions: () => import_shared.getStatsOptions,
|
|
32
34
|
initHooks: () => import_initHooks.initHooks,
|
|
33
35
|
initPlugins: () => import_pluginManager.initPlugins,
|
|
34
36
|
initRsbuildConfig: () => import_initConfigs.initRsbuildConfig,
|
|
37
|
+
plugins: () => import_plugins.plugins,
|
|
35
38
|
rspackProvider: () => import_provider.rspackProvider,
|
|
36
|
-
setHTMLPlugin: () =>
|
|
39
|
+
setHTMLPlugin: () => import_htmlUtils.setHTMLPlugin,
|
|
40
|
+
startProdServer: () => import_server.startProdServer
|
|
37
41
|
});
|
|
38
|
-
module.exports = __toCommonJS(
|
|
39
|
-
var import_provider = require("./provider");
|
|
40
|
-
var import_createContext = require("./createContext");
|
|
41
|
-
var import_pluginManager = require("
|
|
42
|
-
var import_initHooks = require("
|
|
43
|
-
var import_initConfigs = require("./initConfigs");
|
|
44
|
-
var import_initPlugins = require("./initPlugins");
|
|
45
|
-
var import_css = require("./plugins/css");
|
|
46
|
-
var
|
|
47
|
-
var import_shared = require("./shared");
|
|
48
|
-
var import_rspackConfig = require("./rspackConfig");
|
|
49
|
-
var import_swc = require("./plugins/swc");
|
|
50
|
-
var import_devMiddleware = require("./devMiddleware");
|
|
42
|
+
module.exports = __toCommonJS(internal_exports);
|
|
43
|
+
var import_provider = require("./provider/provider");
|
|
44
|
+
var import_createContext = require("./provider/createContext");
|
|
45
|
+
var import_pluginManager = require("./pluginManager");
|
|
46
|
+
var import_initHooks = require("./initHooks");
|
|
47
|
+
var import_initConfigs = require("./provider/initConfigs");
|
|
48
|
+
var import_initPlugins = require("./provider/initPlugins");
|
|
49
|
+
var import_css = require("./provider/plugins/css");
|
|
50
|
+
var import_htmlUtils = require("./htmlUtils");
|
|
51
|
+
var import_shared = require("./provider/shared");
|
|
52
|
+
var import_rspackConfig = require("./provider/rspackConfig");
|
|
53
|
+
var import_swc = require("./provider/plugins/swc");
|
|
54
|
+
var import_devMiddleware = require("./provider/devMiddleware");
|
|
55
|
+
var import_server = require("./server");
|
|
56
|
+
var import_plugins = require("./plugins");
|
|
51
57
|
// Annotate the CommonJS export names for ESM import in node:
|
|
52
58
|
0 && (module.exports = {
|
|
53
59
|
applyBaseCSSRule,
|
|
54
60
|
applyCSSModuleRule,
|
|
55
61
|
applySwcDecoratorConfig,
|
|
56
62
|
createContext,
|
|
63
|
+
createDevServer,
|
|
57
64
|
createPluginManager,
|
|
58
65
|
createPublicContext,
|
|
59
66
|
formatStats,
|
|
@@ -61,9 +68,12 @@ var import_devMiddleware = require("./devMiddleware");
|
|
|
61
68
|
getDevMiddleware,
|
|
62
69
|
getHTMLPlugin,
|
|
63
70
|
getPluginAPI,
|
|
71
|
+
getStatsOptions,
|
|
64
72
|
initHooks,
|
|
65
73
|
initPlugins,
|
|
66
74
|
initRsbuildConfig,
|
|
75
|
+
plugins,
|
|
67
76
|
rspackProvider,
|
|
68
|
-
setHTMLPlugin
|
|
77
|
+
setHTMLPlugin,
|
|
78
|
+
startProdServer
|
|
69
79
|
});
|
package/dist/plugins/fileSize.js
CHANGED
|
@@ -101,6 +101,8 @@ async function printFileSizes(config, stats, rootPath) {
|
|
|
101
101
|
const origin = stats2.toJson({
|
|
102
102
|
all: false,
|
|
103
103
|
assets: true,
|
|
104
|
+
// TODO: need supported in rspack
|
|
105
|
+
// @ts-expect-error
|
|
104
106
|
cachedAssets: true,
|
|
105
107
|
groupAssetsByInfo: false,
|
|
106
108
|
groupAssetsByPath: false,
|
|
@@ -93,7 +93,7 @@ async function createCompiler({
|
|
|
93
93
|
printTime(obj, 0);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
const { message, level } = (0, import_shared2.formatStats)(stats);
|
|
96
|
+
const { message, level } = (0, import_shared2.formatStats)(stats, (0, import_shared2.getStatsOptions)(compiler));
|
|
97
97
|
if (level === "error") {
|
|
98
98
|
import_shared.logger.error(message);
|
|
99
99
|
}
|
|
@@ -26,7 +26,7 @@ module.exports = __toCommonJS(createContext_exports);
|
|
|
26
26
|
var import_node_path = require("node:path");
|
|
27
27
|
var import_shared = require("@rsbuild/shared");
|
|
28
28
|
var import_initHooks = require("../initHooks");
|
|
29
|
-
var import_config = require("
|
|
29
|
+
var import_config = require("../config");
|
|
30
30
|
var import_entry = require("../plugins/entry");
|
|
31
31
|
function getAbsolutePath(root, filepath) {
|
|
32
32
|
return (0, import_node_path.isAbsolute)(filepath) ? filepath : (0, import_node_path.join)(root, filepath);
|
|
@@ -44,7 +44,7 @@ async function createContextByConfig(options, bundlerType, config = {}) {
|
|
|
44
44
|
const context = {
|
|
45
45
|
entry: (0, import_entry.getEntryObject)(config, "web"),
|
|
46
46
|
targets: config.output?.targets || [],
|
|
47
|
-
version: "0.
|
|
47
|
+
version: "0.6.0",
|
|
48
48
|
rootPath,
|
|
49
49
|
distPath,
|
|
50
50
|
cachePath,
|
|
@@ -33,19 +33,32 @@ __export(devMiddleware_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(devMiddleware_exports);
|
|
34
34
|
var import_webpack_dev_middleware = __toESM(require("@rsbuild/shared/webpack-dev-middleware"));
|
|
35
35
|
var import_shared = require("@rsbuild/shared");
|
|
36
|
-
function applyHMREntry(
|
|
36
|
+
function applyHMREntry({
|
|
37
|
+
compiler,
|
|
38
|
+
clientPaths,
|
|
39
|
+
clientConfig = {}
|
|
40
|
+
}) {
|
|
37
41
|
if (!(0, import_shared.isClientCompiler)(compiler)) {
|
|
38
42
|
return;
|
|
39
43
|
}
|
|
40
|
-
new compiler.webpack.
|
|
41
|
-
|
|
44
|
+
new compiler.webpack.DefinePlugin({
|
|
45
|
+
RSBUILD_CLIENT_CONFIG: JSON.stringify(clientConfig)
|
|
42
46
|
}).apply(compiler);
|
|
47
|
+
for (const clientPath of clientPaths) {
|
|
48
|
+
new compiler.webpack.EntryPlugin(compiler.context, clientPath, {
|
|
49
|
+
name: void 0
|
|
50
|
+
}).apply(compiler);
|
|
51
|
+
}
|
|
43
52
|
}
|
|
44
53
|
const getDevMiddleware = (multiCompiler) => (options) => {
|
|
45
|
-
const {
|
|
54
|
+
const { clientPaths, clientConfig, callbacks, ...restOptions } = options;
|
|
46
55
|
const setupCompiler = (compiler) => {
|
|
47
|
-
if (
|
|
48
|
-
applyHMREntry(
|
|
56
|
+
if (clientPaths) {
|
|
57
|
+
applyHMREntry({
|
|
58
|
+
compiler,
|
|
59
|
+
clientPaths,
|
|
60
|
+
clientConfig
|
|
61
|
+
});
|
|
49
62
|
}
|
|
50
63
|
(0, import_shared.setupServerHooks)(compiler, callbacks);
|
|
51
64
|
};
|
|
@@ -27,7 +27,7 @@ var import_mergeConfig = require("../mergeConfig");
|
|
|
27
27
|
var import_createContext = require("./createContext");
|
|
28
28
|
var import_inspectConfig = require("./inspectConfig");
|
|
29
29
|
var import_rspackConfig = require("./rspackConfig");
|
|
30
|
-
var import_config = require("
|
|
30
|
+
var import_config = require("../config");
|
|
31
31
|
var import_pluginManager = require("../pluginManager");
|
|
32
32
|
async function modifyRsbuildConfig(context) {
|
|
33
33
|
(0, import_shared.debug)("modify Rsbuild config");
|
|
@@ -158,7 +158,7 @@ const pluginCss = () => {
|
|
|
158
158
|
});
|
|
159
159
|
api.modifyRspackConfig(
|
|
160
160
|
async (rspackConfig, { isProd, isServer, isWebWorker }) => {
|
|
161
|
-
var _a;
|
|
161
|
+
var _a, _b;
|
|
162
162
|
const config = api.getNormalizedConfig();
|
|
163
163
|
if (!enableNativeCss(config)) {
|
|
164
164
|
rspackConfig.experiments || (rspackConfig.experiments = {});
|
|
@@ -173,13 +173,19 @@ const pluginCss = () => {
|
|
|
173
173
|
);
|
|
174
174
|
localIdentName = localIdentName.replace(":base64", "");
|
|
175
175
|
}
|
|
176
|
-
rspackConfig.
|
|
177
|
-
(_a = rspackConfig.
|
|
178
|
-
rspackConfig.
|
|
179
|
-
|
|
176
|
+
rspackConfig.module || (rspackConfig.module = {});
|
|
177
|
+
(_a = rspackConfig.module).generator || (_a.generator = {});
|
|
178
|
+
rspackConfig.module.generator["css/module"] = {
|
|
179
|
+
exportsConvention: (0, import_shared.kebabCase)(
|
|
180
|
+
config.output.cssModules.exportLocalsConvention
|
|
181
|
+
),
|
|
180
182
|
localIdentName,
|
|
181
183
|
exportsOnly: isServer || isWebWorker
|
|
182
184
|
};
|
|
185
|
+
(_b = rspackConfig.module).parser || (_b.parser = {});
|
|
186
|
+
rspackConfig.module.parser["css/module"] = {
|
|
187
|
+
namedExports: false
|
|
188
|
+
};
|
|
183
189
|
const rules = rspackConfig.module?.rules;
|
|
184
190
|
applyCSSModuleRule(rules, import_shared.CSS_REGEX, config);
|
|
185
191
|
}
|
|
@@ -34,7 +34,7 @@ __export(rspackConfig_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(rspackConfig_exports);
|
|
35
35
|
var import_shared = require("@rsbuild/shared");
|
|
36
36
|
var import_shared2 = require("./shared");
|
|
37
|
-
var
|
|
37
|
+
var import_htmlUtils = require("../htmlUtils");
|
|
38
38
|
async function modifyRspackConfig(context, rspackConfig, utils) {
|
|
39
39
|
(0, import_shared.debug)("modify Rspack config");
|
|
40
40
|
let [modifiedConfig] = await context.hooks.modifyRspackConfig.call(
|
|
@@ -104,7 +104,7 @@ function getChainUtils(target) {
|
|
|
104
104
|
isServiceWorker: target === "service-worker",
|
|
105
105
|
getCompiledPath: import_shared2.getCompiledPath,
|
|
106
106
|
CHAIN_ID: import_shared.CHAIN_ID,
|
|
107
|
-
HtmlPlugin: (0,
|
|
107
|
+
HtmlPlugin: (0, import_htmlUtils.getHTMLPlugin)()
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
110
|
async function generateRspackConfig({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type Stats, type MultiStats, type StatsError } from '@rsbuild/shared';
|
|
1
|
+
import { isMultiCompiler, type Stats, type MultiStats, type StatsError } from '@rsbuild/shared';
|
|
2
2
|
import type { RsbuildPlugin } from '../types';
|
|
3
3
|
import { type Plugins } from '@rsbuild/shared';
|
|
4
|
-
import type { StatsCompilation } from '@rspack/core';
|
|
4
|
+
import type { StatsCompilation, StatsValue } from '@rspack/core';
|
|
5
5
|
export declare const applyDefaultPlugins: (plugins: Plugins) => import("@rsbuild/shared").AwaitableGetter<RsbuildPlugin>;
|
|
6
6
|
export declare const rspackMinVersion = "0.5.0";
|
|
7
7
|
export declare const isSatisfyRspackVersion: (originalVersion: string) => Promise<boolean>;
|
|
@@ -9,7 +9,8 @@ export declare const getCompiledPath: (packageName: string) => string;
|
|
|
9
9
|
export declare const BUILTIN_LOADER = "builtin:";
|
|
10
10
|
export declare const getAllStatsErrors: (statsData: StatsCompilation) => StatsError[] | undefined;
|
|
11
11
|
export declare const getAllStatsWarnings: (statsData: StatsCompilation) => StatsError[] | undefined;
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function getStatsOptions(compiler: Parameters<typeof isMultiCompiler>[0]): StatsValue | undefined;
|
|
13
|
+
export declare function formatStats(stats: Stats | MultiStats, options?: StatsValue): {
|
|
13
14
|
message: string;
|
|
14
15
|
level: string;
|
|
15
16
|
} | {
|
package/dist/provider/shared.js
CHANGED
|
@@ -34,6 +34,7 @@ __export(shared_exports, {
|
|
|
34
34
|
getAllStatsErrors: () => getAllStatsErrors,
|
|
35
35
|
getAllStatsWarnings: () => getAllStatsWarnings,
|
|
36
36
|
getCompiledPath: () => getCompiledPath,
|
|
37
|
+
getStatsOptions: () => getStatsOptions,
|
|
37
38
|
isSatisfyRspackVersion: () => isSatisfyRspackVersion,
|
|
38
39
|
rspackMinVersion: () => rspackMinVersion
|
|
39
40
|
});
|
|
@@ -182,6 +183,10 @@ function formatErrorMessage(errors) {
|
|
|
182
183
|
const title = import_shared.color.bold(
|
|
183
184
|
import_shared.color.red(isTerserError ? "Minify error: " : "Compile error: ")
|
|
184
185
|
);
|
|
186
|
+
if (!errors.length) {
|
|
187
|
+
return `${title}
|
|
188
|
+
${import_shared.color.yellow(`For more details, please setting 'stats.errors: true' `)}`;
|
|
189
|
+
}
|
|
185
190
|
const tip = import_shared.color.yellow(
|
|
186
191
|
isTerserError ? "Failed to minify with terser, check for syntax errors." : "Failed to compile, check the errors for troubleshooting."
|
|
187
192
|
);
|
|
@@ -207,25 +212,38 @@ const getAllStatsWarnings = (statsData) => {
|
|
|
207
212
|
}
|
|
208
213
|
return statsData.warnings;
|
|
209
214
|
};
|
|
210
|
-
function
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
+
function getStatsOptions(compiler) {
|
|
216
|
+
if ((0, import_shared.isMultiCompiler)(compiler)) {
|
|
217
|
+
return {
|
|
218
|
+
children: compiler.compilers.map(
|
|
219
|
+
(compiler2) => compiler2.options ? compiler2.options.stats : void 0
|
|
220
|
+
)
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
return compiler.options ? compiler.options.stats : void 0;
|
|
224
|
+
}
|
|
225
|
+
function formatStats(stats, options = {}) {
|
|
226
|
+
const statsData = stats.toJson(
|
|
227
|
+
typeof options === "object" ? {
|
|
228
|
+
preset: "errors-warnings",
|
|
229
|
+
children: true,
|
|
230
|
+
...options
|
|
231
|
+
} : options
|
|
232
|
+
);
|
|
215
233
|
const { errors, warnings } = (0, import_formatStats.formatStatsMessages)({
|
|
216
234
|
errors: getAllStatsErrors(statsData),
|
|
217
235
|
warnings: getAllStatsWarnings(statsData)
|
|
218
236
|
});
|
|
219
|
-
if (
|
|
237
|
+
if (stats.hasErrors()) {
|
|
220
238
|
return {
|
|
221
239
|
message: formatErrorMessage(errors),
|
|
222
240
|
level: "error"
|
|
223
241
|
};
|
|
224
242
|
}
|
|
225
|
-
if (
|
|
243
|
+
if (stats.hasWarnings()) {
|
|
226
244
|
const title = import_shared.color.bold(import_shared.color.yellow("Compile Warning: \n"));
|
|
227
245
|
return {
|
|
228
|
-
message: `${title}${`${warnings.join("\n\n")}
|
|
246
|
+
message: `${title}${`${warnings.join("\n\n") || import_shared.color.yellow("For more details, please setting 'stats.warnings: true'")}
|
|
229
247
|
`}`,
|
|
230
248
|
level: "warning"
|
|
231
249
|
};
|
|
@@ -240,6 +258,7 @@ function formatStats(stats) {
|
|
|
240
258
|
getAllStatsErrors,
|
|
241
259
|
getAllStatsWarnings,
|
|
242
260
|
getCompiledPath,
|
|
261
|
+
getStatsOptions,
|
|
243
262
|
isSatisfyRspackVersion,
|
|
244
263
|
rspackMinVersion
|
|
245
264
|
});
|
|
@@ -40,7 +40,7 @@ var import_node_fs = __toESM(require("node:fs"));
|
|
|
40
40
|
var import_node_path = require("node:path");
|
|
41
41
|
var import_webpack_sources = __toESM(require("@rsbuild/shared/webpack-sources"));
|
|
42
42
|
var import_shared = require("@rsbuild/shared");
|
|
43
|
-
var
|
|
43
|
+
var import_htmlUtils = require("../htmlUtils");
|
|
44
44
|
class HtmlAppIconPlugin {
|
|
45
45
|
constructor(options) {
|
|
46
46
|
__publicField(this, "name");
|
|
@@ -58,7 +58,7 @@ class HtmlAppIconPlugin {
|
|
|
58
58
|
}
|
|
59
59
|
const iconRelativePath = import_node_path.posix.join(this.distDir, (0, import_node_path.basename)(this.iconPath));
|
|
60
60
|
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
61
|
-
(0,
|
|
61
|
+
(0, import_htmlUtils.getHTMLPlugin)().getHooks(compilation).alterAssetTagGroups.tap(this.name, (data) => {
|
|
62
62
|
const publicPath = (0, import_shared.getPublicPathFromCompiler)(compiler);
|
|
63
63
|
data.headTags.unshift({
|
|
64
64
|
tagName: "link",
|
|
@@ -31,7 +31,7 @@ __export(HtmlBasicPlugin_exports, {
|
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(HtmlBasicPlugin_exports);
|
|
33
33
|
var import_shared = require("@rsbuild/shared");
|
|
34
|
-
var
|
|
34
|
+
var import_htmlUtils = require("../htmlUtils");
|
|
35
35
|
const VOID_TAGS = [
|
|
36
36
|
"area",
|
|
37
37
|
"base",
|
|
@@ -184,7 +184,7 @@ class HtmlBasicPlugin {
|
|
|
184
184
|
}
|
|
185
185
|
apply(compiler) {
|
|
186
186
|
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
187
|
-
(0,
|
|
187
|
+
(0, import_htmlUtils.getHTMLPlugin)().getHooks(compilation).alterAssetTagGroups.tap(this.name, (data) => {
|
|
188
188
|
const entryName = data.plugin.options?.entryName;
|
|
189
189
|
if (!entryName) {
|
|
190
190
|
return data;
|
|
@@ -27,7 +27,7 @@ __export(HtmlCrossOriginPlugin_exports, {
|
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(HtmlCrossOriginPlugin_exports);
|
|
29
29
|
var import_shared = require("@rsbuild/shared");
|
|
30
|
-
var
|
|
30
|
+
var import_htmlUtils = require("../htmlUtils");
|
|
31
31
|
class HtmlCrossOriginPlugin {
|
|
32
32
|
constructor(options) {
|
|
33
33
|
__publicField(this, "name");
|
|
@@ -47,7 +47,7 @@ class HtmlCrossOriginPlugin {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
50
|
-
(0,
|
|
50
|
+
(0, import_htmlUtils.getHTMLPlugin)().getHooks(compilation).alterAssetTags.tap(this.name, (alterAssetTags) => {
|
|
51
51
|
var _a;
|
|
52
52
|
const {
|
|
53
53
|
assetTags: { scripts, styles }
|
|
@@ -27,7 +27,7 @@ __export(HtmlNetworkPerformancePlugin_exports, {
|
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(HtmlNetworkPerformancePlugin_exports);
|
|
29
29
|
var import_shared = require("@rsbuild/shared");
|
|
30
|
-
var
|
|
30
|
+
var import_htmlUtils = require("../htmlUtils");
|
|
31
31
|
function generateLinks(options, type) {
|
|
32
32
|
const relMap = {
|
|
33
33
|
preconnect: "preconnect",
|
|
@@ -54,7 +54,7 @@ class HtmlNetworkPerformancePlugin {
|
|
|
54
54
|
compiler.hooks.compilation.tap(
|
|
55
55
|
`HTML${this.type}Plugin`,
|
|
56
56
|
(compilation) => {
|
|
57
|
-
(0,
|
|
57
|
+
(0, import_htmlUtils.getHTMLPlugin)().getHooks(compilation).alterAssetTagGroups.tap(
|
|
58
58
|
`HTML${(0, import_shared.upperFirst)(this.type)}Plugin`,
|
|
59
59
|
(htmlPluginData) => {
|
|
60
60
|
const { headTags } = htmlPluginData;
|
|
@@ -26,7 +26,7 @@ __export(HtmlNoncePlugin_exports, {
|
|
|
26
26
|
HtmlNoncePlugin: () => HtmlNoncePlugin
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(HtmlNoncePlugin_exports);
|
|
29
|
-
var
|
|
29
|
+
var import_htmlUtils = require("../htmlUtils");
|
|
30
30
|
var import_shared = require("@rsbuild/shared");
|
|
31
31
|
class HtmlNoncePlugin {
|
|
32
32
|
constructor(options) {
|
|
@@ -47,7 +47,7 @@ class HtmlNoncePlugin {
|
|
|
47
47
|
name: void 0
|
|
48
48
|
}).apply(compiler);
|
|
49
49
|
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
|
50
|
-
(0,
|
|
50
|
+
(0, import_htmlUtils.getHTMLPlugin)().getHooks(compilation).alterAssetTagGroups.tap(this.name, (data) => {
|
|
51
51
|
const { headTags, bodyTags } = data;
|
|
52
52
|
const allTags = [...headTags, ...bodyTags];
|
|
53
53
|
for (const tag of allTags) {
|