@rsbuild/core 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 (147) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +19 -0
  3. package/bin/rsbuild.js +24 -0
  4. package/dist/cli/commands.d.ts +7 -0
  5. package/dist/cli/commands.js +53 -0
  6. package/dist/cli/config.d.ts +12 -0
  7. package/dist/cli/config.js +90 -0
  8. package/dist/cli/index.d.ts +6 -0
  9. package/dist/cli/index.js +48 -0
  10. package/dist/createRsbuild.d.ts +11 -0
  11. package/dist/createRsbuild.js +103 -0
  12. package/dist/index.d.ts +5 -0
  13. package/dist/index.js +36 -0
  14. package/dist/plugins/asset.d.ts +3 -0
  15. package/dist/plugins/asset.js +67 -0
  16. package/dist/plugins/assetsRetry.d.ts +2 -0
  17. package/dist/plugins/assetsRetry.js +66 -0
  18. package/dist/plugins/bundleAnalyzer.d.ts +2 -0
  19. package/dist/plugins/bundleAnalyzer.js +59 -0
  20. package/dist/plugins/cache.d.ts +2 -0
  21. package/dist/plugins/cache.js +115 -0
  22. package/dist/plugins/cleanOutput.d.ts +2 -0
  23. package/dist/plugins/cleanOutput.js +47 -0
  24. package/dist/plugins/define.d.ts +2 -0
  25. package/dist/plugins/define.js +59 -0
  26. package/dist/plugins/devtool.d.ts +2 -0
  27. package/dist/plugins/devtool.js +46 -0
  28. package/dist/plugins/entry.d.ts +2 -0
  29. package/dist/plugins/entry.js +42 -0
  30. package/dist/plugins/externals.d.ts +2 -0
  31. package/dist/plugins/externals.js +48 -0
  32. package/dist/plugins/fileSize.d.ts +4 -0
  33. package/dist/plugins/fileSize.js +160 -0
  34. package/dist/plugins/html.d.ts +7 -0
  35. package/dist/plugins/html.js +242 -0
  36. package/dist/plugins/index.d.ts +2 -0
  37. package/dist/plugins/index.js +67 -0
  38. package/dist/plugins/inlineChunk.d.ts +2 -0
  39. package/dist/plugins/inlineChunk.js +85 -0
  40. package/dist/plugins/moment.d.ts +2 -0
  41. package/dist/plugins/moment.js +43 -0
  42. package/dist/plugins/networkPerformance.d.ts +2 -0
  43. package/dist/plugins/networkPerformance.js +58 -0
  44. package/dist/plugins/nodeAddons.d.ts +2 -0
  45. package/dist/plugins/nodeAddons.js +78 -0
  46. package/dist/plugins/performance.d.ts +5 -0
  47. package/dist/plugins/performance.js +63 -0
  48. package/dist/plugins/preloadOrPrefetch.d.ts +2 -0
  49. package/dist/plugins/preloadOrPrefetch.js +61 -0
  50. package/dist/plugins/rem.d.ts +2 -0
  51. package/dist/plugins/rem.js +103 -0
  52. package/dist/plugins/splitChunks.d.ts +4 -0
  53. package/dist/plugins/splitChunks.js +251 -0
  54. package/dist/plugins/startUrl.d.ts +12 -0
  55. package/dist/plugins/startUrl.js +146 -0
  56. package/dist/plugins/target.d.ts +2 -0
  57. package/dist/plugins/target.js +53 -0
  58. package/dist/plugins/toml.d.ts +2 -0
  59. package/dist/plugins/toml.js +36 -0
  60. package/dist/plugins/wasm.d.ts +2 -0
  61. package/dist/plugins/wasm.js +51 -0
  62. package/dist/plugins/yaml.d.ts +2 -0
  63. package/dist/plugins/yaml.js +36 -0
  64. package/dist/rspack-provider/config/defaults.d.ts +3 -0
  65. package/dist/rspack-provider/config/defaults.js +40 -0
  66. package/dist/rspack-provider/config/normalize.d.ts +7 -0
  67. package/dist/rspack-provider/config/normalize.js +33 -0
  68. package/dist/rspack-provider/core/build.d.ts +19 -0
  69. package/dist/rspack-provider/core/build.js +79 -0
  70. package/dist/rspack-provider/core/createCompiler.d.ts +9 -0
  71. package/dist/rspack-provider/core/createCompiler.js +83 -0
  72. package/dist/rspack-provider/core/createContext.d.ts +7 -0
  73. package/dist/rspack-provider/core/createContext.js +47 -0
  74. package/dist/rspack-provider/core/devMiddleware.d.ts +5 -0
  75. package/dist/rspack-provider/core/devMiddleware.js +65 -0
  76. package/dist/rspack-provider/core/initConfigs.d.ts +14 -0
  77. package/dist/rspack-provider/core/initConfigs.js +76 -0
  78. package/dist/rspack-provider/core/initHooks.d.ts +18 -0
  79. package/dist/rspack-provider/core/initHooks.js +45 -0
  80. package/dist/rspack-provider/core/initPlugins.d.ts +9 -0
  81. package/dist/rspack-provider/core/initPlugins.js +82 -0
  82. package/dist/rspack-provider/core/inspectConfig.d.ts +19 -0
  83. package/dist/rspack-provider/core/inspectConfig.js +81 -0
  84. package/dist/rspack-provider/core/rspackConfig.d.ts +9 -0
  85. package/dist/rspack-provider/core/rspackConfig.js +137 -0
  86. package/dist/rspack-provider/core/startDevServer.d.ts +6 -0
  87. package/dist/rspack-provider/core/startDevServer.js +84 -0
  88. package/dist/rspack-provider/index.d.ts +5 -0
  89. package/dist/rspack-provider/index.js +31 -0
  90. package/dist/rspack-provider/plugins/basic.d.ts +5 -0
  91. package/dist/rspack-provider/plugins/basic.js +34 -0
  92. package/dist/rspack-provider/plugins/css.d.ts +29 -0
  93. package/dist/rspack-provider/plugins/css.js +214 -0
  94. package/dist/rspack-provider/plugins/fallback.d.ts +2 -0
  95. package/dist/rspack-provider/plugins/fallback.js +54 -0
  96. package/dist/rspack-provider/plugins/hmr.d.ts +2 -0
  97. package/dist/rspack-provider/plugins/hmr.js +38 -0
  98. package/dist/rspack-provider/plugins/less.d.ts +2 -0
  99. package/dist/rspack-provider/plugins/less.js +78 -0
  100. package/dist/rspack-provider/plugins/manifest.d.ts +2 -0
  101. package/dist/rspack-provider/plugins/manifest.js +58 -0
  102. package/dist/rspack-provider/plugins/minimize.d.ts +5 -0
  103. package/dist/rspack-provider/plugins/minimize.js +77 -0
  104. package/dist/rspack-provider/plugins/output.d.ts +2 -0
  105. package/dist/rspack-provider/plugins/output.js +65 -0
  106. package/dist/rspack-provider/plugins/progress.d.ts +2 -0
  107. package/dist/rspack-provider/plugins/progress.js +57 -0
  108. package/dist/rspack-provider/plugins/resolve.d.ts +2 -0
  109. package/dist/rspack-provider/plugins/resolve.js +55 -0
  110. package/dist/rspack-provider/plugins/rspack-profile.d.ts +4 -0
  111. package/dist/rspack-provider/plugins/rspack-profile.js +107 -0
  112. package/dist/rspack-provider/plugins/sass.d.ts +2 -0
  113. package/dist/rspack-provider/plugins/sass.js +83 -0
  114. package/dist/rspack-provider/plugins/swc.d.ts +7 -0
  115. package/dist/rspack-provider/plugins/swc.js +151 -0
  116. package/dist/rspack-provider/plugins/transition.d.ts +5 -0
  117. package/dist/rspack-provider/plugins/transition.js +42 -0
  118. package/dist/rspack-provider/provider.d.ts +8 -0
  119. package/dist/rspack-provider/provider.js +116 -0
  120. package/dist/rspack-provider/rspackLoader/css-modules-typescript-pre-loader/index.d.ts +6 -0
  121. package/dist/rspack-provider/rspackLoader/css-modules-typescript-pre-loader/index.js +84 -0
  122. package/dist/rspack-provider/rspackLoader/css-modules-typescript-pre-loader/postcss-icss-extract-plugin.d.ts +11 -0
  123. package/dist/rspack-provider/rspackLoader/css-modules-typescript-pre-loader/postcss-icss-extract-plugin.js +67 -0
  124. package/dist/rspack-provider/rspackPlugin/removeCssSourcemapPlugin.d.ts +8 -0
  125. package/dist/rspack-provider/rspackPlugin/removeCssSourcemapPlugin.js +51 -0
  126. package/dist/rspack-provider/shared/constants.d.ts +1 -0
  127. package/dist/rspack-provider/shared/constants.js +28 -0
  128. package/dist/rspack-provider/shared/fs.d.ts +1 -0
  129. package/dist/rspack-provider/shared/fs.js +38 -0
  130. package/dist/rspack-provider/shared/index.d.ts +3 -0
  131. package/dist/rspack-provider/shared/index.js +26 -0
  132. package/dist/rspack-provider/shared/plugin.d.ts +3 -0
  133. package/dist/rspack-provider/shared/plugin.js +83 -0
  134. package/dist/rspack-provider/shared/rspackVersion.d.ts +3 -0
  135. package/dist/rspack-provider/shared/rspackVersion.js +61 -0
  136. package/dist/rspack-provider/types/context.d.ts +16 -0
  137. package/dist/rspack-provider/types/context.js +16 -0
  138. package/dist/rspack-provider/types/hooks.d.ts +3 -0
  139. package/dist/rspack-provider/types/hooks.js +16 -0
  140. package/dist/rspack-provider/types/index.d.ts +4 -0
  141. package/dist/rspack-provider/types/index.js +26 -0
  142. package/dist/rspack-provider/types/plugin.d.ts +7 -0
  143. package/dist/rspack-provider/types/plugin.js +16 -0
  144. package/dist/utils/generateMetaTags.d.ts +12 -0
  145. package/dist/utils/generateMetaTags.js +50 -0
  146. package/package.json +98 -0
  147. package/static/openChrome.applescript +95 -0
