@rsbuild/core 0.7.0-beta.3 → 0.7.0-beta.5

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 (181) hide show
  1. package/bin/rsbuild.js +4 -3
  2. package/compiled/css-loader/index.js +20 -20
  3. package/compiled/less-loader/index.js +8 -8
  4. package/compiled/postcss-loader/index.js +11 -11
  5. package/compiled/rspack-manifest-plugin/index.js +4 -4
  6. package/dist/{rspack/ignoreCssLoader.js → ignoreCssLoader.cjs} +2 -0
  7. package/dist/index.cjs +7195 -0
  8. package/dist/index.js +7428 -40
  9. package/dist/{rspack/transformLoader.js → transformLoader.cjs} +2 -0
  10. package/dist/{rspack/transformRawLoader.js → transformRawLoader.cjs} +37 -13
  11. package/{dist → dist-types}/constants.d.ts +3 -0
  12. package/dist-types/helpers.d.ts +32 -0
  13. package/{dist → dist-types}/index.d.ts +6 -0
  14. package/{dist → dist-types}/internal.d.ts +5 -3
  15. package/dist-types/package.json +1 -0
  16. package/{dist → dist-types}/plugins/html.d.ts +2 -1
  17. package/{dist → dist-types}/plugins/index.d.ts +1 -0
  18. package/dist-types/plugins/minimize.d.ts +12 -0
  19. package/{dist/provider → dist-types}/plugins/progress.d.ts +1 -1
  20. package/{dist/provider → dist-types}/plugins/resolve.d.ts +1 -1
  21. package/{dist/provider → dist-types}/plugins/rspackProfile.d.ts +1 -1
  22. package/{dist/provider → dist-types}/plugins/swc.d.ts +1 -1
  23. package/dist-types/server/devMiddleware.d.ts +18 -0
  24. package/{dist → dist-types}/server/helper.d.ts +11 -0
  25. package/package.json +14 -16
  26. package/dist/cli/commands.js +0 -110
  27. package/dist/cli/init.js +0 -101
  28. package/dist/cli/prepare.js +0 -43
  29. package/dist/client/format.js +0 -72
  30. package/dist/config.js +0 -306
  31. package/dist/constants.js +0 -40
  32. package/dist/createContext.js +0 -116
  33. package/dist/createRsbuild.js +0 -103
  34. package/dist/initHooks.js +0 -82
  35. package/dist/initPlugins.js +0 -152
  36. package/dist/internal.js +0 -79
  37. package/dist/loadEnv.js +0 -93
  38. package/dist/mergeConfig.js +0 -80
  39. package/dist/pluginHelper.js +0 -66
  40. package/dist/pluginManager.js +0 -180
  41. package/dist/plugins/asset.js +0 -101
  42. package/dist/plugins/basic.js +0 -77
  43. package/dist/plugins/bundleAnalyzer.js +0 -69
  44. package/dist/plugins/cache.js +0 -116
  45. package/dist/plugins/cleanOutput.js +0 -68
  46. package/dist/plugins/css.js +0 -257
  47. package/dist/plugins/define.js +0 -45
  48. package/dist/plugins/entry.js +0 -76
  49. package/dist/plugins/externals.js +0 -48
  50. package/dist/plugins/fileSize.js +0 -199
  51. package/dist/plugins/html.js +0 -327
  52. package/dist/plugins/index.js +0 -66
  53. package/dist/plugins/inlineChunk.js +0 -69
  54. package/dist/plugins/less.js +0 -107
  55. package/dist/plugins/manifest.js +0 -142
  56. package/dist/plugins/moduleFederation.js +0 -125
  57. package/dist/plugins/moment.js +0 -43
  58. package/dist/plugins/nodeAddons.js +0 -74
  59. package/dist/plugins/output.js +0 -63
  60. package/dist/plugins/performance.js +0 -56
  61. package/dist/plugins/resourceHints.js +0 -86
  62. package/dist/plugins/rsdoctor.js +0 -81
  63. package/dist/plugins/sass.js +0 -154
  64. package/dist/plugins/server.js +0 -59
  65. package/dist/plugins/splitChunks.js +0 -236
  66. package/dist/plugins/startUrl.js +0 -146
  67. package/dist/plugins/target.js +0 -54
  68. package/dist/plugins/wasm.js +0 -51
  69. package/dist/provider/build.js +0 -84
  70. package/dist/provider/createCompiler.js +0 -143
  71. package/dist/provider/initConfigs.js +0 -92
  72. package/dist/provider/inspectConfig.js +0 -85
  73. package/dist/provider/plugins/minimize.d.ts +0 -2
  74. package/dist/provider/plugins/minimize.js +0 -49
  75. package/dist/provider/plugins/progress.js +0 -49
  76. package/dist/provider/plugins/resolve.js +0 -42
  77. package/dist/provider/plugins/rspackProfile.js +0 -112
  78. package/dist/provider/plugins/swc.js +0 -152
  79. package/dist/provider/plugins/transition.d.ts +0 -5
  80. package/dist/provider/plugins/transition.js +0 -35
  81. package/dist/provider/provider.js +0 -158
  82. package/dist/provider/rspackConfig.js +0 -144
  83. package/dist/provider/shared.d.ts +0 -16
  84. package/dist/provider/shared.js +0 -215
  85. package/dist/rspack/HtmlAppIconPlugin.js +0 -98
  86. package/dist/rspack/HtmlBasicPlugin.js +0 -229
  87. package/dist/rspack/InlineChunkHtmlPlugin.js +0 -196
  88. package/dist/rspack/preload/HtmlPreloadOrPrefetchPlugin.js +0 -173
  89. package/dist/rspack/preload/helpers/determineAsValue.js +0 -83
  90. package/dist/rspack/preload/helpers/doesChunkBelongToHtml.js +0 -77
  91. package/dist/rspack/preload/helpers/extractChunks.js +0 -83
  92. package/dist/rspack/preload/helpers/index.js +0 -28
  93. package/dist/rspack/preload/helpers/type.js +0 -16
  94. package/dist/server/compilerDevMiddleware.js +0 -129
  95. package/dist/server/devMiddleware.d.ts +0 -3
  96. package/dist/server/devMiddleware.js +0 -74
  97. package/dist/server/devServer.js +0 -195
  98. package/dist/server/getDevMiddlewares.js +0 -177
  99. package/dist/server/helper.js +0 -237
  100. package/dist/server/httpServer.js +0 -45
  101. package/dist/server/index.js +0 -31
  102. package/dist/server/middlewares.js +0 -162
  103. package/dist/server/prodServer.js +0 -196
  104. package/dist/server/proxy.js +0 -93
  105. package/dist/server/restart.js +0 -66
  106. package/dist/server/socketServer.js +0 -178
  107. package/dist/server/watchFiles.js +0 -90
  108. package/dist/types.js +0 -16
  109. /package/dist/client/{hmr.mjs → hmr.js} +0 -0
  110. /package/dist/client/{overlay.mjs → overlay.js} +0 -0
  111. /package/{dist → dist-types}/cli/commands.d.ts +0 -0
  112. /package/{dist → dist-types}/cli/init.d.ts +0 -0
  113. /package/{dist → dist-types}/cli/prepare.d.ts +0 -0
  114. /package/{dist → dist-types}/client/format.d.ts +0 -0
  115. /package/{dist → dist-types}/client/hmr.d.ts +0 -0
  116. /package/{dist → dist-types}/client/overlay.d.ts +0 -0
  117. /package/{dist → dist-types}/config.d.ts +0 -0
  118. /package/{dist → dist-types}/createContext.d.ts +0 -0
  119. /package/{dist → dist-types}/createRsbuild.d.ts +0 -0
  120. /package/{dist → dist-types}/initHooks.d.ts +0 -0
  121. /package/{dist → dist-types}/initPlugins.d.ts +0 -0
  122. /package/{dist → dist-types}/loadEnv.d.ts +0 -0
  123. /package/{dist/rspack → dist-types/loader}/ignoreCssLoader.d.ts +0 -0
  124. /package/{dist/rspack → dist-types/loader}/transformLoader.d.ts +0 -0
  125. /package/{dist/rspack → dist-types/loader}/transformRawLoader.d.ts +0 -0
  126. /package/{dist → dist-types}/mergeConfig.d.ts +0 -0
  127. /package/{dist → dist-types}/pluginHelper.d.ts +0 -0
  128. /package/{dist → dist-types}/pluginManager.d.ts +0 -0
  129. /package/{dist → dist-types}/plugins/asset.d.ts +0 -0
  130. /package/{dist → dist-types}/plugins/basic.d.ts +0 -0
  131. /package/{dist → dist-types}/plugins/bundleAnalyzer.d.ts +0 -0
  132. /package/{dist → dist-types}/plugins/cache.d.ts +0 -0
  133. /package/{dist → dist-types}/plugins/cleanOutput.d.ts +0 -0
  134. /package/{dist → dist-types}/plugins/css.d.ts +0 -0
  135. /package/{dist → dist-types}/plugins/define.d.ts +0 -0
  136. /package/{dist → dist-types}/plugins/entry.d.ts +0 -0
  137. /package/{dist → dist-types}/plugins/externals.d.ts +0 -0
  138. /package/{dist → dist-types}/plugins/fileSize.d.ts +0 -0
  139. /package/{dist → dist-types}/plugins/inlineChunk.d.ts +0 -0
  140. /package/{dist → dist-types}/plugins/less.d.ts +0 -0
  141. /package/{dist → dist-types}/plugins/manifest.d.ts +0 -0
  142. /package/{dist → dist-types}/plugins/moduleFederation.d.ts +0 -0
  143. /package/{dist → dist-types}/plugins/moment.d.ts +0 -0
  144. /package/{dist → dist-types}/plugins/nodeAddons.d.ts +0 -0
  145. /package/{dist → dist-types}/plugins/output.d.ts +0 -0
  146. /package/{dist → dist-types}/plugins/performance.d.ts +0 -0
  147. /package/{dist → dist-types}/plugins/resourceHints.d.ts +0 -0
  148. /package/{dist → dist-types}/plugins/rsdoctor.d.ts +0 -0
  149. /package/{dist → dist-types}/plugins/sass.d.ts +0 -0
  150. /package/{dist → dist-types}/plugins/server.d.ts +0 -0
  151. /package/{dist → dist-types}/plugins/splitChunks.d.ts +0 -0
  152. /package/{dist → dist-types}/plugins/startUrl.d.ts +0 -0
  153. /package/{dist → dist-types}/plugins/target.d.ts +0 -0
  154. /package/{dist → dist-types}/plugins/wasm.d.ts +0 -0
  155. /package/{dist → dist-types}/provider/build.d.ts +0 -0
  156. /package/{dist → dist-types}/provider/createCompiler.d.ts +0 -0
  157. /package/{dist → dist-types}/provider/initConfigs.d.ts +0 -0
  158. /package/{dist → dist-types}/provider/inspectConfig.d.ts +0 -0
  159. /package/{dist → dist-types}/provider/provider.d.ts +0 -0
  160. /package/{dist → dist-types}/provider/rspackConfig.d.ts +0 -0
  161. /package/{dist → dist-types}/rspack/HtmlAppIconPlugin.d.ts +0 -0
  162. /package/{dist → dist-types}/rspack/HtmlBasicPlugin.d.ts +0 -0
  163. /package/{dist → dist-types}/rspack/InlineChunkHtmlPlugin.d.ts +0 -0
  164. /package/{dist → dist-types}/rspack/preload/HtmlPreloadOrPrefetchPlugin.d.ts +0 -0
  165. /package/{dist → dist-types}/rspack/preload/helpers/determineAsValue.d.ts +0 -0
  166. /package/{dist → dist-types}/rspack/preload/helpers/doesChunkBelongToHtml.d.ts +0 -0
  167. /package/{dist → dist-types}/rspack/preload/helpers/extractChunks.d.ts +0 -0
  168. /package/{dist → dist-types}/rspack/preload/helpers/index.d.ts +0 -0
  169. /package/{dist → dist-types}/rspack/preload/helpers/type.d.ts +0 -0
  170. /package/{dist → dist-types}/server/compilerDevMiddleware.d.ts +0 -0
  171. /package/{dist → dist-types}/server/devServer.d.ts +0 -0
  172. /package/{dist → dist-types}/server/getDevMiddlewares.d.ts +0 -0
  173. /package/{dist → dist-types}/server/httpServer.d.ts +0 -0
  174. /package/{dist → dist-types}/server/index.d.ts +0 -0
  175. /package/{dist → dist-types}/server/middlewares.d.ts +0 -0
  176. /package/{dist → dist-types}/server/prodServer.d.ts +0 -0
  177. /package/{dist → dist-types}/server/proxy.d.ts +0 -0
  178. /package/{dist → dist-types}/server/restart.d.ts +0 -0
  179. /package/{dist → dist-types}/server/socketServer.d.ts +0 -0
  180. /package/{dist → dist-types}/server/watchFiles.d.ts +0 -0
  181. /package/{dist → dist-types}/types.d.ts +0 -0
