@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.
Files changed (158) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +19 -0
  3. package/compiled/ansi-escapes/index.d.ts +248 -0
  4. package/compiled/ansi-escapes/index.js +1 -0
  5. package/compiled/ansi-escapes/license +9 -0
  6. package/compiled/ansi-escapes/package.json +1 -0
  7. package/compiled/ansi-escapes/type-fest/index.d.ts +2 -0
  8. package/compiled/babel-plugin-lodash/index.d.ts +1 -0
  9. package/compiled/babel-plugin-lodash/index.js +1 -0
  10. package/compiled/babel-plugin-lodash/license +44 -0
  11. package/compiled/babel-plugin-lodash/package.json +1 -0
  12. package/compiled/babel-plugin-transform-react-remove-prop-types/index.d.ts +1 -0
  13. package/compiled/babel-plugin-transform-react-remove-prop-types/index.js +1 -0
  14. package/compiled/babel-plugin-transform-react-remove-prop-types/license +22 -0
  15. package/compiled/babel-plugin-transform-react-remove-prop-types/package.json +1 -0
  16. package/compiled/cli-truncate/index.d.ts +96 -0
  17. package/compiled/cli-truncate/index.js +1 -0
  18. package/compiled/cli-truncate/license +9 -0
  19. package/compiled/cli-truncate/package.json +1 -0
  20. package/compiled/copy-webpack-plugin/index.d.ts +1 -0
  21. package/compiled/copy-webpack-plugin/index.js +22 -0
  22. package/compiled/copy-webpack-plugin/license +20 -0
  23. package/compiled/copy-webpack-plugin/package.json +1 -0
  24. package/compiled/patch-console/build/index.d.ts +4 -0
  25. package/compiled/patch-console/index.js +1 -0
  26. package/compiled/patch-console/package.json +1 -0
  27. package/compiled/schema-utils3/index.d.ts +1 -0
  28. package/compiled/schema-utils3/index.js +3 -0
  29. package/compiled/schema-utils3/license +20 -0
  30. package/compiled/schema-utils3/package.json +1 -0
  31. package/compiled/tapable/index.js +1 -0
  32. package/compiled/tapable/license +21 -0
  33. package/compiled/tapable/package.json +1 -0
  34. package/compiled/tapable/tapable.d.ts +116 -0
  35. package/compiled/webpack-manifest-plugin/index.js +1 -0
  36. package/compiled/webpack-manifest-plugin/license +21 -0
  37. package/compiled/webpack-manifest-plugin/package.json +1 -0
  38. package/compiled/webpack-manifest-plugin/types/helpers.d.ts +23 -0
  39. package/compiled/webpack-manifest-plugin/types/hooks.d.ts +24 -0
  40. package/compiled/webpack-manifest-plugin/types/index.d.ts +30 -0
  41. package/compiled/webpack-sources/index.d.ts +1 -0
  42. package/compiled/webpack-sources/index.js +1 -0
  43. package/compiled/webpack-sources/license +21 -0
  44. package/compiled/webpack-sources/package.json +1 -0
  45. package/dist/config/defaults.d.ts +3 -0
  46. package/dist/config/defaults.js +52 -0
  47. package/dist/config/normalize.d.ts +7 -0
  48. package/dist/config/normalize.js +33 -0
  49. package/dist/core/build.d.ts +20 -0
  50. package/dist/core/build.js +80 -0
  51. package/dist/core/createCompiler.d.ts +8 -0
  52. package/dist/core/createCompiler.js +68 -0
  53. package/dist/core/createContext.d.ts +13 -0
  54. package/dist/core/createContext.js +56 -0
  55. package/dist/core/devMiddleware.d.ts +5 -0
  56. package/dist/core/devMiddleware.js +73 -0
  57. package/dist/core/initConfigs.d.ts +14 -0
  58. package/dist/core/initConfigs.js +76 -0
  59. package/dist/core/initHooks.d.ts +19 -0
  60. package/dist/core/initHooks.js +44 -0
  61. package/dist/core/initPlugins.d.ts +9 -0
  62. package/dist/core/initPlugins.js +83 -0
  63. package/dist/core/inspectConfig.d.ts +20 -0
  64. package/dist/core/inspectConfig.js +81 -0
  65. package/dist/core/startDevServer.d.ts +5 -0
  66. package/dist/core/startDevServer.js +75 -0
  67. package/dist/core/webpackConfig.d.ts +9 -0
  68. package/dist/core/webpackConfig.js +164 -0
  69. package/dist/exports/webpack.d.ts +2 -0
  70. package/dist/exports/webpack.js +35 -0
  71. package/dist/index.d.ts +6 -0
  72. package/dist/index.js +34 -0
  73. package/dist/plugins/babel.d.ts +3 -0
  74. package/dist/plugins/babel.js +171 -0
  75. package/dist/plugins/basic.d.ts +5 -0
  76. package/dist/plugins/basic.js +60 -0
  77. package/dist/plugins/copy.d.ts +2 -0
  78. package/dist/plugins/copy.js +69 -0
  79. package/dist/plugins/css.d.ts +23 -0
  80. package/dist/plugins/css.js +123 -0
  81. package/dist/plugins/fallback.d.ts +2 -0
  82. package/dist/plugins/fallback.js +51 -0
  83. package/dist/plugins/hmr.d.ts +2 -0
  84. package/dist/plugins/hmr.js +41 -0
  85. package/dist/plugins/lazyCompilation.d.ts +2 -0
  86. package/dist/plugins/lazyCompilation.js +43 -0
  87. package/dist/plugins/less.d.ts +6 -0
  88. package/dist/plugins/less.js +65 -0
  89. package/dist/plugins/manifest.d.ts +2 -0
  90. package/dist/plugins/manifest.js +58 -0
  91. package/dist/plugins/minimize.d.ts +2 -0
  92. package/dist/plugins/minimize.js +64 -0
  93. package/dist/plugins/moduleScopes.d.ts +5 -0
  94. package/dist/plugins/moduleScopes.js +85 -0
  95. package/dist/plugins/output.d.ts +2 -0
  96. package/dist/plugins/output.js +66 -0
  97. package/dist/plugins/progress.d.ts +2 -0
  98. package/dist/plugins/progress.js +57 -0
  99. package/dist/plugins/react.d.ts +2 -0
  100. package/dist/plugins/react.js +96 -0
  101. package/dist/plugins/resolve.d.ts +2 -0
  102. package/dist/plugins/resolve.js +88 -0
  103. package/dist/plugins/sass.d.ts +2 -0
  104. package/dist/plugins/sass.js +76 -0
  105. package/dist/plugins/sri.d.ts +2 -0
  106. package/dist/plugins/sri.js +43 -0
  107. package/dist/plugins/tsLoader.d.ts +2 -0
  108. package/dist/plugins/tsLoader.js +103 -0
  109. package/dist/provider.d.ts +9 -0
  110. package/dist/provider.js +104 -0
  111. package/dist/shared/fs.d.ts +1 -0
  112. package/dist/shared/fs.js +38 -0
  113. package/dist/shared/index.d.ts +1 -0
  114. package/dist/shared/index.js +22 -0
  115. package/dist/shared/plugin.d.ts +5 -0
  116. package/dist/shared/plugin.js +111 -0
  117. package/dist/types/config/index.d.ts +30 -0
  118. package/dist/types/config/index.js +26 -0
  119. package/dist/types/config/security.d.ts +9 -0
  120. package/dist/types/config/security.js +16 -0
  121. package/dist/types/config/source.d.ts +26 -0
  122. package/dist/types/config/source.js +16 -0
  123. package/dist/types/config/tools.d.ts +52 -0
  124. package/dist/types/config/tools.js +16 -0
  125. package/dist/types/context.d.ts +17 -0
  126. package/dist/types/context.js +16 -0
  127. package/dist/types/hooks.d.ts +24 -0
  128. package/dist/types/hooks.js +16 -0
  129. package/dist/types/index.d.ts +5 -0
  130. package/dist/types/index.js +30 -0
  131. package/dist/types/plugin.d.ts +10 -0
  132. package/dist/types/plugin.js +16 -0
  133. package/dist/types/thirdParty/css.d.ts +7 -0
  134. package/dist/types/thirdParty/css.js +16 -0
  135. package/dist/types/thirdParty/index.d.ts +9 -0
  136. package/dist/types/thirdParty/index.js +16 -0
  137. package/dist/webpackPlugins/ModuleScopePlugin.d.ts +16 -0
  138. package/dist/webpackPlugins/ModuleScopePlugin.js +111 -0
  139. package/dist/webpackPlugins/ProgressPlugin/ProgressPlugin.d.ts +13 -0
  140. package/dist/webpackPlugins/ProgressPlugin/ProgressPlugin.js +102 -0
  141. package/dist/webpackPlugins/ProgressPlugin/helpers/bar.d.ts +5 -0
  142. package/dist/webpackPlugins/ProgressPlugin/helpers/bar.js +143 -0
  143. package/dist/webpackPlugins/ProgressPlugin/helpers/bus.d.ts +17 -0
  144. package/dist/webpackPlugins/ProgressPlugin/helpers/bus.js +105 -0
  145. package/dist/webpackPlugins/ProgressPlugin/helpers/index.d.ts +4 -0
  146. package/dist/webpackPlugins/ProgressPlugin/helpers/index.js +28 -0
  147. package/dist/webpackPlugins/ProgressPlugin/helpers/log.d.ts +8 -0
  148. package/dist/webpackPlugins/ProgressPlugin/helpers/log.js +62 -0
  149. package/dist/webpackPlugins/ProgressPlugin/helpers/nonTty.d.ts +15 -0
  150. package/dist/webpackPlugins/ProgressPlugin/helpers/nonTty.js +56 -0
  151. package/dist/webpackPlugins/ProgressPlugin/helpers/percentage.d.ts +7 -0
  152. package/dist/webpackPlugins/ProgressPlugin/helpers/percentage.js +52 -0
  153. package/dist/webpackPlugins/ProgressPlugin/helpers/type.d.ts +25 -0
  154. package/dist/webpackPlugins/ProgressPlugin/helpers/type.js +16 -0
  155. package/dist/webpackPlugins/ProgressPlugin/helpers/utils.d.ts +1 -0
  156. package/dist/webpackPlugins/ProgressPlugin/helpers/utils.js +30 -0
  157. package/package.json +88 -0
  158. package/static/ModuleFilenameHelpers.js +2 -0
@@ -0,0 +1,8 @@
1
+ import type { Context, WebpackConfig } from '../types';
2
+ export declare function createCompiler({
3
+ context,
4
+ webpackConfigs
5
+ }: {
6
+ context: Context;
7
+ webpackConfigs: WebpackConfig[];
8
+ }): Promise<import("webpack").Compiler | import("webpack").MultiCompiler>;
@@ -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,9 @@
1
+ import { type PluginStore } from '@rsbuild/shared';
2
+ import type { Context, RsbuildPluginAPI } from '../types';
3
+ export declare function getPluginAPI({
4
+ context,
5
+ pluginStore
6
+ }: {
7
+ context: Context;
8
+ pluginStore: PluginStore;
9
+ }): RsbuildPluginAPI;
@@ -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
+ });
@@ -0,0 +1,9 @@
1
+ import { type RsbuildTarget } from '@rsbuild/shared';
2
+ import type { Context, WebpackConfig } from '../types';
3
+ export declare function generateWebpackConfig({
4
+ target,
5
+ context
6
+ }: {
7
+ target: RsbuildTarget;
8
+ context: Context;
9
+ }): Promise<WebpackConfig>;