@@ -0,0 +1,242 @@
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 html_exports = {};
30
+ __export(html_exports, {
31
+ applyInjectTags: () => applyInjectTags,
32
+ getMetaTags: () => getMetaTags,
33
+ pluginHtml: () => pluginHtml
34
+ });
35
+ module.exports = __toCommonJS(html_exports);
36
+ var import_path = __toESM(require("path"));
37
+ var import_shared = require("@rsbuild/shared");
38
+ var import_fs_extra = require("@rsbuild/shared/fs-extra");
39
+ var import_lodash = __toESM(require("lodash"));
40
+ var import_generateMetaTags = require("../utils/generateMetaTags");
41
+ async function getMetaTags(entryName, config) {
42
+ const { meta, metaByEntries } = config.html;
43
+ const metaOptions = {};
44
+ if (config.output.charset === "utf8") {
45
+ metaOptions.charset = { charset: "utf-8" };
46
+ }
47
+ Object.assign(metaOptions, meta, metaByEntries == null ? void 0 : metaByEntries[entryName]);
48
+ return (0, import_generateMetaTags.generateMetaTags)(metaOptions);
49
+ }
50
+ async function getTemplateParameters(entryName, config, assetPrefix) {
51
+ const { mountId, templateParameters, templateParametersByEntries } = config.html;
52
+ const title = (0, import_shared.getTitle)(entryName, config);
53
+ const templateParams = (templateParametersByEntries == null ? void 0 : templateParametersByEntries[entryName]) || templateParameters;
54
+ const baseParameters = {
55
+ title,
56
+ mountId,
57
+ entryName,
58
+ assetPrefix
59
+ };
60
+ return (compilation, assets, assetTags, pluginOptions) => {
61
+ const defaultOptions = {
62
+ compilation,
63
+ webpackConfig: compilation.options,
64
+ htmlWebpackPlugin: {
65
+ tags: assetTags,
66
+ files: assets,
67
+ options: pluginOptions
68
+ },
69
+ ...baseParameters
70
+ };
71
+ return (0, import_shared.mergeChainedOptions)(defaultOptions, templateParams);
72
+ };
73
+ }
74
+ async function getChunks(entryName, entryValue) {
75
+ const dependOn = [];
76
+ if ((0, import_shared.isPlainObject)(entryValue)) {
77
+ dependOn.push(...entryValue.dependOn);
78
+ }
79
+ return [...dependOn, entryName];
80
+ }
81
+ const applyInjectTags = (api) => {
82
+ api.modifyBundlerChain(async (chain, { HtmlPlugin, CHAIN_ID }) => {
83
+ const config = api.getNormalizedConfig();
84
+ const tags = (0, import_shared.castArray)(config.html.tags).filter(Boolean);
85
+ const tagsByEntries = import_lodash.default.mapValues(
86
+ config.html.tagsByEntries,
87
+ (tags2) => (0, import_shared.castArray)(tags2).filter(Boolean)
88
+ );
89
+ const shouldByEntries = import_lodash.default.some(tagsByEntries, "length");
90
+ if (!tags.length && !shouldByEntries) {
91
+ return;
92
+ }
93
+ const { HtmlTagsPlugin } = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared")));
94
+ const sharedOptions = {
95
+ HtmlPlugin,
96
+ append: true,
97
+ hash: false,
98
+ publicPath: true,
99
+ tags
100
+ };
101
+ if (tags.length && !shouldByEntries) {
102
+ chain.plugin(CHAIN_ID.PLUGIN.HTML_TAGS).use(HtmlTagsPlugin, [sharedOptions]);
103
+ return;
104
+ }
105
+ for (const [entry, filename] of Object.entries(api.getHTMLPaths())) {
106
+ const opts = { ...sharedOptions, includes: [filename] };
107
+ entry in tagsByEntries && (opts.tags = tagsByEntries[entry]);
108
+ chain.plugin(`${CHAIN_ID.PLUGIN.HTML_TAGS}#${entry}`).use(HtmlTagsPlugin, [opts]);
109
+ }
110
+ });
111
+ };
112
+ const pluginHtml = () => ({
113
+ name: "plugin-html",
114
+ setup(api) {
115
+ const routesInfo = [];
116
+ api.modifyBundlerChain(
117
+ async (chain, { HtmlPlugin, isProd, CHAIN_ID, target }) => {
118
+ const config = api.getNormalizedConfig();
119
+ if ((0, import_shared.isHtmlDisabled)(config, target)) {
120
+ return;
121
+ }
122
+ const minify = await (0, import_shared.getMinify)(isProd, config);
123
+ const assetPrefix = (0, import_shared.removeTailSlash)(
124
+ chain.output.get("publicPath") || ""
125
+ );
126
+ const entries = chain.entryPoints.entries() || {};
127
+ const entryNames = Object.keys(entries);
128
+ const htmlPaths = api.getHTMLPaths();
129
+ const faviconUrls = [];
130
+ const metaPluginOptions = {
131
+ meta: [],
132
+ HtmlPlugin
133
+ };
134
+ await Promise.all(
135
+ entryNames.map(async (entryName, index) => {
136
+ const entryValue = entries[entryName].values();
137
+ const chunks = await getChunks(entryName, entryValue);
138
+ const inject = (0, import_shared.getInject)(entryName, config);
139
+ const favicon = (0, import_shared.getFavicon)(entryName, config);
140
+ const filename = htmlPaths[entryName];
141
+ const template = (0, import_shared.getTemplatePath)(entryName, config);
142
+ const metaTags = await getMetaTags(entryName, config);
143
+ const templateParameters = await getTemplateParameters(
144
+ entryName,
145
+ config,
146
+ assetPrefix
147
+ );
148
+ if (metaTags.length) {
149
+ metaPluginOptions.meta.push({
150
+ tags: metaTags,
151
+ filename
152
+ });
153
+ }
154
+ const pluginOptions = {
155
+ chunks,
156
+ inject,
157
+ minify,
158
+ filename,
159
+ template,
160
+ templateParameters,
161
+ scriptLoading: config.html.scriptLoading
162
+ };
163
+ if (favicon) {
164
+ if ((0, import_shared.isURL)(favicon)) {
165
+ faviconUrls.push({
166
+ filename,
167
+ url: favicon
168
+ });
169
+ } else {
170
+ pluginOptions.favicon = favicon;
171
+ }
172
+ }
173
+ const finalOptions = (0, import_shared.mergeChainedOptions)(
174
+ pluginOptions,
175
+ config.tools.htmlPlugin,
176
+ {
177
+ entryName,
178
+ entryValue
179
+ }
180
+ );
181
+ routesInfo.push({
182
+ urlPath: index === 0 ? "/" : `/${entryName}`,
183
+ entryName,
184
+ entryPath: filename,
185
+ isSPA: true
186
+ });
187
+ chain.plugin(`${CHAIN_ID.PLUGIN.HTML}-${entryName}`).use(HtmlPlugin, [finalOptions]);
188
+ })
189
+ );
190
+ if (metaPluginOptions.meta.length) {
191
+ chain.plugin(CHAIN_ID.PLUGIN.HTML_META).use(import_shared.HtmlMetaPlugin, [metaPluginOptions]);
192
+ }
193
+ if (config.security) {
194
+ const { nonce } = config.security;
195
+ if (nonce) {
196
+ const { HtmlNoncePlugin } = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared")));
197
+ chain.plugin(CHAIN_ID.PLUGIN.HTML_NONCE).use(HtmlNoncePlugin, [{ nonce, HtmlPlugin }]);
198
+ }
199
+ }
200
+ if (config.html) {
201
+ const { appIcon, crossorigin } = config.html;
202
+ if (crossorigin) {
203
+ const { HtmlCrossOriginPlugin } = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared")));
204
+ const formattedCrossorigin = crossorigin === true ? "anonymous" : crossorigin;
205
+ chain.plugin(CHAIN_ID.PLUGIN.HTML_CROSS_ORIGIN).use(HtmlCrossOriginPlugin, [
206
+ { crossOrigin: formattedCrossorigin, HtmlPlugin }
207
+ ]);
208
+ chain.output.crossOriginLoading(formattedCrossorigin);
209
+ }
210
+ if (faviconUrls.length) {
211
+ const { HtmlFaviconUrlPlugin } = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared")));
212
+ chain.plugin(CHAIN_ID.PLUGIN.FAVICON_URL).use(HtmlFaviconUrlPlugin, [{ faviconUrls, HtmlPlugin }]);
213
+ }
214
+ if (appIcon) {
215
+ const { HtmlAppIconPlugin } = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared")));
216
+ const distDir = (0, import_shared.getDistPath)(config.output, "image");
217
+ const iconPath = import_path.default.isAbsolute(appIcon) ? appIcon : import_path.default.join(api.context.rootPath, appIcon);
218
+ chain.plugin(CHAIN_ID.PLUGIN.APP_ICON).use(HtmlAppIconPlugin, [{ iconPath, distDir, HtmlPlugin }]);
219
+ }
220
+ }
221
+ }
222
+ );
223
+ const emitRouteJson = async () => {
224
+ const routeFilePath = import_path.default.join(api.context.distPath, import_shared.ROUTE_SPEC_FILE);
225
+ if (!await (0, import_shared.isFileExists)(routeFilePath) && routesInfo.length) {
226
+ await import_fs_extra.fs.outputFile(
227
+ routeFilePath,
228
+ JSON.stringify({ routes: routesInfo }, null, 2)
229
+ );
230
+ }
231
+ };
232
+ api.onBeforeBuild(emitRouteJson);
233
+ api.onBeforeStartDevServer(emitRouteJson);
234
+ applyInjectTags(api);
235
+ }
236
+ });
237
+ // Annotate the CommonJS export names for ESM import in node:
238
+ 0 && (module.exports = {
239
+ applyInjectTags,
240
+ getMetaTags,
241
+ pluginHtml
242
+ });
@@ -0,0 +1,2 @@
1
+ import { Plugins } from '@rsbuild/shared';
2
+ export declare const plugins: Plugins;
@@ -0,0 +1,67 @@
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 plugins_exports = {};
30
+ __export(plugins_exports, {
31
+ plugins: () => plugins
32
+ });
33
+ module.exports = __toCommonJS(plugins_exports);
34
+ var import_shared = require("@rsbuild/shared");
35
+ const plugins = {
36
+ html: () => Promise.resolve().then(() => __toESM(require("./html"))).then((m) => m.pluginHtml()),
37
+ cleanOutput: () => Promise.resolve().then(() => __toESM(require("./cleanOutput"))).then((m) => m.pluginCleanOutput()),
38
+ startUrl: () => Promise.resolve().then(() => __toESM(require("./startUrl"))).then((m) => m.pluginStartUrl()),
39
+ fileSize: () => Promise.resolve().then(() => __toESM(require("./fileSize"))).then((m) => m.pluginFileSize()),
40
+ devtool: () => Promise.resolve().then(() => __toESM(require("./devtool"))).then((m) => m.pluginDevtool()),
41
+ target: () => Promise.resolve().then(() => __toESM(require("./target"))).then((m) => m.pluginTarget()),
42
+ entry: () => Promise.resolve().then(() => __toESM(require("./entry"))).then((m) => m.pluginEntry()),
43
+ cache: () => Promise.resolve().then(() => __toESM(require("./cache"))).then((m) => m.pluginCache()),
44
+ yaml: () => Promise.resolve().then(() => __toESM(require("./yaml"))).then((m) => m.pluginYaml()),
45
+ toml: () => Promise.resolve().then(() => __toESM(require("./toml"))).then((m) => m.pluginToml()),
46
+ splitChunks: () => Promise.resolve().then(() => __toESM(require("./splitChunks"))).then((m) => m.pluginSplitChunks()),
47
+ inlineChunk: () => Promise.resolve().then(() => __toESM(require("./inlineChunk"))).then((m) => m.pluginInlineChunk()),
48
+ bundleAnalyzer: () => Promise.resolve().then(() => __toESM(require("./bundleAnalyzer"))).then((m) => m.pluginBundleAnalyzer()),
49
+ svg: () => Promise.resolve().then(() => __toESM(require("./asset"))).then((m) => m.pluginAsset("svg", ["svg"])),
50
+ font: () => Promise.resolve().then(() => __toESM(require("./asset"))).then((m) => m.pluginAsset("font", import_shared.FONT_EXTENSIONS)),
51
+ image: () => Promise.resolve().then(() => __toESM(require("./asset"))).then((m) => m.pluginAsset("image", import_shared.IMAGE_EXTENSIONS)),
52
+ media: () => Promise.resolve().then(() => __toESM(require("./asset"))).then((m) => m.pluginAsset("media", import_shared.MEDIA_EXTENSIONS)),
53
+ assetsRetry: () => Promise.resolve().then(() => __toESM(require("./assetsRetry"))).then((m) => m.pluginAssetsRetry()),
54
+ rem: () => Promise.resolve().then(() => __toESM(require("./rem"))).then((m) => m.pluginRem()),
55
+ wasm: () => Promise.resolve().then(() => __toESM(require("./wasm"))).then((m) => m.pluginWasm()),
56
+ moment: () => Promise.resolve().then(() => __toESM(require("./moment"))).then((m) => m.pluginMoment()),
57
+ nodeAddons: () => Promise.resolve().then(() => __toESM(require("./nodeAddons"))).then((m) => m.pluginNodeAddons()),
58
+ externals: () => Promise.resolve().then(() => __toESM(require("./externals"))).then((m) => m.pluginExternals()),
59
+ networkPerformance: () => Promise.resolve().then(() => __toESM(require("./networkPerformance"))).then((m) => m.pluginNetworkPerformance()),
60
+ preloadOrPrefetch: () => Promise.resolve().then(() => __toESM(require("./preloadOrPrefetch"))).then((m) => m.pluginPreloadOrPrefetch()),
61
+ performance: () => Promise.resolve().then(() => __toESM(require("./performance"))).then((m) => m.pluginPerformance()),
62
+ define: () => Promise.resolve().then(() => __toESM(require("./define"))).then((m) => m.pluginDefine())
63
+ };
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ plugins
67
+ });
@@ -0,0 +1,2 @@
1
+ import { DefaultRsbuildPlugin } from '@rsbuild/shared';
2
+ export declare const pluginInlineChunk: () => DefaultRsbuildPlugin;
@@ -0,0 +1,85 @@
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 inlineChunk_exports = {};
30
+ __export(inlineChunk_exports, {
31
+ pluginInlineChunk: () => pluginInlineChunk
32
+ });
33
+ module.exports = __toCommonJS(inlineChunk_exports);
34
+ var import_shared = require("@rsbuild/shared");
35
+ const pluginInlineChunk = () => ({
36
+ name: "plugin-inline-chunk",
37
+ setup(api) {
38
+ api.modifyBundlerChain(
39
+ async (chain, { target, CHAIN_ID, isProd, HtmlPlugin }) => {
40
+ const config = api.getNormalizedConfig();
41
+ if ((0, import_shared.isHtmlDisabled)(config, target) || !isProd) {
42
+ return;
43
+ }
44
+ const { InlineChunkHtmlPlugin } = await Promise.resolve().then(() => __toESM(require("@rsbuild/shared")));
45
+ const {
46
+ disableInlineRuntimeChunk,
47
+ enableInlineStyles,
48
+ // todo: not support enableInlineScripts in Rspack yet, which will take unknown build error
49
+ enableInlineScripts
50
+ } = config.output;
51
+ const scriptTests = [];
52
+ const styleTests = [];
53
+ if (enableInlineScripts) {
54
+ scriptTests.push(
55
+ enableInlineScripts === true ? import_shared.JS_REGEX : enableInlineScripts
56
+ );
57
+ }
58
+ if (enableInlineStyles) {
59
+ styleTests.push(
60
+ enableInlineStyles === true ? import_shared.CSS_REGEX : enableInlineStyles
61
+ );
62
+ }
63
+ if (!disableInlineRuntimeChunk) {
64
+ scriptTests.push(
65
+ // RegExp like /bundler-runtime([.].+)?\.js$/
66
+ // matches bundler-runtime.js and bundler-runtime.123456.js
67
+ new RegExp(`${import_shared.RUNTIME_CHUNK_NAME}([.].+)?\\.js$`)
68
+ );
69
+ }
70
+ chain.plugin(CHAIN_ID.PLUGIN.INLINE_HTML).use(InlineChunkHtmlPlugin, [
71
+ HtmlPlugin,
72
+ {
73
+ styleTests,
74
+ scriptTests,
75
+ distPath: (0, import_shared.pick)(config.output.distPath, ["js", "css"])
76
+ }
77
+ ]);
78
+ }
79
+ );
80
+ }
81
+ });
82
+ // Annotate the CommonJS export names for ESM import in node:
83
+ 0 && (module.exports = {
84
+ pluginInlineChunk
85
+ });
@@ -0,0 +1,2 @@
1
+ import { DefaultRsbuildPlugin } from '@rsbuild/shared';
2
+ export declare const pluginMoment: () => DefaultRsbuildPlugin;
@@ -0,0 +1,43 @@
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 moment_exports = {};
20
+ __export(moment_exports, {
21
+ pluginMoment: () => pluginMoment
22
+ });
23
+ module.exports = __toCommonJS(moment_exports);
24
+ const pluginMoment = () => ({
25
+ name: "plugin-moment",
26
+ setup(api) {
27
+ api.modifyBundlerChain(async (chain, { webpack }) => {
28
+ const config = api.getNormalizedConfig();
29
+ if (config.performance.removeMomentLocale) {
30
+ chain.plugin("remove-moment-locale").use(webpack.IgnorePlugin, [
31
+ {
32
+ resourceRegExp: /^\.\/locale$/,
33
+ contextRegExp: /moment$/
34
+ }
35
+ ]);
36
+ }
37
+ });
38
+ }
39
+ });
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ pluginMoment
43
+ });
@@ -0,0 +1,2 @@
1
+ import { type DefaultRsbuildPlugin } from '@rsbuild/shared';
2
+ export declare const pluginNetworkPerformance: () => DefaultRsbuildPlugin;
@@ -0,0 +1,58 @@
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 networkPerformance_exports = {};
20
+ __export(networkPerformance_exports, {
21
+ pluginNetworkPerformance: () => pluginNetworkPerformance
22
+ });
23
+ module.exports = __toCommonJS(networkPerformance_exports);
24
+ var import_shared = require("@rsbuild/shared");
25
+ const pluginNetworkPerformance = () => ({
26
+ name: `plugin-network-performance`,
27
+ setup(api) {
28
+ api.modifyBundlerChain(
29
+ async (chain, { CHAIN_ID, isServer, isWebWorker, isServiceWorker, HtmlPlugin }) => {
30
+ const config = api.getNormalizedConfig();
31
+ const {
32
+ performance: { dnsPrefetch, preconnect }
33
+ } = config;
34
+ if (isServer || isWebWorker || isServiceWorker) {
35
+ return;
36
+ }
37
+ if (dnsPrefetch) {
38
+ chain.plugin(CHAIN_ID.PLUGIN.HTML_DNS_PREFETCH).use(import_shared.HtmlNetworkPerformancePlugin, [
39
+ dnsPrefetch,
40
+ "dnsPrefetch",
41
+ HtmlPlugin
42
+ ]);
43
+ }
44
+ if (preconnect) {
45
+ chain.plugin(CHAIN_ID.PLUGIN.HTML_PRECONNECT).use(import_shared.HtmlNetworkPerformancePlugin, [
46
+ preconnect,
47
+ "preconnect",
48
+ HtmlPlugin
49
+ ]);
50
+ }
51
+ }
52
+ );
53
+ }
54
+ });
55
+ // Annotate the CommonJS export names for ESM import in node:
56
+ 0 && (module.exports = {
57
+ pluginNetworkPerformance
58
+ });
@@ -0,0 +1,2 @@
1
+ import { type DefaultRsbuildPlugin } from '@rsbuild/shared';
2
+ export declare const pluginNodeAddons: () => DefaultRsbuildPlugin;
@@ -0,0 +1,78 @@
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 nodeAddons_exports = {};
30
+ __export(nodeAddons_exports, {
31
+ pluginNodeAddons: () => pluginNodeAddons
32
+ });
33
+ module.exports = __toCommonJS(nodeAddons_exports);
34
+ var import_shared = require("@rsbuild/shared");
35
+ var import_chalk = require("@rsbuild/shared/chalk");
36
+ const pluginNodeAddons = () => ({
37
+ name: "plugin-node-addons",
38
+ setup(api) {
39
+ api.modifyBundlerChain(
40
+ async (chain, { isServer, isServiceWorker, CHAIN_ID }) => {
41
+ if (!isServer && !isServiceWorker) {
42
+ return;
43
+ }
44
+ const pkgUp = await Promise.resolve().then(() => __toESM(require("pkg-up")));
45
+ const getDistName = (resource) => {
46
+ const pkgJSON = pkgUp.sync({ cwd: resource });
47
+ if (!pkgJSON) {
48
+ throw new Error(
49
+ `Failed to compile Node.js addons, couldn't find the package.json of ${import_chalk.chalk.yellow(
50
+ resource
51
+ )}.`
52
+ );
53
+ }
54
+ const getFilename = (resource2, pkgName2) => {
55
+ const reg = new RegExp(`node_modules/${pkgName2}/(.+)`);
56
+ const match = resource2.match(reg);
57
+ const filename = match == null ? void 0 : match[1];
58
+ if (!filename) {
59
+ return "[name].[ext]";
60
+ }
61
+ return `${filename}`;
62
+ };
63
+ const { name: pkgName } = require(pkgJSON);
64
+ const config = api.getNormalizedConfig();
65
+ const serverPath = (0, import_shared.getDistPath)(config.output, "server");
66
+ return `${serverPath}/${getFilename(resource, pkgName)}`;
67
+ };
68
+ chain.module.rule(CHAIN_ID.RULE.NODE).test(/\.node$/).use(CHAIN_ID.USE.NODE).loader((0, import_shared.getSharedPkgCompiledPath)("node-loader")).options({
69
+ name: getDistName
70
+ });
71
+ }
72
+ );
73
+ }
74
+ });
75
+ // Annotate the CommonJS export names for ESM import in node:
76
+ 0 && (module.exports = {
77
+ pluginNodeAddons
78
+ });
@@ -0,0 +1,5 @@
1
+ import type { DefaultRsbuildPlugin } from '@rsbuild/shared';
2
+ /**
3
+ * Apply some configs of Rsbuild performance
4
+ */
5
+ export declare const pluginPerformance: () => DefaultRsbuildPlugin;
@@ -0,0 +1,63 @@
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 performance_exports = {};
20
+ __export(performance_exports, {
21
+ pluginPerformance: () => pluginPerformance
22
+ });
23
+ module.exports = __toCommonJS(performance_exports);
24
+ function applyProfile({
25
+ chain,
26
+ config
27
+ }) {
28
+ const { profile } = config.performance;
29
+ if (!profile) {
30
+ return;
31
+ }
32
+ chain.profile(profile);
33
+ }
34
+ const pluginPerformance = () => ({
35
+ name: "plugin-performance",
36
+ setup(api) {
37
+ api.modifyRsbuildConfig((rsbuildConfig) => {
38
+ var _a, _b, _c;
39
+ if ((_a = rsbuildConfig.performance) == null ? void 0 : _a.profile) {
40
+ if (!((_b = rsbuildConfig.performance) == null ? void 0 : _b.bundleAnalyze)) {
41
+ (_c = rsbuildConfig.performance) != null ? _c : rsbuildConfig.performance = {};
42
+ rsbuildConfig.performance.bundleAnalyze = {
43
+ analyzerMode: "disabled",
44
+ generateStatsFile: true
45
+ };
46
+ } else {
47
+ rsbuildConfig.performance.bundleAnalyze = {
48
+ generateStatsFile: true,
49
+ ...rsbuildConfig.performance.bundleAnalyze || {}
50
+ };
51
+ }
52
+ }
53
+ });
54
+ api.modifyBundlerChain((chain) => {
55
+ const config = api.getNormalizedConfig();
56
+ applyProfile({ chain, config });
57
+ });
58
+ }
59
+ });
60
+ // Annotate the CommonJS export names for ESM import in node:
61
+ 0 && (module.exports = {
62
+ pluginPerformance
63
+ });
@@ -0,0 +1,2 @@
1
+ import { type DefaultRsbuildPlugin } from '@rsbuild/shared';
2
+ export declare const pluginPreloadOrPrefetch: () => DefaultRsbuildPlugin;