@rsbuild/core 0.6.5 → 0.6.7
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/sirv/index.js +1 -1
- package/dist/cli/commands.js +2 -2
- package/dist/cli/init.js +1 -1
- package/dist/cli/prepare.js +1 -1
- package/dist/client/hmr.mjs +11 -3
- package/dist/config.d.ts +1 -1
- package/dist/config.js +3 -2
- package/dist/createContext.d.ts +1 -1
- package/dist/createContext.js +2 -2
- package/dist/createRsbuild.d.ts +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/initHooks.d.ts +1 -1
- package/dist/initPlugins.js +7 -2
- package/dist/plugins/html.d.ts +1 -1
- package/dist/plugins/moduleFederation.js +2 -12
- package/dist/plugins/nodeAddons.js +41 -6
- package/dist/plugins/server.js +1 -1
- package/dist/plugins/startUrl.js +2 -2
- package/dist/provider/build.d.ts +1 -1
- package/dist/provider/build.js +3 -13
- package/dist/provider/createCompiler.d.ts +2 -2
- package/dist/provider/createCompiler.js +5 -6
- package/dist/provider/css-modules-typescript-pre-loader/index.js +1 -1
- package/dist/provider/css-modules-typescript-pre-loader/postcssIcssExtractPlugin.js +1 -1
- package/dist/provider/initConfigs.d.ts +1 -1
- package/dist/provider/initConfigs.js +3 -3
- package/dist/provider/inspectConfig.d.ts +1 -1
- package/dist/provider/inspectConfig.js +1 -1
- package/dist/provider/plugins/css.d.ts +2 -2
- package/dist/provider/plugins/minimize.js +2 -11
- package/dist/provider/plugins/output.js +2 -12
- package/dist/provider/plugins/progress.js +2 -12
- package/dist/provider/plugins/rspackProfile.d.ts +1 -1
- package/dist/provider/plugins/rspackProfile.js +10 -7
- package/dist/provider/plugins/swc.d.ts +5 -4
- package/dist/provider/plugins/swc.js +2 -3
- package/dist/provider/provider.js +1 -1
- package/dist/provider/rspackConfig.d.ts +1 -1
- package/dist/provider/rspackConfig.js +4 -4
- package/dist/provider/shared.d.ts +1 -1
- package/dist/provider/shared.js +3 -3
- package/dist/rspack/HtmlBasicPlugin.d.ts +2 -2
- package/dist/rspack/InlineChunkHtmlPlugin.d.ts +1 -1
- package/dist/rspack/preload/HtmlPreloadOrPrefetchPlugin.d.ts +1 -1
- package/dist/rspack/preload/HtmlPreloadOrPrefetchPlugin.js +1 -1
- package/dist/rspack/preload/helpers/doesChunkBelongToHtml.d.ts +1 -1
- package/dist/rspack/preload/helpers/extractChunks.d.ts +1 -1
- package/dist/rspack/transformLoader.d.ts +1 -1
- package/dist/rspack/transformRawLoader.d.ts +3 -0
- package/dist/rspack/{nodeAddonsLoader.js → transformRawLoader.js} +6 -33
- package/dist/server/compilerDevMiddleware.d.ts +1 -1
- package/dist/server/compilerDevMiddleware.js +1 -0
- package/dist/server/devMiddleware.js +8 -5
- package/dist/server/devServer.d.ts +1 -1
- package/dist/server/devServer.js +10 -3
- package/dist/server/getDevMiddlewares.d.ts +1 -1
- package/dist/server/getDevMiddlewares.js +1 -1
- package/dist/server/helper.d.ts +2 -1
- package/dist/server/helper.js +5 -2
- package/dist/server/middlewares.js +3 -3
- package/dist/server/prodServer.d.ts +1 -1
- package/dist/server/prodServer.js +3 -3
- package/dist/server/proxy.d.ts +1 -1
- package/dist/server/proxy.js +3 -1
- package/dist/server/socketServer.d.ts +1 -1
- package/dist/server/socketServer.js +1 -1
- package/dist/server/watchFiles.d.ts +10 -0
- package/dist/server/watchFiles.js +90 -0
- package/dist/types.d.ts +1 -1
- package/package.json +20 -6
- package/dist/rspack/nodeAddonsLoader.d.ts +0 -3
|
@@ -23,12 +23,12 @@ __export(initConfigs_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(initConfigs_exports);
|
|
25
25
|
var import_shared = require("@rsbuild/shared");
|
|
26
|
-
var
|
|
26
|
+
var import_config = require("../config");
|
|
27
27
|
var import_createContext = require("../createContext");
|
|
28
|
+
var import_mergeConfig = require("../mergeConfig");
|
|
29
|
+
var import_pluginManager = require("../pluginManager");
|
|
28
30
|
var import_inspectConfig = require("./inspectConfig");
|
|
29
31
|
var import_rspackConfig = require("./rspackConfig");
|
|
30
|
-
var import_config = require("../config");
|
|
31
|
-
var import_pluginManager = require("../pluginManager");
|
|
32
32
|
async function modifyRsbuildConfig(context) {
|
|
33
33
|
(0, import_shared.debug)("modify Rsbuild config");
|
|
34
34
|
const [modified] = await context.hooks.modifyRsbuildConfig.call(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { type InspectConfigOptions, type InspectConfigResult, type RspackConfig } from '@rsbuild/shared';
|
|
1
2
|
import { type InitConfigsOptions } from './initConfigs';
|
|
2
|
-
import { type RspackConfig, type InspectConfigResult, type InspectConfigOptions } from '@rsbuild/shared';
|
|
3
3
|
export declare function inspectConfig({ context, pluginManager, rsbuildOptions, bundlerConfigs, inspectOptions, }: InitConfigsOptions & {
|
|
4
4
|
inspectOptions?: InspectConfigOptions;
|
|
5
5
|
bundlerConfigs?: RspackConfig[];
|
|
@@ -22,8 +22,8 @@ __export(inspectConfig_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(inspectConfig_exports);
|
|
24
24
|
var import_node_path = require("node:path");
|
|
25
|
-
var import_initConfigs = require("./initConfigs");
|
|
26
25
|
var import_shared = require("@rsbuild/shared");
|
|
26
|
+
var import_initConfigs = require("./initConfigs");
|
|
27
27
|
async function inspectConfig({
|
|
28
28
|
context,
|
|
29
29
|
pluginManager,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type BundlerChain, type
|
|
2
|
-
import type {
|
|
1
|
+
import { type BundlerChain, type ModifyBundlerChainUtils, type RsbuildContext, type RspackRule } from '@rsbuild/shared';
|
|
2
|
+
import type { NormalizedConfig, RsbuildPlugin } from '../../types';
|
|
3
3
|
export declare const enableNativeCss: (config: NormalizedConfig) => boolean;
|
|
4
4
|
export declare function applyBaseCSSRule({ rule, config, context, utils: { target, isProd, isServer, isWebWorker, CHAIN_ID }, importLoaders, }: {
|
|
5
5
|
rule: ReturnType<BundlerChain['module']['rule']>;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
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
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var minimize_exports = {};
|
|
30
20
|
__export(minimize_exports, {
|
|
@@ -32,6 +22,7 @@ __export(minimize_exports, {
|
|
|
32
22
|
});
|
|
33
23
|
module.exports = __toCommonJS(minimize_exports);
|
|
34
24
|
var import_shared = require("@rsbuild/shared");
|
|
25
|
+
var import_core = require("@rspack/core");
|
|
35
26
|
const pluginMinimize = () => ({
|
|
36
27
|
name: "rsbuild:minimize",
|
|
37
28
|
setup(api) {
|
|
@@ -41,7 +32,7 @@ const pluginMinimize = () => ({
|
|
|
41
32
|
if (!isMinimize) {
|
|
42
33
|
return;
|
|
43
34
|
}
|
|
44
|
-
const { SwcJsMinimizerRspackPlugin, SwcCssMinimizerRspackPlugin } =
|
|
35
|
+
const { SwcJsMinimizerRspackPlugin, SwcCssMinimizerRspackPlugin } = import_core.rspack;
|
|
45
36
|
const { minifyJs, minifyCss } = (0, import_shared.parseMinifyOptions)(config);
|
|
46
37
|
if (minifyJs) {
|
|
47
38
|
chain.optimization.minimizer(import_shared.CHAIN_ID.MINIMIZER.JS).use(SwcJsMinimizerRspackPlugin, [(0, import_shared.getSwcMinimizerOptions)(config)]).end();
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
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
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var output_exports = {};
|
|
30
20
|
__export(output_exports, {
|
|
@@ -33,6 +23,7 @@ __export(output_exports, {
|
|
|
33
23
|
module.exports = __toCommonJS(output_exports);
|
|
34
24
|
var import_node_path = require("node:path");
|
|
35
25
|
var import_shared = require("@rsbuild/shared");
|
|
26
|
+
var import_core = require("@rspack/core");
|
|
36
27
|
const pluginOutput = () => ({
|
|
37
28
|
name: "rsbuild:output",
|
|
38
29
|
setup(api) {
|
|
@@ -40,10 +31,9 @@ const pluginOutput = () => ({
|
|
|
40
31
|
api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
|
|
41
32
|
const config = api.getNormalizedConfig();
|
|
42
33
|
if (config.output.copy) {
|
|
43
|
-
const { CopyRspackPlugin } = await Promise.resolve().then(() => __toESM(require("@rspack/core")));
|
|
44
34
|
const { copy } = config.output;
|
|
45
35
|
const options = Array.isArray(copy) ? { patterns: copy } : copy;
|
|
46
|
-
chain.plugin(CHAIN_ID.PLUGIN.COPY).use(CopyRspackPlugin, [options]);
|
|
36
|
+
chain.plugin(CHAIN_ID.PLUGIN.COPY).use(import_core.rspack.CopyRspackPlugin, [options]);
|
|
47
37
|
}
|
|
48
38
|
});
|
|
49
39
|
api.modifyRspackConfig(async (rspackConfig, { isProd }) => {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
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
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var progress_exports = {};
|
|
30
20
|
__export(progress_exports, {
|
|
@@ -32,6 +22,7 @@ __export(progress_exports, {
|
|
|
32
22
|
});
|
|
33
23
|
module.exports = __toCommonJS(progress_exports);
|
|
34
24
|
var import_shared = require("@rsbuild/shared");
|
|
25
|
+
var import_core = require("@rspack/core");
|
|
35
26
|
const pluginProgress = () => ({
|
|
36
27
|
name: "rsbuild:progress",
|
|
37
28
|
setup(api) {
|
|
@@ -43,8 +34,7 @@ const pluginProgress = () => ({
|
|
|
43
34
|
return;
|
|
44
35
|
}
|
|
45
36
|
const prefix = options !== true && options.id !== void 0 ? options.id : import_shared.TARGET_ID_MAP[target];
|
|
46
|
-
|
|
47
|
-
chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(ProgressPlugin, [
|
|
37
|
+
chain.plugin(CHAIN_ID.PLUGIN.PROGRESS).use(import_core.rspack.ProgressPlugin, [
|
|
48
38
|
{
|
|
49
39
|
prefix,
|
|
50
40
|
...options === true ? {} : options
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type { RsbuildPlugin } from '../../types';
|
|
3
2
|
import inspector from 'node:inspector';
|
|
3
|
+
import type { RsbuildPlugin } from '../../types';
|
|
4
4
|
export declare const stopProfiler: (output: string, profileSession?: inspector.Session) => void;
|
|
5
5
|
export declare const pluginRspackProfile: () => RsbuildPlugin;
|
|
@@ -32,10 +32,11 @@ __export(rspackProfile_exports, {
|
|
|
32
32
|
stopProfiler: () => stopProfiler
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(rspackProfile_exports);
|
|
35
|
-
var import_node_path = __toESM(require("node:path"));
|
|
36
35
|
var import_node_inspector = __toESM(require("node:inspector"));
|
|
36
|
+
var import_node_path = __toESM(require("node:path"));
|
|
37
37
|
var import_shared = require("@rsbuild/shared");
|
|
38
38
|
var import_shared2 = require("@rsbuild/shared");
|
|
39
|
+
var import_core = require("@rspack/core");
|
|
39
40
|
const stopProfiler = (output, profileSession) => {
|
|
40
41
|
if (!profileSession) {
|
|
41
42
|
return;
|
|
@@ -55,10 +56,6 @@ const pluginRspackProfile = () => ({
|
|
|
55
56
|
if (!RSPACK_PROFILE) {
|
|
56
57
|
return;
|
|
57
58
|
}
|
|
58
|
-
const {
|
|
59
|
-
experimental_registerGlobalTrace: registerGlobalTrace,
|
|
60
|
-
experimental_cleanupGlobalTrace: cleanupGlobalTrace
|
|
61
|
-
} = await Promise.resolve().then(() => __toESM(require("@rspack/core")));
|
|
62
59
|
const timestamp = Date.now();
|
|
63
60
|
const profileDir = import_node_path.default.join(
|
|
64
61
|
api.context.distPath,
|
|
@@ -74,7 +71,11 @@ const pluginRspackProfile = () => ({
|
|
|
74
71
|
const onStart = () => {
|
|
75
72
|
import_shared.fse.ensureDirSync(profileDir);
|
|
76
73
|
if (enableProfileTrace) {
|
|
77
|
-
|
|
74
|
+
import_core.rspack.experimental_registerGlobalTrace(
|
|
75
|
+
"trace",
|
|
76
|
+
"chrome",
|
|
77
|
+
traceFilePath
|
|
78
|
+
);
|
|
78
79
|
}
|
|
79
80
|
if (enableCPUProfile) {
|
|
80
81
|
profileSession = new import_node_inspector.default.Session();
|
|
@@ -96,7 +97,9 @@ const pluginRspackProfile = () => ({
|
|
|
96
97
|
}
|
|
97
98
|
});
|
|
98
99
|
api.onExit(() => {
|
|
99
|
-
|
|
100
|
+
if (enableProfileTrace) {
|
|
101
|
+
import_core.rspack.experimental_cleanupGlobalTrace();
|
|
102
|
+
}
|
|
100
103
|
stopProfiler(cpuProfilePath, profileSession);
|
|
101
104
|
import_shared2.logger.info(`Saved Rspack profile file to ${profileDir}`);
|
|
102
105
|
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { type RsbuildTarget
|
|
2
|
-
import type {
|
|
3
|
-
|
|
1
|
+
import { type RsbuildTarget } from '@rsbuild/shared';
|
|
2
|
+
import type { SwcLoaderOptions } from '@rspack/core';
|
|
3
|
+
import type { NormalizedConfig, RsbuildPlugin } from '../../types';
|
|
4
|
+
export declare function getDefaultSwcConfig(config: NormalizedConfig, rootPath: string, target: RsbuildTarget): Promise<SwcLoaderOptions>;
|
|
4
5
|
/**
|
|
5
6
|
* Provide some swc configs of rspack
|
|
6
7
|
*/
|
|
7
8
|
export declare const pluginSwc: () => RsbuildPlugin;
|
|
8
|
-
export declare function applySwcDecoratorConfig(swcConfig:
|
|
9
|
+
export declare function applySwcDecoratorConfig(swcConfig: SwcLoaderOptions, config: NormalizedConfig): void;
|
|
@@ -33,8 +33,8 @@ __export(swc_exports, {
|
|
|
33
33
|
pluginSwc: () => pluginSwc
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(swc_exports);
|
|
36
|
-
var import_shared = require("@rsbuild/shared");
|
|
37
36
|
var import_node_path = __toESM(require("node:path"));
|
|
37
|
+
var import_shared = require("@rsbuild/shared");
|
|
38
38
|
var import_constants = require("../../constants");
|
|
39
39
|
const builtinSwcLoaderName = "builtin:swc-loader";
|
|
40
40
|
async function getDefaultSwcConfig(config, rootPath, target) {
|
|
@@ -53,8 +53,7 @@ async function getDefaultSwcConfig(config, rootPath, target) {
|
|
|
53
53
|
isModule: "unknown",
|
|
54
54
|
env: {
|
|
55
55
|
targets: await (0, import_shared.getBrowserslistWithDefault)(rootPath, config, target)
|
|
56
|
-
}
|
|
57
|
-
sourceMaps: Boolean((0, import_shared.getJsSourceMap)(config))
|
|
56
|
+
}
|
|
58
57
|
};
|
|
59
58
|
}
|
|
60
59
|
const pluginSwc = () => ({
|
|
@@ -33,9 +33,9 @@ __export(provider_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(provider_exports);
|
|
34
34
|
var import_shared = require("@rsbuild/shared");
|
|
35
35
|
var import_createContext = require("../createContext");
|
|
36
|
-
var import_initConfigs = require("./initConfigs");
|
|
37
36
|
var import_initPlugins = require("../initPlugins");
|
|
38
37
|
var import_plugins = require("../plugins");
|
|
38
|
+
var import_initConfigs = require("./initConfigs");
|
|
39
39
|
const rspackProvider = async ({
|
|
40
40
|
pluginManager,
|
|
41
41
|
rsbuildOptions
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ModifyChainUtils, type RsbuildTarget, type RspackConfig } from '@rsbuild/shared';
|
|
2
2
|
import type { InternalContext } from '../types';
|
|
3
3
|
export declare function getChainUtils(target: RsbuildTarget): ModifyChainUtils;
|
|
4
4
|
export declare function generateRspackConfig({ target, context, }: {
|
|
@@ -33,8 +33,9 @@ __export(rspackConfig_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(rspackConfig_exports);
|
|
35
35
|
var import_shared = require("@rsbuild/shared");
|
|
36
|
-
var
|
|
36
|
+
var import_core = require("@rspack/core");
|
|
37
37
|
var import_htmlUtils = require("../htmlUtils");
|
|
38
|
+
var import_shared2 = require("./shared");
|
|
38
39
|
async function modifyRspackConfig(context, rspackConfig, utils) {
|
|
39
40
|
(0, import_shared.debug)("modify Rspack config");
|
|
40
41
|
let [modifiedConfig] = await context.hooks.modifyRspackConfig.call(
|
|
@@ -54,10 +55,9 @@ async function modifyRspackConfig(context, rspackConfig, utils) {
|
|
|
54
55
|
}
|
|
55
56
|
async function getConfigUtils(config, chainUtils) {
|
|
56
57
|
const { merge } = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared/webpack-merge")));
|
|
57
|
-
const rspack = await Promise.resolve().then(() => __toESM(require("@rspack/core")));
|
|
58
58
|
return {
|
|
59
59
|
...chainUtils,
|
|
60
|
-
rspack,
|
|
60
|
+
rspack: import_core.rspack,
|
|
61
61
|
mergeConfig: merge,
|
|
62
62
|
addRules(rules) {
|
|
63
63
|
const ruleArr = (0, import_shared.castArray)(rules);
|
|
@@ -118,7 +118,7 @@ async function generateRspackConfig({
|
|
|
118
118
|
IgnorePlugin,
|
|
119
119
|
ProvidePlugin,
|
|
120
120
|
HotModuleReplacementPlugin
|
|
121
|
-
} =
|
|
121
|
+
} = import_core.rspack;
|
|
122
122
|
const chain = await (0, import_shared.modifyBundlerChain)(context, {
|
|
123
123
|
...chainUtils,
|
|
124
124
|
bundler: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type MultiStats, type Stats, type StatsError, isMultiCompiler } from '@rsbuild/shared';
|
|
2
2
|
import type { StatsCompilation, StatsValue } from '@rspack/core';
|
|
3
3
|
export declare const rspackMinVersion = "0.6.2";
|
|
4
4
|
export declare const isSatisfyRspackVersion: (originalVersion: string) => Promise<boolean>;
|
package/dist/provider/shared.js
CHANGED
|
@@ -192,11 +192,11 @@ function formatStats(stats, options = {}) {
|
|
|
192
192
|
level: "error"
|
|
193
193
|
};
|
|
194
194
|
}
|
|
195
|
-
if (
|
|
195
|
+
if (warnings.length) {
|
|
196
196
|
const title = import_shared.color.bold(import_shared.color.yellow("Compile Warning: \n"));
|
|
197
197
|
return {
|
|
198
|
-
message: `${title}${
|
|
199
|
-
|
|
198
|
+
message: `${title}${warnings.join("\n\n")}
|
|
199
|
+
`,
|
|
200
200
|
level: "warning"
|
|
201
201
|
};
|
|
202
202
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { type HtmlTag, type HtmlTagDescriptor, type ModifyHTMLTagsFn } from '@rsbuild/shared';
|
|
2
|
+
import type { Compiler } from '@rspack/core';
|
|
1
3
|
import type HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
2
4
|
import type { HtmlTagObject } from 'html-webpack-plugin';
|
|
3
|
-
import type { Compiler } from '@rspack/core';
|
|
4
|
-
import { type HtmlTag, type HtmlTagDescriptor, type ModifyHTMLTagsFn } from '@rsbuild/shared';
|
|
5
5
|
export type TagConfig = {
|
|
6
6
|
tags?: HtmlTagDescriptor[];
|
|
7
7
|
hash?: HtmlTag['hash'];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type InlineChunkTest } from '@rsbuild/shared';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Compilation, Compiler } from '@rspack/core';
|
|
3
3
|
import type { HtmlTagObject } from 'html-webpack-plugin';
|
|
4
4
|
export type InlineChunkHtmlPluginOptions = {
|
|
5
5
|
styleTests: InlineChunkTest[];
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
import { type PreloadOrPreFetchOption } from '@rsbuild/shared';
|
|
17
18
|
import type { Compiler, RspackPluginInstance } from '@rspack/core';
|
|
18
19
|
import type HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
19
|
-
import { type PreloadOrPreFetchOption } from '@rsbuild/shared';
|
|
20
20
|
type LinkType = 'preload' | 'prefetch';
|
|
21
21
|
export declare class HtmlPreloadOrPrefetchPlugin implements RspackPluginInstance {
|
|
22
22
|
readonly options: PreloadOrPreFetchOption;
|
|
@@ -27,8 +27,8 @@ __export(HtmlPreloadOrPrefetchPlugin_exports, {
|
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(HtmlPreloadOrPrefetchPlugin_exports);
|
|
29
29
|
var import_shared = require("@rsbuild/shared");
|
|
30
|
-
var import_helpers = require("./helpers");
|
|
31
30
|
var import_htmlUtils = require("../../htmlUtils");
|
|
31
|
+
var import_helpers = require("./helpers");
|
|
32
32
|
/**
|
|
33
33
|
* @license
|
|
34
34
|
* Copyright 2018 Google Inc.
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
import type { PreloadOrPreFetchOption } from '@rsbuild/shared';
|
|
17
18
|
import type { Compilation } from '@rspack/core';
|
|
18
19
|
import type { Chunk } from 'webpack';
|
|
19
|
-
import type { PreloadOrPreFetchOption } from '@rsbuild/shared';
|
|
20
20
|
import type { BeforeAssetTagGenerationHtmlPluginData } from './type';
|
|
21
21
|
interface DoesChunkBelongToHtmlOptions {
|
|
22
22
|
chunk: Chunk;
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import type { Chunk, Compilation } from 'webpack';
|
|
18
17
|
import type { PreloadIncludeType } from '@rsbuild/shared';
|
|
18
|
+
import type { Chunk, Compilation } from 'webpack';
|
|
19
19
|
export type ChunkGroup = Compilation['chunkGroups'][0];
|
|
20
20
|
interface ExtractChunks {
|
|
21
21
|
compilation: Compilation;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { LoaderContext } from '@rspack/core';
|
|
2
1
|
import type { RspackSourceMap } from '@rsbuild/shared';
|
|
2
|
+
import type { LoaderContext } from '@rspack/core';
|
|
3
3
|
export default function transform(this: LoaderContext<{
|
|
4
4
|
id: string;
|
|
5
5
|
}>, source: string, map?: string | RspackSourceMap): Promise<void>;
|
|
@@ -26,41 +26,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
31
|
-
default: () =>
|
|
29
|
+
var transformRawLoader_exports = {};
|
|
30
|
+
__export(transformRawLoader_exports, {
|
|
31
|
+
default: () => transformRawLoader_default,
|
|
32
32
|
raw: () => raw
|
|
33
33
|
});
|
|
34
|
-
module.exports = __toCommonJS(
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
let basename = "";
|
|
38
|
-
if (resourcePath) {
|
|
39
|
-
const parsed = import_node_path.default.parse(resourcePath);
|
|
40
|
-
if (parsed.dir) {
|
|
41
|
-
basename = parsed.name;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (basename) {
|
|
45
|
-
return `${basename}.node`;
|
|
46
|
-
}
|
|
47
|
-
return null;
|
|
48
|
-
};
|
|
49
|
-
function nodeAddonsLoader_default(source) {
|
|
50
|
-
const name = getFilename(this.resourcePath);
|
|
51
|
-
if (name === null) {
|
|
52
|
-
throw new Error(`Failed to load Node.js addon: "${this.resourcePath}"`);
|
|
53
|
-
}
|
|
54
|
-
this.emitFile(name, source);
|
|
55
|
-
return `
|
|
56
|
-
try {
|
|
57
|
-
const path = require("path");
|
|
58
|
-
process.dlopen(module, path.join(__dirname, "${name}"));
|
|
59
|
-
} catch (error) {
|
|
60
|
-
throw new Error('Failed to load Node.js addon: "${name}"\\n' + error);
|
|
61
|
-
}
|
|
62
|
-
`;
|
|
63
|
-
}
|
|
34
|
+
module.exports = __toCommonJS(transformRawLoader_exports);
|
|
35
|
+
var import_transformLoader = __toESM(require("./transformLoader"));
|
|
36
|
+
var transformRawLoader_default = import_transformLoader.default;
|
|
64
37
|
const raw = true;
|
|
65
38
|
// Annotate the CommonJS export names for ESM import in node:
|
|
66
39
|
0 && (module.exports = {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import type { IncomingMessage } from 'node:http';
|
|
4
4
|
import type { Socket } from 'node:net';
|
|
5
|
-
import type {
|
|
5
|
+
import type { DevMiddleware as CustomDevMiddleware, DevConfig, DevMiddlewareAPI, ServerConfig } from '@rsbuild/shared';
|
|
6
6
|
type Options = {
|
|
7
7
|
publicPaths: string[];
|
|
8
8
|
dev: DevConfig;
|
|
@@ -31,18 +31,20 @@ __export(devMiddleware_exports, {
|
|
|
31
31
|
getDevMiddleware: () => getDevMiddleware
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(devMiddleware_exports);
|
|
34
|
-
var import_webpack_dev_middleware = __toESM(require("@rsbuild/shared/webpack-dev-middleware"));
|
|
35
34
|
var import_shared = require("@rsbuild/shared");
|
|
35
|
+
var import_webpack_dev_middleware = __toESM(require("@rsbuild/shared/webpack-dev-middleware"));
|
|
36
36
|
function applyHMREntry({
|
|
37
37
|
compiler,
|
|
38
38
|
clientPaths,
|
|
39
|
-
clientConfig = {}
|
|
39
|
+
clientConfig = {},
|
|
40
|
+
liveReload = true
|
|
40
41
|
}) {
|
|
41
42
|
if (!(0, import_shared.isClientCompiler)(compiler)) {
|
|
42
43
|
return;
|
|
43
44
|
}
|
|
44
45
|
new compiler.webpack.DefinePlugin({
|
|
45
|
-
RSBUILD_CLIENT_CONFIG: JSON.stringify(clientConfig)
|
|
46
|
+
RSBUILD_CLIENT_CONFIG: JSON.stringify(clientConfig),
|
|
47
|
+
RSBUILD_DEV_LIVE_RELOAD: liveReload
|
|
46
48
|
}).apply(compiler);
|
|
47
49
|
for (const clientPath of clientPaths) {
|
|
48
50
|
new compiler.webpack.EntryPlugin(compiler.context, clientPath, {
|
|
@@ -51,13 +53,14 @@ function applyHMREntry({
|
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
const getDevMiddleware = (multiCompiler) => (options) => {
|
|
54
|
-
const { clientPaths, clientConfig, callbacks, ...restOptions } = options;
|
|
56
|
+
const { clientPaths, clientConfig, callbacks, liveReload, ...restOptions } = options;
|
|
55
57
|
const setupCompiler = (compiler) => {
|
|
56
58
|
if (clientPaths) {
|
|
57
59
|
applyHMREntry({
|
|
58
60
|
compiler,
|
|
59
61
|
clientPaths,
|
|
60
|
-
clientConfig
|
|
62
|
+
clientConfig,
|
|
63
|
+
liveReload
|
|
61
64
|
});
|
|
62
65
|
}
|
|
63
66
|
(0, import_shared.setupServerHooks)(compiler, callbacks);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type CreateDevMiddlewareReturns, type CreateDevServerOptions, type RsbuildDevServer, type StartDevServerOptions } from '@rsbuild/shared';
|
|
2
2
|
import type { InternalContext } from '../types';
|
|
3
3
|
export declare function createDevServer<Options extends {
|
|
4
4
|
context: InternalContext;
|
package/dist/server/devServer.js
CHANGED
|
@@ -32,12 +32,13 @@ __export(devServer_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(devServer_exports);
|
|
34
34
|
var import_shared = require("@rsbuild/shared");
|
|
35
|
-
var import_helper = require("./helper");
|
|
36
35
|
var import_connect = __toESM(require("@rsbuild/shared/connect"));
|
|
37
|
-
var import_restart = require("./restart");
|
|
38
|
-
var import_httpServer = require("./httpServer");
|
|
39
36
|
var import_getDevMiddlewares = require("./getDevMiddlewares");
|
|
37
|
+
var import_helper = require("./helper");
|
|
38
|
+
var import_httpServer = require("./httpServer");
|
|
40
39
|
var import_middlewares = require("./middlewares");
|
|
40
|
+
var import_restart = require("./restart");
|
|
41
|
+
var import_watchFiles = require("./watchFiles");
|
|
41
42
|
async function createDevServer(options, createDevMiddleware, {
|
|
42
43
|
compiler: customCompiler,
|
|
43
44
|
getPortSilently,
|
|
@@ -106,6 +107,11 @@ async function createDevServer(options, createDevMiddleware, {
|
|
|
106
107
|
});
|
|
107
108
|
}
|
|
108
109
|
const compileMiddlewareAPI = runCompile ? await startCompile() : void 0;
|
|
110
|
+
const fileWatcher = await (0, import_watchFiles.setupWatchFiles)({
|
|
111
|
+
dev: devConfig,
|
|
112
|
+
server: serverConfig,
|
|
113
|
+
compileMiddlewareAPI
|
|
114
|
+
});
|
|
109
115
|
const devMiddlewares = await (0, import_getDevMiddlewares.getMiddlewares)({
|
|
110
116
|
pwd: options.context.rootPath,
|
|
111
117
|
compileMiddlewareAPI,
|
|
@@ -172,6 +178,7 @@ async function createDevServer(options, createDevMiddleware, {
|
|
|
172
178
|
close: async () => {
|
|
173
179
|
await options.context.hooks.onCloseDevServer.call();
|
|
174
180
|
await devMiddlewares.close();
|
|
181
|
+
await fileWatcher?.close();
|
|
175
182
|
}
|
|
176
183
|
};
|
|
177
184
|
(0, import_shared.debug)("create dev server done");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CompileMiddlewareAPI, DevConfig, Middlewares, ServerConfig, UpgradeEvent } from '@rsbuild/shared';
|
|
2
2
|
export type RsbuildDevMiddlewareOptions = {
|
|
3
3
|
pwd: string;
|
|
4
4
|
dev: DevConfig;
|
|
@@ -31,10 +31,10 @@ __export(getDevMiddlewares_exports, {
|
|
|
31
31
|
getMiddlewares: () => getMiddlewares
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(getDevMiddlewares_exports);
|
|
34
|
+
var import_node_path = require("node:path");
|
|
34
35
|
var import_node_url = __toESM(require("node:url"));
|
|
35
36
|
var import_shared = require("@rsbuild/shared");
|
|
36
37
|
var import_middlewares = require("./middlewares");
|
|
37
|
-
var import_node_path = require("node:path");
|
|
38
38
|
const applySetupMiddlewares = (dev, compileMiddlewareAPI) => {
|
|
39
39
|
const setupMiddlewares = dev.setupMiddlewares || [];
|
|
40
40
|
const serverOptions = {
|
package/dist/server/helper.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DevConfig, OutputStructure, PrintUrls, Routes, RsbuildConfig, RsbuildEntry } from '@rsbuild/shared';
|
|
2
2
|
export declare const formatRoutes: (entry: RsbuildEntry, prefix: string | undefined, outputStructure: OutputStructure | undefined) => Routes;
|
|
3
3
|
export declare function printServerURLs({ urls: originalUrls, port, routes, protocol, printUrls, }: {
|
|
4
4
|
urls: Array<{
|
|
@@ -50,4 +50,5 @@ export declare const getDevOptions: ({ rsbuildConfig, getPortSilently, }: {
|
|
|
50
50
|
port: number;
|
|
51
51
|
host: string;
|
|
52
52
|
https: boolean;
|
|
53
|
+
liveReload: boolean | undefined;
|
|
53
54
|
}>;
|
package/dist/server/helper.js
CHANGED
|
@@ -136,7 +136,8 @@ const mergeDevOptions = ({
|
|
|
136
136
|
// By default it is set to "location.protocol === 'https:' ? 'wss' : 'ws'""
|
|
137
137
|
protocol: void 0
|
|
138
138
|
},
|
|
139
|
-
writeToDisk: false
|
|
139
|
+
writeToDisk: false,
|
|
140
|
+
liveReload: true
|
|
140
141
|
};
|
|
141
142
|
const devConfig = rsbuildConfig.dev ? (0, import_shared.deepmerge)(defaultDevConfig, rsbuildConfig.dev) : defaultDevConfig;
|
|
142
143
|
return devConfig;
|
|
@@ -214,12 +215,14 @@ const getDevOptions = async ({
|
|
|
214
215
|
getPortSilently
|
|
215
216
|
});
|
|
216
217
|
const devConfig = mergeDevOptions({ rsbuildConfig, port });
|
|
218
|
+
const liveReload = devConfig.liveReload;
|
|
217
219
|
return {
|
|
218
220
|
devConfig,
|
|
219
221
|
serverConfig,
|
|
220
222
|
port,
|
|
221
223
|
host,
|
|
222
|
-
https
|
|
224
|
+
https,
|
|
225
|
+
liveReload
|
|
223
226
|
};
|
|
224
227
|
};
|
|
225
228
|
// Annotate the CommonJS export names for ESM import in node:
|