@rsbuild/webpack 0.0.0-next-20231103091827
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/LICENSE +21 -0
- package/README.md +19 -0
- package/compiled/ansi-escapes/index.d.ts +248 -0
- package/compiled/ansi-escapes/index.js +1 -0
- package/compiled/ansi-escapes/license +9 -0
- package/compiled/ansi-escapes/package.json +1 -0
- package/compiled/ansi-escapes/type-fest/index.d.ts +2 -0
- package/compiled/babel-plugin-lodash/index.d.ts +1 -0
- package/compiled/babel-plugin-lodash/index.js +1 -0
- package/compiled/babel-plugin-lodash/license +44 -0
- package/compiled/babel-plugin-lodash/package.json +1 -0
- package/compiled/babel-plugin-transform-react-remove-prop-types/index.d.ts +1 -0
- package/compiled/babel-plugin-transform-react-remove-prop-types/index.js +1 -0
- package/compiled/babel-plugin-transform-react-remove-prop-types/license +22 -0
- package/compiled/babel-plugin-transform-react-remove-prop-types/package.json +1 -0
- package/compiled/cli-truncate/index.d.ts +96 -0
- package/compiled/cli-truncate/index.js +1 -0
- package/compiled/cli-truncate/license +9 -0
- package/compiled/cli-truncate/package.json +1 -0
- package/compiled/copy-webpack-plugin/index.d.ts +1 -0
- package/compiled/copy-webpack-plugin/index.js +22 -0
- package/compiled/copy-webpack-plugin/license +20 -0
- package/compiled/copy-webpack-plugin/package.json +1 -0
- package/compiled/patch-console/build/index.d.ts +4 -0
- package/compiled/patch-console/index.js +1 -0
- package/compiled/patch-console/package.json +1 -0
- package/compiled/schema-utils3/index.d.ts +1 -0
- package/compiled/schema-utils3/index.js +3 -0
- package/compiled/schema-utils3/license +20 -0
- package/compiled/schema-utils3/package.json +1 -0
- package/compiled/tapable/index.js +1 -0
- package/compiled/tapable/license +21 -0
- package/compiled/tapable/package.json +1 -0
- package/compiled/tapable/tapable.d.ts +116 -0
- package/compiled/webpack-manifest-plugin/index.js +1 -0
- package/compiled/webpack-manifest-plugin/license +21 -0
- package/compiled/webpack-manifest-plugin/package.json +1 -0
- package/compiled/webpack-manifest-plugin/types/helpers.d.ts +23 -0
- package/compiled/webpack-manifest-plugin/types/hooks.d.ts +24 -0
- package/compiled/webpack-manifest-plugin/types/index.d.ts +30 -0
- package/compiled/webpack-sources/index.d.ts +1 -0
- package/compiled/webpack-sources/index.js +1 -0
- package/compiled/webpack-sources/license +21 -0
- package/compiled/webpack-sources/package.json +1 -0
- package/dist/config/defaults.d.ts +3 -0
- package/dist/config/defaults.js +52 -0
- package/dist/config/normalize.d.ts +7 -0
- package/dist/config/normalize.js +33 -0
- package/dist/core/build.d.ts +20 -0
- package/dist/core/build.js +80 -0
- package/dist/core/createCompiler.d.ts +8 -0
- package/dist/core/createCompiler.js +68 -0
- package/dist/core/createContext.d.ts +13 -0
- package/dist/core/createContext.js +56 -0
- package/dist/core/devMiddleware.d.ts +5 -0
- package/dist/core/devMiddleware.js +73 -0
- package/dist/core/initConfigs.d.ts +14 -0
- package/dist/core/initConfigs.js +76 -0
- package/dist/core/initHooks.d.ts +19 -0
- package/dist/core/initHooks.js +44 -0
- package/dist/core/initPlugins.d.ts +9 -0
- package/dist/core/initPlugins.js +83 -0
- package/dist/core/inspectConfig.d.ts +20 -0
- package/dist/core/inspectConfig.js +81 -0
- package/dist/core/startDevServer.d.ts +5 -0
- package/dist/core/startDevServer.js +75 -0
- package/dist/core/webpackConfig.d.ts +9 -0
- package/dist/core/webpackConfig.js +164 -0
- package/dist/exports/webpack.d.ts +2 -0
- package/dist/exports/webpack.js +35 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +34 -0
- package/dist/plugins/babel.d.ts +3 -0
- package/dist/plugins/babel.js +171 -0
- package/dist/plugins/basic.d.ts +5 -0
- package/dist/plugins/basic.js +60 -0
- package/dist/plugins/copy.d.ts +2 -0
- package/dist/plugins/copy.js +69 -0
- package/dist/plugins/css.d.ts +23 -0
- package/dist/plugins/css.js +123 -0
- package/dist/plugins/fallback.d.ts +2 -0
- package/dist/plugins/fallback.js +51 -0
- package/dist/plugins/hmr.d.ts +2 -0
- package/dist/plugins/hmr.js +41 -0
- package/dist/plugins/lazyCompilation.d.ts +2 -0
- package/dist/plugins/lazyCompilation.js +43 -0
- package/dist/plugins/less.d.ts +6 -0
- package/dist/plugins/less.js +65 -0
- package/dist/plugins/manifest.d.ts +2 -0
- package/dist/plugins/manifest.js +58 -0
- package/dist/plugins/minimize.d.ts +2 -0
- package/dist/plugins/minimize.js +64 -0
- package/dist/plugins/moduleScopes.d.ts +5 -0
- package/dist/plugins/moduleScopes.js +85 -0
- package/dist/plugins/output.d.ts +2 -0
- package/dist/plugins/output.js +66 -0
- package/dist/plugins/progress.d.ts +2 -0
- package/dist/plugins/progress.js +57 -0
- package/dist/plugins/react.d.ts +2 -0
- package/dist/plugins/react.js +96 -0
- package/dist/plugins/resolve.d.ts +2 -0
- package/dist/plugins/resolve.js +88 -0
- package/dist/plugins/sass.d.ts +2 -0
- package/dist/plugins/sass.js +76 -0
- package/dist/plugins/sri.d.ts +2 -0
- package/dist/plugins/sri.js +43 -0
- package/dist/plugins/tsLoader.d.ts +2 -0
- package/dist/plugins/tsLoader.js +103 -0
- package/dist/provider.d.ts +9 -0
- package/dist/provider.js +104 -0
- package/dist/shared/fs.d.ts +1 -0
- package/dist/shared/fs.js +38 -0
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.js +22 -0
- package/dist/shared/plugin.d.ts +5 -0
- package/dist/shared/plugin.js +111 -0
- package/dist/types/config/index.d.ts +30 -0
- package/dist/types/config/index.js +26 -0
- package/dist/types/config/security.d.ts +9 -0
- package/dist/types/config/security.js +16 -0
- package/dist/types/config/source.d.ts +26 -0
- package/dist/types/config/source.js +16 -0
- package/dist/types/config/tools.d.ts +52 -0
- package/dist/types/config/tools.js +16 -0
- package/dist/types/context.d.ts +17 -0
- package/dist/types/context.js +16 -0
- package/dist/types/hooks.d.ts +24 -0
- package/dist/types/hooks.js +16 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +30 -0
- package/dist/types/plugin.d.ts +10 -0
- package/dist/types/plugin.js +16 -0
- package/dist/types/thirdParty/css.d.ts +7 -0
- package/dist/types/thirdParty/css.js +16 -0
- package/dist/types/thirdParty/index.d.ts +9 -0
- package/dist/types/thirdParty/index.js +16 -0
- package/dist/webpackPlugins/ModuleScopePlugin.d.ts +16 -0
- package/dist/webpackPlugins/ModuleScopePlugin.js +111 -0
- package/dist/webpackPlugins/ProgressPlugin/ProgressPlugin.d.ts +13 -0
- package/dist/webpackPlugins/ProgressPlugin/ProgressPlugin.js +102 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/bar.d.ts +5 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/bar.js +143 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/bus.d.ts +17 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/bus.js +105 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/index.d.ts +4 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/index.js +28 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/log.d.ts +8 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/log.js +62 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/nonTty.d.ts +15 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/nonTty.js +56 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/percentage.d.ts +7 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/percentage.js +52 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/type.d.ts +25 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/type.js +16 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/utils.d.ts +1 -0
- package/dist/webpackPlugins/ProgressPlugin/helpers/utils.js +30 -0
- package/package.json +88 -0
- package/static/ModuleFilenameHelpers.js +2 -0
|
@@ -0,0 +1,68 @@
|
|
|
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 createCompiler_exports = {};
|
|
30
|
+
__export(createCompiler_exports, {
|
|
31
|
+
createCompiler: () => createCompiler
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(createCompiler_exports);
|
|
34
|
+
var import_shared = require("@rsbuild/shared");
|
|
35
|
+
async function createCompiler({
|
|
36
|
+
context,
|
|
37
|
+
webpackConfigs
|
|
38
|
+
}) {
|
|
39
|
+
(0, import_shared.debug)("create compiler");
|
|
40
|
+
await context.hooks.onBeforeCreateCompilerHook.call({
|
|
41
|
+
bundlerConfigs: webpackConfigs
|
|
42
|
+
});
|
|
43
|
+
const { default: webpack } = await Promise.resolve().then(() => __toESM(require("webpack")));
|
|
44
|
+
const compiler = webpackConfigs.length === 1 ? webpack(webpackConfigs[0]) : webpack(webpackConfigs);
|
|
45
|
+
let isFirstCompile = true;
|
|
46
|
+
compiler.hooks.done.tap("done", async (stats) => {
|
|
47
|
+
const { message, level } = (0, import_shared.formatStats)(stats);
|
|
48
|
+
if (level === "error") {
|
|
49
|
+
import_shared.logger.error(message);
|
|
50
|
+
}
|
|
51
|
+
if (level === "warning") {
|
|
52
|
+
import_shared.logger.warn(message);
|
|
53
|
+
}
|
|
54
|
+
if ((0, import_shared.isDev)()) {
|
|
55
|
+
await context.hooks.onDevCompileDoneHook.call({
|
|
56
|
+
isFirstCompile
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
isFirstCompile = false;
|
|
60
|
+
});
|
|
61
|
+
await context.hooks.onAfterCreateCompilerHook.call({ compiler });
|
|
62
|
+
(0, import_shared.debug)("create compiler done");
|
|
63
|
+
return compiler;
|
|
64
|
+
}
|
|
65
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
66
|
+
0 && (module.exports = {
|
|
67
|
+
createCompiler
|
|
68
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type CreateRsbuildOptions } from '@rsbuild/shared';
|
|
2
|
+
import type { Context, RsbuildConfig } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Create primary context.
|
|
5
|
+
* It will be assembled into a normal context or a stub for testing as needed.
|
|
6
|
+
* Usually it would be a pure function
|
|
7
|
+
*/
|
|
8
|
+
export declare function createPrimaryContext(options: Required<CreateRsbuildOptions>, userRsbuildConfig: RsbuildConfig): Context;
|
|
9
|
+
/**
|
|
10
|
+
* Generate the actual context used in the build,
|
|
11
|
+
* which can have a lot of overhead and take some side effects.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createContext(options: Required<CreateRsbuildOptions>, rsbuildConfig: RsbuildConfig): Promise<Context>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var createContext_exports = {};
|
|
20
|
+
__export(createContext_exports, {
|
|
21
|
+
createContext: () => createContext,
|
|
22
|
+
createPrimaryContext: () => createPrimaryContext
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(createContext_exports);
|
|
25
|
+
var import_path = require("path");
|
|
26
|
+
var import_shared = require("@rsbuild/shared");
|
|
27
|
+
var import_initHooks = require("./initHooks");
|
|
28
|
+
var import_defaults = require("../config/defaults");
|
|
29
|
+
function createPrimaryContext(options, userRsbuildConfig) {
|
|
30
|
+
const rsbuildConfig = (0, import_defaults.withDefaultConfig)(userRsbuildConfig);
|
|
31
|
+
const context = (0, import_shared.createContextByConfig)(
|
|
32
|
+
options,
|
|
33
|
+
rsbuildConfig.output,
|
|
34
|
+
"webpack"
|
|
35
|
+
);
|
|
36
|
+
return {
|
|
37
|
+
...context,
|
|
38
|
+
hooks: (0, import_initHooks.initHooks)(),
|
|
39
|
+
config: { ...rsbuildConfig },
|
|
40
|
+
originalConfig: userRsbuildConfig
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
async function createContext(options, rsbuildConfig) {
|
|
44
|
+
(0, import_shared.debug)("create context");
|
|
45
|
+
const ctx = createPrimaryContext(options, rsbuildConfig);
|
|
46
|
+
const tsconfigPath = (0, import_path.join)(ctx.rootPath, import_shared.TS_CONFIG_FILE);
|
|
47
|
+
if (await (0, import_shared.isFileExists)(tsconfigPath)) {
|
|
48
|
+
ctx.tsconfigPath = tsconfigPath;
|
|
49
|
+
}
|
|
50
|
+
return ctx;
|
|
51
|
+
}
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
createContext,
|
|
55
|
+
createPrimaryContext
|
|
56
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Compiler, MultiCompiler } from 'webpack';
|
|
2
|
+
import type { ModernDevServerOptions } from '@modern-js/server';
|
|
3
|
+
type DevMiddlewareOptions = ModernDevServerOptions['devMiddleware'];
|
|
4
|
+
export declare const getDevMiddleware: (compiler: Compiler | MultiCompiler) => NonNullable<DevMiddlewareOptions>;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
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 devMiddleware_exports = {};
|
|
30
|
+
__export(devMiddleware_exports, {
|
|
31
|
+
getDevMiddleware: () => getDevMiddleware
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(devMiddleware_exports);
|
|
34
|
+
var import_webpack_dev_middleware = __toESM(require("@rsbuild/shared/webpack-dev-middleware"));
|
|
35
|
+
var import_shared = require("@rsbuild/shared");
|
|
36
|
+
const applyHMREntry = (compiler, clientPath) => {
|
|
37
|
+
const applyEntry = (clientEntry, compiler2) => {
|
|
38
|
+
if ((0, import_shared.isClientCompiler)(compiler2)) {
|
|
39
|
+
new compiler2.webpack.EntryPlugin(compiler2.context, clientEntry, {
|
|
40
|
+
name: void 0
|
|
41
|
+
}).apply(compiler2);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
if (compiler.compilers) {
|
|
45
|
+
compiler.compilers.forEach((target) => {
|
|
46
|
+
applyEntry(clientPath, target);
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
applyEntry(clientPath, compiler);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const setupHooks = (compiler, hookCallbacks) => {
|
|
53
|
+
if (compiler.compilers) {
|
|
54
|
+
compiler.compilers.forEach(
|
|
55
|
+
(compiler2) => (0, import_shared.setupServerHooks)(compiler2, hookCallbacks)
|
|
56
|
+
);
|
|
57
|
+
} else {
|
|
58
|
+
(0, import_shared.setupServerHooks)(compiler, hookCallbacks);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const getDevMiddleware = (compiler) => (options) => {
|
|
62
|
+
const { hmrClientPath, callbacks, ...restOptions } = options;
|
|
63
|
+
hmrClientPath && applyHMREntry(compiler, hmrClientPath);
|
|
64
|
+
setupHooks(compiler, callbacks);
|
|
65
|
+
return (0, import_webpack_dev_middleware.default)(
|
|
66
|
+
compiler,
|
|
67
|
+
restOptions
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
+
0 && (module.exports = {
|
|
72
|
+
getDevMiddleware
|
|
73
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type PluginStore, type CreateRsbuildOptions } from '@rsbuild/shared';
|
|
2
|
+
import type { Context, WebpackConfig } from '../types';
|
|
3
|
+
export type InitConfigsOptions = {
|
|
4
|
+
context: Context;
|
|
5
|
+
pluginStore: PluginStore;
|
|
6
|
+
rsbuildOptions: Required<CreateRsbuildOptions>;
|
|
7
|
+
};
|
|
8
|
+
export declare function initConfigs({
|
|
9
|
+
context,
|
|
10
|
+
pluginStore,
|
|
11
|
+
rsbuildOptions
|
|
12
|
+
}: InitConfigsOptions): Promise<{
|
|
13
|
+
webpackConfigs: WebpackConfig[];
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var initConfigs_exports = {};
|
|
20
|
+
__export(initConfigs_exports, {
|
|
21
|
+
initConfigs: () => initConfigs
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(initConfigs_exports);
|
|
24
|
+
var import_shared = require("@rsbuild/shared");
|
|
25
|
+
var import_inspectConfig = require("./inspectConfig");
|
|
26
|
+
var import_webpackConfig = require("./webpackConfig");
|
|
27
|
+
var import_normalize = require("../config/normalize");
|
|
28
|
+
async function modifyRsbuildConfig(context) {
|
|
29
|
+
(0, import_shared.debug)("modify Rsbuild config");
|
|
30
|
+
const [modified] = await context.hooks.modifyRsbuildConfigHook.call(
|
|
31
|
+
context.config,
|
|
32
|
+
{ mergeRsbuildConfig: import_shared.mergeRsbuildConfig }
|
|
33
|
+
);
|
|
34
|
+
context.config = modified;
|
|
35
|
+
(0, import_shared.debug)("modify Rsbuild config done");
|
|
36
|
+
}
|
|
37
|
+
async function initConfigs({
|
|
38
|
+
context,
|
|
39
|
+
pluginStore,
|
|
40
|
+
rsbuildOptions
|
|
41
|
+
}) {
|
|
42
|
+
await (0, import_shared.initPlugins)({
|
|
43
|
+
pluginAPI: context.pluginAPI,
|
|
44
|
+
pluginStore
|
|
45
|
+
});
|
|
46
|
+
await modifyRsbuildConfig(context);
|
|
47
|
+
context.normalizedConfig = (0, import_normalize.normalizeConfig)(context.config);
|
|
48
|
+
const targets = (0, import_shared.castArray)(rsbuildOptions.target);
|
|
49
|
+
const webpackConfigs = await Promise.all(
|
|
50
|
+
targets.map((target) => (0, import_webpackConfig.generateWebpackConfig)({ target, context }))
|
|
51
|
+
);
|
|
52
|
+
if ((0, import_shared.isDebug)()) {
|
|
53
|
+
const inspect = () => {
|
|
54
|
+
const inspectOptions = {
|
|
55
|
+
verbose: true,
|
|
56
|
+
writeToDisk: true
|
|
57
|
+
};
|
|
58
|
+
(0, import_inspectConfig.inspectConfig)({
|
|
59
|
+
context,
|
|
60
|
+
pluginStore,
|
|
61
|
+
inspectOptions,
|
|
62
|
+
rsbuildOptions,
|
|
63
|
+
bundlerConfigs: webpackConfigs
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
context.hooks.onBeforeBuildHook.tap(inspect);
|
|
67
|
+
context.hooks.onBeforeStartDevServerHook.tap(inspect);
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
webpackConfigs
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
+
0 && (module.exports = {
|
|
75
|
+
initConfigs
|
|
76
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { OnExitFn, OnAfterBuildFn, OnBeforeBuildFn, OnDevCompileDoneFn, ModifyRsbuildConfigFn, OnAfterStartDevServerFn, OnBeforeStartDevServerFn, OnAfterCreateCompilerFn, OnBeforeCreateCompilerFn } from '@rsbuild/shared';
|
|
2
|
+
import type { ModifyBundlerChainFn } from '@rsbuild/shared';
|
|
3
|
+
import type { Compiler, MultiCompiler } from 'webpack';
|
|
4
|
+
import type { WebpackConfig, RsbuildConfig, ModifyWebpackChainFn, ModifyWebpackConfigFn } from '../types';
|
|
5
|
+
export declare function initHooks(): {
|
|
6
|
+
onExitHook: import("@rsbuild/shared").AsyncHook<OnExitFn>;
|
|
7
|
+
onAfterBuildHook: import("@rsbuild/shared").AsyncHook<OnAfterBuildFn>;
|
|
8
|
+
onBeforeBuildHook: import("@rsbuild/shared").AsyncHook<OnBeforeBuildFn<WebpackConfig>>;
|
|
9
|
+
onDevCompileDoneHook: import("@rsbuild/shared").AsyncHook<OnDevCompileDoneFn>;
|
|
10
|
+
modifyWebpackChainHook: import("@rsbuild/shared").AsyncHook<ModifyWebpackChainFn>;
|
|
11
|
+
modifyWebpackConfigHook: import("@rsbuild/shared").AsyncHook<ModifyWebpackConfigFn>;
|
|
12
|
+
modifyRsbuildConfigHook: import("@rsbuild/shared").AsyncHook<ModifyRsbuildConfigFn<RsbuildConfig>>;
|
|
13
|
+
onAfterCreateCompilerHook: import("@rsbuild/shared").AsyncHook<OnAfterCreateCompilerFn<Compiler | MultiCompiler>>;
|
|
14
|
+
onBeforeCreateCompilerHook: import("@rsbuild/shared").AsyncHook<OnBeforeCreateCompilerFn<WebpackConfig>>;
|
|
15
|
+
onAfterStartDevServerHook: import("@rsbuild/shared").AsyncHook<OnAfterStartDevServerFn>;
|
|
16
|
+
onBeforeStartDevServerHook: import("@rsbuild/shared").AsyncHook<OnBeforeStartDevServerFn>;
|
|
17
|
+
modifyBundlerChainHook: import("@rsbuild/shared").AsyncHook<ModifyBundlerChainFn>;
|
|
18
|
+
};
|
|
19
|
+
export type Hooks = ReturnType<typeof initHooks>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var initHooks_exports = {};
|
|
20
|
+
__export(initHooks_exports, {
|
|
21
|
+
initHooks: () => initHooks
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(initHooks_exports);
|
|
24
|
+
var import_shared = require("@rsbuild/shared");
|
|
25
|
+
function initHooks() {
|
|
26
|
+
return {
|
|
27
|
+
onExitHook: (0, import_shared.createAsyncHook)(),
|
|
28
|
+
onAfterBuildHook: (0, import_shared.createAsyncHook)(),
|
|
29
|
+
onBeforeBuildHook: (0, import_shared.createAsyncHook)(),
|
|
30
|
+
onDevCompileDoneHook: (0, import_shared.createAsyncHook)(),
|
|
31
|
+
modifyWebpackChainHook: (0, import_shared.createAsyncHook)(),
|
|
32
|
+
modifyWebpackConfigHook: (0, import_shared.createAsyncHook)(),
|
|
33
|
+
modifyRsbuildConfigHook: (0, import_shared.createAsyncHook)(),
|
|
34
|
+
onAfterCreateCompilerHook: (0, import_shared.createAsyncHook)(),
|
|
35
|
+
onBeforeCreateCompilerHook: (0, import_shared.createAsyncHook)(),
|
|
36
|
+
onAfterStartDevServerHook: (0, import_shared.createAsyncHook)(),
|
|
37
|
+
onBeforeStartDevServerHook: (0, import_shared.createAsyncHook)(),
|
|
38
|
+
modifyBundlerChainHook: (0, import_shared.createAsyncHook)()
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
initHooks
|
|
44
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var initPlugins_exports = {};
|
|
20
|
+
__export(initPlugins_exports, {
|
|
21
|
+
getPluginAPI: () => getPluginAPI
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(initPlugins_exports);
|
|
24
|
+
var import_shared = require("@rsbuild/shared");
|
|
25
|
+
function getPluginAPI({
|
|
26
|
+
context,
|
|
27
|
+
pluginStore
|
|
28
|
+
}) {
|
|
29
|
+
const { hooks } = context;
|
|
30
|
+
const publicContext = (0, import_shared.createPublicContext)(context);
|
|
31
|
+
const getRsbuildConfig = () => {
|
|
32
|
+
if (!context.normalizedConfig) {
|
|
33
|
+
throw new Error(
|
|
34
|
+
"Cannot access Rsbuild config until modifyRsbuildConfig is called."
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
return context.config;
|
|
38
|
+
};
|
|
39
|
+
const getNormalizedConfig = () => {
|
|
40
|
+
if (!context.normalizedConfig) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
"Cannot access normalized config until modifyRsbuildConfig is called."
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
return context.normalizedConfig;
|
|
46
|
+
};
|
|
47
|
+
const getHTMLPaths = () => {
|
|
48
|
+
return Object.keys(context.entry).reduce(
|
|
49
|
+
(prev, key) => {
|
|
50
|
+
prev[key] = (0, import_shared.getHTMLPathByEntry)(key, getNormalizedConfig());
|
|
51
|
+
return prev;
|
|
52
|
+
},
|
|
53
|
+
{}
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
(0, import_shared.onExitProcess)(() => {
|
|
57
|
+
hooks.onExitHook.call();
|
|
58
|
+
});
|
|
59
|
+
return {
|
|
60
|
+
context: publicContext,
|
|
61
|
+
getHTMLPaths,
|
|
62
|
+
getRsbuildConfig,
|
|
63
|
+
getNormalizedConfig,
|
|
64
|
+
isPluginExists: pluginStore.isPluginExists,
|
|
65
|
+
// Hooks
|
|
66
|
+
onExit: hooks.onExitHook.tap,
|
|
67
|
+
onAfterBuild: hooks.onAfterBuildHook.tap,
|
|
68
|
+
onBeforeBuild: hooks.onBeforeBuildHook.tap,
|
|
69
|
+
onDevCompileDone: hooks.onDevCompileDoneHook.tap,
|
|
70
|
+
modifyBundlerChain: hooks.modifyBundlerChainHook.tap,
|
|
71
|
+
modifyWebpackChain: hooks.modifyWebpackChainHook.tap,
|
|
72
|
+
modifyWebpackConfig: hooks.modifyWebpackConfigHook.tap,
|
|
73
|
+
modifyRsbuildConfig: hooks.modifyRsbuildConfigHook.tap,
|
|
74
|
+
onAfterCreateCompiler: hooks.onAfterCreateCompilerHook.tap,
|
|
75
|
+
onBeforeCreateCompiler: hooks.onBeforeCreateCompilerHook.tap,
|
|
76
|
+
onAfterStartDevServer: hooks.onAfterStartDevServerHook.tap,
|
|
77
|
+
onBeforeStartDevServer: hooks.onBeforeStartDevServerHook.tap
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
getPluginAPI
|
|
83
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { InitConfigsOptions } from './initConfigs';
|
|
2
|
+
import { InspectConfigOptions } from '@rsbuild/shared';
|
|
3
|
+
import type { WebpackConfig } from '../types';
|
|
4
|
+
export declare function inspectConfig({
|
|
5
|
+
context,
|
|
6
|
+
pluginStore,
|
|
7
|
+
rsbuildOptions,
|
|
8
|
+
bundlerConfigs,
|
|
9
|
+
inspectOptions
|
|
10
|
+
}: InitConfigsOptions & {
|
|
11
|
+
inspectOptions?: InspectConfigOptions;
|
|
12
|
+
bundlerConfigs?: WebpackConfig[];
|
|
13
|
+
}): Promise<{
|
|
14
|
+
rsbuildConfig: string;
|
|
15
|
+
bundlerConfigs: string[];
|
|
16
|
+
origin: {
|
|
17
|
+
rsbuildConfig: Readonly<import("../types").RsbuildConfig>;
|
|
18
|
+
bundlerConfigs: WebpackConfig[];
|
|
19
|
+
};
|
|
20
|
+
}>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var inspectConfig_exports = {};
|
|
20
|
+
__export(inspectConfig_exports, {
|
|
21
|
+
inspectConfig: () => inspectConfig
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(inspectConfig_exports);
|
|
24
|
+
var import_path = require("path");
|
|
25
|
+
var import_initConfigs = require("./initConfigs");
|
|
26
|
+
var import_shared = require("@rsbuild/shared");
|
|
27
|
+
async function inspectConfig({
|
|
28
|
+
context,
|
|
29
|
+
pluginStore,
|
|
30
|
+
rsbuildOptions,
|
|
31
|
+
bundlerConfigs,
|
|
32
|
+
inspectOptions = {}
|
|
33
|
+
}) {
|
|
34
|
+
if (inspectOptions.env) {
|
|
35
|
+
process.env.NODE_ENV = inspectOptions.env;
|
|
36
|
+
} else if (!process.env.NODE_ENV) {
|
|
37
|
+
process.env.NODE_ENV = "development";
|
|
38
|
+
}
|
|
39
|
+
const webpackConfigs = bundlerConfigs || (await (0, import_initConfigs.initConfigs)({
|
|
40
|
+
context,
|
|
41
|
+
pluginStore,
|
|
42
|
+
rsbuildOptions
|
|
43
|
+
})).webpackConfigs;
|
|
44
|
+
const rawRsbuildConfig = await (0, import_shared.stringifyConfig)(
|
|
45
|
+
context.config,
|
|
46
|
+
inspectOptions.verbose
|
|
47
|
+
);
|
|
48
|
+
const rawBundlerConfigs = await Promise.all(
|
|
49
|
+
webpackConfigs.map(
|
|
50
|
+
(config) => (0, import_shared.stringifyConfig)(config, inspectOptions.verbose)
|
|
51
|
+
)
|
|
52
|
+
);
|
|
53
|
+
let outputPath = inspectOptions.outputPath || context.distPath;
|
|
54
|
+
if (!(0, import_path.isAbsolute)(outputPath)) {
|
|
55
|
+
outputPath = (0, import_path.join)(context.rootPath, outputPath);
|
|
56
|
+
}
|
|
57
|
+
if (inspectOptions.writeToDisk) {
|
|
58
|
+
await (0, import_shared.outputInspectConfigFiles)({
|
|
59
|
+
rsbuildConfig: rawRsbuildConfig,
|
|
60
|
+
bundlerConfigs: rawBundlerConfigs,
|
|
61
|
+
inspectOptions: {
|
|
62
|
+
...inspectOptions,
|
|
63
|
+
outputPath
|
|
64
|
+
},
|
|
65
|
+
rsbuildOptions,
|
|
66
|
+
configType: "webpack"
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
rsbuildConfig: rawRsbuildConfig,
|
|
71
|
+
bundlerConfigs: rawBundlerConfigs,
|
|
72
|
+
origin: {
|
|
73
|
+
rsbuildConfig: context.config,
|
|
74
|
+
bundlerConfigs: webpackConfigs
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
79
|
+
0 && (module.exports = {
|
|
80
|
+
inspectConfig
|
|
81
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { StartDevServerOptions } from '@rsbuild/shared';
|
|
2
|
+
import { InitConfigsOptions } from './initConfigs';
|
|
3
|
+
import type { Compiler, MultiCompiler } from 'webpack';
|
|
4
|
+
export declare function createDevServer(options: InitConfigsOptions, port: number, serverOptions: Exclude<StartDevServerOptions['serverOptions'], undefined>, customCompiler?: Compiler | MultiCompiler): Promise<import("@modern-js/server").Server>;
|
|
5
|
+
export declare function startDevServer(options: InitConfigsOptions, startDevServerOptions?: StartDevServerOptions): Promise<import("@rsbuild/shared").StartServerResult>;
|
|
@@ -0,0 +1,75 @@
|
|
|
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 startDevServer_exports = {};
|
|
30
|
+
__export(startDevServer_exports, {
|
|
31
|
+
createDevServer: () => createDevServer,
|
|
32
|
+
startDevServer: () => startDevServer
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(startDevServer_exports);
|
|
35
|
+
var import_shared = require("@rsbuild/shared");
|
|
36
|
+
var import_createCompiler = require("./createCompiler");
|
|
37
|
+
var import_initConfigs = require("./initConfigs");
|
|
38
|
+
var import_devMiddleware = require("./devMiddleware");
|
|
39
|
+
async function createDevServer(options, port, serverOptions, customCompiler) {
|
|
40
|
+
const { Server } = await Promise.resolve().then(() => __toESM(require("@modern-js/server")));
|
|
41
|
+
let compiler;
|
|
42
|
+
if (customCompiler) {
|
|
43
|
+
compiler = customCompiler;
|
|
44
|
+
} else {
|
|
45
|
+
const { webpackConfigs } = await (0, import_initConfigs.initConfigs)(options);
|
|
46
|
+
compiler = await (0, import_createCompiler.createCompiler)({
|
|
47
|
+
context: options.context,
|
|
48
|
+
webpackConfigs
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
(0, import_shared.debug)("create dev server");
|
|
52
|
+
const rsbuildConfig = options.context.config;
|
|
53
|
+
const { config, devConfig } = await (0, import_shared.getDevServerOptions)({
|
|
54
|
+
rsbuildConfig,
|
|
55
|
+
serverOptions,
|
|
56
|
+
port
|
|
57
|
+
});
|
|
58
|
+
const server = new Server({
|
|
59
|
+
pwd: options.context.rootPath,
|
|
60
|
+
devMiddleware: (0, import_devMiddleware.getDevMiddleware)(compiler),
|
|
61
|
+
...serverOptions,
|
|
62
|
+
dev: devConfig,
|
|
63
|
+
config
|
|
64
|
+
});
|
|
65
|
+
(0, import_shared.debug)("create dev server done");
|
|
66
|
+
return server;
|
|
67
|
+
}
|
|
68
|
+
async function startDevServer(options, startDevServerOptions = {}) {
|
|
69
|
+
return (0, import_shared.startDevServer)(options, createDevServer, startDevServerOptions);
|
|
70
|
+
}
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
createDevServer,
|
|
74
|
+
startDevServer
|
|
75
|
+
});
|