@@ -1,152 +0,0 @@
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 swc_exports = {};
30
- __export(swc_exports, {
31
- applySwcDecoratorConfig: () => applySwcDecoratorConfig,
32
- pluginSwc: () => pluginSwc
33
- });
34
- module.exports = __toCommonJS(swc_exports);
35
- var import_node_path = __toESM(require("node:path"));
36
- var import_shared = require("@rsbuild/shared");
37
- var import_constants = require("../../constants");
38
- const builtinSwcLoaderName = "builtin:swc-loader";
39
- async function getDefaultSwcConfig(config, rootPath, target) {
40
- return {
41
- jsc: {
42
- externalHelpers: true,
43
- parser: {
44
- tsx: false,
45
- syntax: "typescript",
46
- decorators: true
47
- },
48
- // Avoid the webpack magic comment to be removed
49
- // https://github.com/swc-project/swc/issues/6403
50
- preserveAllComments: true
51
- },
52
- isModule: "unknown",
53
- env: {
54
- targets: await (0, import_shared.getBrowserslistWithDefault)(rootPath, config, target)
55
- }
56
- };
57
- }
58
- const pluginSwc = () => ({
59
- name: import_constants.PLUGIN_SWC_NAME,
60
- setup(api) {
61
- api.modifyBundlerChain({
62
- order: "pre",
63
- handler: async (chain, { CHAIN_ID, target }) => {
64
- const config = api.getNormalizedConfig();
65
- const rule = chain.module.rule(CHAIN_ID.RULE.JS).test(import_shared.SCRIPT_REGEX).type("javascript/auto");
66
- (0, import_shared.applyScriptCondition)({
67
- rule,
68
- chain,
69
- config,
70
- context: api.context,
71
- includes: [],
72
- excludes: []
73
- });
74
- const swcConfig = await getDefaultSwcConfig(
75
- config,
76
- api.context.rootPath,
77
- target
78
- );
79
- applyTransformImport(swcConfig, config.source.transformImport);
80
- applySwcDecoratorConfig(swcConfig, config);
81
- if (swcConfig.jsc?.externalHelpers) {
82
- chain.resolve.alias.set(
83
- "@swc/helpers",
84
- import_node_path.default.dirname(require.resolve("@swc/helpers/package.json"))
85
- );
86
- }
87
- if ((0, import_shared.isWebTarget)(target)) {
88
- const polyfillMode = config.output.polyfill;
89
- if (polyfillMode === "off") {
90
- swcConfig.env.mode = void 0;
91
- } else {
92
- swcConfig.env.mode = polyfillMode;
93
- await applyCoreJs(swcConfig, chain, polyfillMode);
94
- }
95
- }
96
- const mergedSwcConfig = (0, import_shared.mergeChainedOptions)({
97
- defaults: swcConfig,
98
- options: config.tools.swc,
99
- mergeFn: import_shared.deepmerge
100
- });
101
- rule.use(CHAIN_ID.USE.SWC).loader(builtinSwcLoaderName).options(mergedSwcConfig);
102
- chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).mimetype({
103
- or: ["text/javascript", "application/javascript"]
104
- }).resolve.set("fullySpecified", false).end().use(CHAIN_ID.USE.SWC).loader(builtinSwcLoaderName).options((0, import_shared.cloneDeep)(mergedSwcConfig));
105
- }
106
- });
107
- }
108
- });
109
- async function applyCoreJs(swcConfig, chain, polyfillMode) {
110
- const coreJsPath = require.resolve("core-js/package.json");
111
- const version = (0, import_shared.getCoreJsVersion)(coreJsPath);
112
- const coreJsDir = import_node_path.default.dirname(coreJsPath);
113
- swcConfig.env.coreJs = version;
114
- if (polyfillMode === "usage") {
115
- swcConfig.env.shippedProposals = true;
116
- }
117
- chain.resolve.alias.merge({
118
- "core-js": coreJsDir
119
- });
120
- }
121
- function applyTransformImport(swcConfig, pluginImport) {
122
- var _a;
123
- if (pluginImport !== false && pluginImport) {
124
- swcConfig.rspackExperiments ?? (swcConfig.rspackExperiments = {});
125
- (_a = swcConfig.rspackExperiments).import ?? (_a.import = []);
126
- swcConfig.rspackExperiments.import.push(...pluginImport);
127
- }
128
- }
129
- function applySwcDecoratorConfig(swcConfig, config) {
130
- var _a;
131
- swcConfig.jsc || (swcConfig.jsc = {});
132
- (_a = swcConfig.jsc).transform || (_a.transform = {});
133
- const { version } = config.source.decorators;
134
- switch (version) {
135
- case "legacy":
136
- swcConfig.jsc.transform.legacyDecorator = true;
137
- swcConfig.jsc.transform.decoratorMetadata = true;
138
- swcConfig.jsc.transform.useDefineForClassFields = false;
139
- break;
140
- case "2022-03":
141
- swcConfig.jsc.transform.legacyDecorator = false;
142
- swcConfig.jsc.transform.decoratorVersion = "2022-03";
143
- break;
144
- default:
145
- throw new Error("Unknown decorators version: ${version}");
146
- }
147
- }
148
- // Annotate the CommonJS export names for ESM import in node:
149
- 0 && (module.exports = {
150
- applySwcDecoratorConfig,
151
- pluginSwc
152
- });
@@ -1,5 +0,0 @@
1
- import type { RsbuildPlugin } from '../../types';
2
- /**
3
- * Provide some temporary configurations for Rspack early transition
4
- */
5
- export declare const pluginTransition: () => RsbuildPlugin;
@@ -1,35 +0,0 @@
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 transition_exports = {};
20
- __export(transition_exports, {
21
- pluginTransition: () => pluginTransition
22
- });
23
- module.exports = __toCommonJS(transition_exports);
24
- const pluginTransition = () => ({
25
- name: "rsbuild:transition",
26
- setup() {
27
- var _a;
28
- process.env.RSPACK_CONFIG_VALIDATE = "loose-silent";
29
- (_a = process.env).WATCHPACK_WATCHER_LIMIT || (_a.WATCHPACK_WATCHER_LIMIT = "20");
30
- }
31
- });
32
- // Annotate the CommonJS export names for ESM import in node:
33
- 0 && (module.exports = {
34
- pluginTransition
35
- });
@@ -1,158 +0,0 @@
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 provider_exports = {};
30
- __export(provider_exports, {
31
- rspackProvider: () => rspackProvider
32
- });
33
- module.exports = __toCommonJS(provider_exports);
34
- var import_shared = require("@rsbuild/shared");
35
- var import_createContext = require("../createContext");
36
- var import_initPlugins = require("../initPlugins");
37
- var import_plugins = require("../plugins");
38
- var import_initConfigs = require("./initConfigs");
39
- const rspackProvider = async ({
40
- pluginManager,
41
- rsbuildOptions
42
- }) => {
43
- const rsbuildConfig = (0, import_shared.pickRsbuildConfig)(rsbuildOptions.rsbuildConfig);
44
- const context = await (0, import_createContext.createContext)(rsbuildOptions, rsbuildConfig, "rspack");
45
- const pluginAPI = (0, import_initPlugins.getPluginAPI)({ context, pluginManager });
46
- context.pluginAPI = pluginAPI;
47
- const createCompiler = async () => {
48
- const { createCompiler: createCompiler2 } = await Promise.resolve().then(() => __toESM(require("./createCompiler")));
49
- const { rspackConfigs } = await (0, import_initConfigs.initConfigs)({
50
- context,
51
- pluginManager,
52
- rsbuildOptions
53
- });
54
- return createCompiler2({
55
- context,
56
- rspackConfigs
57
- });
58
- };
59
- return {
60
- bundler: "rspack",
61
- pluginAPI,
62
- createCompiler,
63
- publicContext: (0, import_createContext.createPublicContext)(context),
64
- async applyDefaultPlugins() {
65
- const allPlugins = await Promise.all([
66
- Promise.resolve().then(() => __toESM(require("./plugins/transition"))).then((m) => m.pluginTransition()),
67
- import_plugins.plugins.basic(),
68
- import_plugins.plugins.entry(),
69
- // plugins.cache(),
70
- import_plugins.plugins.target(),
71
- import_plugins.plugins.output(),
72
- Promise.resolve().then(() => __toESM(require("./plugins/resolve"))).then((m) => m.pluginResolve()),
73
- import_plugins.plugins.fileSize(),
74
- // cleanOutput plugin should before the html plugin
75
- import_plugins.plugins.cleanOutput(),
76
- import_plugins.plugins.asset(),
77
- import_plugins.plugins.html(async (tags) => {
78
- const result = await context.hooks.modifyHTMLTags.call(tags);
79
- return result[0];
80
- }),
81
- import_plugins.plugins.wasm(),
82
- import_plugins.plugins.moment(),
83
- import_plugins.plugins.nodeAddons(),
84
- import_plugins.plugins.define(),
85
- import_plugins.plugins.css(),
86
- import_plugins.plugins.less(),
87
- import_plugins.plugins.sass(),
88
- Promise.resolve().then(() => __toESM(require("./plugins/minimize"))).then((m) => m.pluginMinimize()),
89
- Promise.resolve().then(() => __toESM(require("./plugins/progress"))).then((m) => m.pluginProgress()),
90
- Promise.resolve().then(() => __toESM(require("./plugins/swc"))).then((m) => m.pluginSwc()),
91
- import_plugins.plugins.externals(),
92
- import_plugins.plugins.splitChunks(),
93
- import_plugins.plugins.startUrl(),
94
- import_plugins.plugins.inlineChunk(),
95
- import_plugins.plugins.bundleAnalyzer(),
96
- import_plugins.plugins.rsdoctor(),
97
- import_plugins.plugins.resourceHints(),
98
- import_plugins.plugins.performance(),
99
- import_plugins.plugins.server(),
100
- import_plugins.plugins.moduleFederation(),
101
- import_plugins.plugins.manifest(),
102
- Promise.resolve().then(() => __toESM(require("./plugins/rspackProfile"))).then((m) => m.pluginRspackProfile())
103
- ]);
104
- pluginManager.addPlugins(allPlugins);
105
- },
106
- async createDevServer(options) {
107
- const { createDevServer } = await Promise.resolve().then(() => __toESM(require("../server/devServer")));
108
- const { createDevMiddleware } = await Promise.resolve().then(() => __toESM(require("./createCompiler")));
109
- await (0, import_initConfigs.initRsbuildConfig)({ context, pluginManager });
110
- return createDevServer(
111
- { context, pluginManager, rsbuildOptions },
112
- createDevMiddleware,
113
- options
114
- );
115
- },
116
- async startDevServer(options) {
117
- const { createDevServer } = await Promise.resolve().then(() => __toESM(require("../server/devServer")));
118
- const { createDevMiddleware } = await Promise.resolve().then(() => __toESM(require("./createCompiler")));
119
- await (0, import_initConfigs.initRsbuildConfig)({ context, pluginManager });
120
- const server = await createDevServer(
121
- { context, pluginManager, rsbuildOptions },
122
- createDevMiddleware,
123
- options
124
- );
125
- return server.listen();
126
- },
127
- async preview(options) {
128
- const { startProdServer } = await Promise.resolve().then(() => __toESM(require("../server/prodServer")));
129
- await (0, import_initConfigs.initRsbuildConfig)({ context, pluginManager });
130
- return startProdServer(context, context.config, options);
131
- },
132
- async build(options) {
133
- const { build } = await Promise.resolve().then(() => __toESM(require("./build")));
134
- return build({ context, pluginManager, rsbuildOptions }, options);
135
- },
136
- async initConfigs() {
137
- const { rspackConfigs } = await (0, import_initConfigs.initConfigs)({
138
- context,
139
- pluginManager,
140
- rsbuildOptions
141
- });
142
- return rspackConfigs;
143
- },
144
- async inspectConfig(inspectOptions) {
145
- const { inspectConfig } = await Promise.resolve().then(() => __toESM(require("./inspectConfig")));
146
- return inspectConfig({
147
- context,
148
- pluginManager,
149
- rsbuildOptions,
150
- inspectOptions
151
- });
152
- }
153
- };
154
- };
155
- // Annotate the CommonJS export names for ESM import in node:
156
- 0 && (module.exports = {
157
- rspackProvider
158
- });
@@ -1,144 +0,0 @@
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 rspackConfig_exports = {};
30
- __export(rspackConfig_exports, {
31
- generateRspackConfig: () => generateRspackConfig,
32
- getChainUtils: () => getChainUtils
33
- });
34
- module.exports = __toCommonJS(rspackConfig_exports);
35
- var import_shared = require("@rsbuild/shared");
36
- var import_core = require("@rspack/core");
37
- var import_pluginHelper = require("../pluginHelper");
38
- var import_shared2 = require("./shared");
39
- async function modifyRspackConfig(context, rspackConfig, utils) {
40
- (0, import_shared.debug)("modify Rspack config");
41
- let [modifiedConfig] = await context.hooks.modifyRspackConfig.call(
42
- rspackConfig,
43
- utils
44
- );
45
- if (context.config.tools?.rspack) {
46
- modifiedConfig = (0, import_shared.mergeChainedOptions)({
47
- defaults: modifiedConfig,
48
- options: context.config.tools.rspack,
49
- utils,
50
- mergeFn: utils.mergeConfig
51
- });
52
- }
53
- (0, import_shared.debug)("modify Rspack config done");
54
- return modifiedConfig;
55
- }
56
- async function getConfigUtils(config, chainUtils) {
57
- const { merge } = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared/webpack-merge")));
58
- return {
59
- ...chainUtils,
60
- rspack: import_core.rspack,
61
- mergeConfig: merge,
62
- addRules(rules) {
63
- const ruleArr = (0, import_shared.castArray)(rules);
64
- if (!config.module) {
65
- config.module = {};
66
- }
67
- if (!config.module.rules) {
68
- config.module.rules = [];
69
- }
70
- config.module.rules.unshift(...ruleArr);
71
- },
72
- prependPlugins(plugins) {
73
- const pluginArr = (0, import_shared.castArray)(plugins);
74
- if (!config.plugins) {
75
- config.plugins = [];
76
- }
77
- config.plugins.unshift(...pluginArr);
78
- },
79
- appendPlugins(plugins) {
80
- const pluginArr = (0, import_shared.castArray)(plugins);
81
- if (!config.plugins) {
82
- config.plugins = [];
83
- }
84
- config.plugins.push(...pluginArr);
85
- },
86
- removePlugin(pluginName) {
87
- if (config.plugins) {
88
- config.plugins = config.plugins.filter(
89
- (p) => p && p.name !== pluginName
90
- );
91
- }
92
- }
93
- };
94
- }
95
- function getChainUtils(target) {
96
- const nodeEnv = (0, import_shared.getNodeEnv)();
97
- return {
98
- env: nodeEnv,
99
- target,
100
- isDev: nodeEnv === "development",
101
- isProd: nodeEnv === "production",
102
- isServer: target === "node",
103
- isWebWorker: target === "web-worker",
104
- isServiceWorker: target === "service-worker",
105
- getCompiledPath: import_shared2.getCompiledPath,
106
- CHAIN_ID: import_shared.CHAIN_ID,
107
- HtmlPlugin: (0, import_pluginHelper.getHTMLPlugin)()
108
- };
109
- }
110
- async function generateRspackConfig({
111
- target,
112
- context
113
- }) {
114
- const chainUtils = getChainUtils(target);
115
- const {
116
- BannerPlugin,
117
- DefinePlugin,
118
- IgnorePlugin,
119
- ProvidePlugin,
120
- HotModuleReplacementPlugin
121
- } = import_core.rspack;
122
- const chain = await (0, import_shared.modifyBundlerChain)(context, {
123
- ...chainUtils,
124
- bundler: {
125
- BannerPlugin,
126
- DefinePlugin,
127
- IgnorePlugin,
128
- ProvidePlugin,
129
- HotModuleReplacementPlugin
130
- }
131
- });
132
- let rspackConfig = (0, import_shared.chainToConfig)(chain);
133
- rspackConfig = await modifyRspackConfig(
134
- context,
135
- rspackConfig,
136
- await getConfigUtils(rspackConfig, chainUtils)
137
- );
138
- return rspackConfig;
139
- }
140
- // Annotate the CommonJS export names for ESM import in node:
141
- 0 && (module.exports = {
142
- generateRspackConfig,
143
- getChainUtils
144
- });
@@ -1,16 +0,0 @@
1
- import { type MultiStats, type Stats, type StatsError, isMultiCompiler } from '@rsbuild/shared';
2
- import type { StatsCompilation, StatsValue } from '@rspack/core';
3
- export declare const rspackMinVersion = "0.6.2";
4
- export declare const isSatisfyRspackVersion: (originalVersion: string) => Promise<boolean>;
5
- export declare const getCompiledPath: (packageName: string) => string;
6
- export declare const BUILTIN_LOADER = "builtin:";
7
- export declare const getAllStatsErrors: (statsData: StatsCompilation) => StatsError[] | undefined;
8
- export declare const getAllStatsWarnings: (statsData: StatsCompilation) => StatsError[] | undefined;
9
- export declare function getStatsOptions(compiler: Parameters<typeof isMultiCompiler>[0]): StatsValue | undefined;
10
- export declare function formatStats(stats: Stats | MultiStats, options?: StatsValue): {
11
- message: string;
12
- level: string;
13
- } | {
14
- message?: undefined;
15
- level?: undefined;
16
- };