@rsbuild/core 0.0.12 → 0.0.14

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 (89) hide show
  1. package/dist/cli/config.d.ts +3 -9
  2. package/dist/cli/index.js +1 -2
  3. package/dist/plugins/asset.d.ts +2 -1
  4. package/dist/plugins/asset.js +10 -1
  5. package/dist/plugins/entry.d.ts +1 -1
  6. package/dist/plugins/entry.js +2 -12
  7. package/dist/plugins/fileSize.js +9 -11
  8. package/dist/plugins/html.d.ts +4 -4
  9. package/dist/plugins/html.js +18 -9
  10. package/dist/plugins/index.js +1 -1
  11. package/dist/plugins/moment.d.ts +1 -1
  12. package/dist/plugins/moment.js +27 -2
  13. package/dist/plugins/nodeAddons.js +1 -2
  14. package/dist/plugins/splitChunks.js +2 -10
  15. package/dist/plugins/startUrl.js +6 -8
  16. package/dist/rspack-provider/config/defaults.js +1 -4
  17. package/dist/rspack-provider/core/build.d.ts +4 -5
  18. package/dist/rspack-provider/core/createCompiler.d.ts +2 -1
  19. package/dist/rspack-provider/core/createContext.js +0 -4
  20. package/dist/rspack-provider/core/initConfigs.d.ts +1 -1
  21. package/dist/rspack-provider/core/initConfigs.js +1 -2
  22. package/dist/rspack-provider/core/initHooks.d.ts +2 -2
  23. package/dist/rspack-provider/core/inspectConfig.d.ts +3 -4
  24. package/dist/rspack-provider/core/rspackConfig.d.ts +2 -2
  25. package/dist/rspack-provider/core/rspackConfig.js +5 -8
  26. package/dist/rspack-provider/core/startDevServer.d.ts +3 -4
  27. package/dist/rspack-provider/core/startDevServer.js +1 -1
  28. package/dist/rspack-provider/index.d.ts +2 -1
  29. package/dist/rspack-provider/plugins/css.d.ts +2 -2
  30. package/dist/rspack-provider/plugins/css.js +2 -2
  31. package/dist/rspack-provider/plugins/fallback.js +0 -2
  32. package/dist/rspack-provider/plugins/minimize.d.ts +3 -2
  33. package/dist/rspack-provider/plugins/minimize.js +9 -4
  34. package/dist/rspack-provider/plugins/swc.d.ts +2 -2
  35. package/dist/rspack-provider/provider.d.ts +3 -3
  36. package/dist/rspack-provider/provider.js +1 -2
  37. package/dist/rspack-provider/rspackPlugin/removeCssSourcemapPlugin.d.ts +1 -1
  38. package/dist/rspack-provider/shared/plugin.js +0 -3
  39. package/dist/rspack-provider/types/context.d.ts +1 -4
  40. package/dist/rspack-provider/types/hooks.d.ts +2 -10
  41. package/dist/rspack-provider/types/index.d.ts +1 -2
  42. package/dist/rspack-provider/types/index.js +1 -5
  43. package/dist/rspack-provider/types/plugin.d.ts +3 -4
  44. package/dist/utils/generateMetaTags.d.ts +2 -1
  45. package/dist/utils/generateMetaTags.js +4 -18
  46. package/package.json +8 -8
  47. package/static/openChrome.applescript +95 -0
  48. package/dist/plugins/checkSyntax.d.ts +0 -0
  49. package/dist/plugins/checkSyntax.js +0 -1
  50. package/dist/plugins/svg.d.ts +0 -2
  51. package/dist/plugins/svg.js +0 -60
  52. package/dist/rspack-provider/config/validate/dev.d.ts +0 -3
  53. package/dist/rspack-provider/config/validate/dev.js +0 -29
  54. package/dist/rspack-provider/config/validate/html.d.ts +0 -3
  55. package/dist/rspack-provider/config/validate/html.js +0 -29
  56. package/dist/rspack-provider/config/validate/index.d.ts +0 -4
  57. package/dist/rspack-provider/config/validate/index.js +0 -50
  58. package/dist/rspack-provider/config/validate/output.d.ts +0 -3
  59. package/dist/rspack-provider/config/validate/output.js +0 -29
  60. package/dist/rspack-provider/config/validate/performance.d.ts +0 -3
  61. package/dist/rspack-provider/config/validate/performance.js +0 -41
  62. package/dist/rspack-provider/config/validate/security.d.ts +0 -3
  63. package/dist/rspack-provider/config/validate/security.js +0 -29
  64. package/dist/rspack-provider/config/validate/source.d.ts +0 -3
  65. package/dist/rspack-provider/config/validate/source.js +0 -31
  66. package/dist/rspack-provider/config/validate/tools.d.ts +0 -3
  67. package/dist/rspack-provider/config/validate/tools.js +0 -35
  68. package/dist/rspack-provider/plugins/manifest.d.ts +0 -2
  69. package/dist/rspack-provider/plugins/manifest.js +0 -58
  70. package/dist/rspack-provider/plugins/pug.d.ts +0 -2
  71. package/dist/rspack-provider/plugins/pug.js +0 -67
  72. package/dist/rspack-provider/types/config/dev.d.ts +0 -3
  73. package/dist/rspack-provider/types/config/dev.js +0 -16
  74. package/dist/rspack-provider/types/config/html.d.ts +0 -3
  75. package/dist/rspack-provider/types/config/html.js +0 -16
  76. package/dist/rspack-provider/types/config/index.d.ts +0 -34
  77. package/dist/rspack-provider/types/config/index.js +0 -34
  78. package/dist/rspack-provider/types/config/output.d.ts +0 -9
  79. package/dist/rspack-provider/types/config/output.js +0 -16
  80. package/dist/rspack-provider/types/config/performance.d.ts +0 -3
  81. package/dist/rspack-provider/types/config/performance.js +0 -16
  82. package/dist/rspack-provider/types/config/security.d.ts +0 -3
  83. package/dist/rspack-provider/types/config/security.js +0 -16
  84. package/dist/rspack-provider/types/config/source.d.ts +0 -11
  85. package/dist/rspack-provider/types/config/source.js +0 -16
  86. package/dist/rspack-provider/types/config/tools.d.ts +0 -21
  87. package/dist/rspack-provider/types/config/tools.js +0 -16
  88. package/dist/rspack-provider/types/rspack.d.ts +0 -107
  89. package/dist/rspack-provider/types/rspack.js +0 -16
@@ -1,17 +1,11 @@
1
- import type { RsbuildEntry, RsbuildPlugin, RsbuildProvider, SharedRsbuildConfig } from '@rsbuild/shared';
2
- import type { RsbuildConfig as RspackRsbuildConfig } from '../rspack-provider';
3
- export type RsbuildConfig<Config> = Config & {
1
+ import type { RsbuildEntry, RsbuildPlugin, RsbuildConfig as BaseRsbuildConfig } from '@rsbuild/shared';
2
+ export type RsbuildConfig = BaseRsbuildConfig & {
4
3
  source?: {
5
4
  entries?: RsbuildEntry;
6
5
  };
7
6
  plugins?: RsbuildPlugin[];
8
- provider?: ({
9
- rsbuildConfig
10
- }: {
11
- rsbuildConfig: Config;
12
- }) => RsbuildProvider;
13
7
  };
14
- export declare const defineConfig: <T extends SharedRsbuildConfig = RspackRsbuildConfig>(config: RsbuildConfig<T>) => RsbuildConfig<T>;
8
+ export declare const defineConfig: (config: RsbuildConfig) => RsbuildConfig;
15
9
  export declare function loadConfig(): Promise<ReturnType<typeof defineConfig>>;
16
10
  export declare function getDefaultEntries(): {
17
11
  index: string;
package/dist/cli/index.js CHANGED
@@ -28,9 +28,8 @@ var import_config = require("./config");
28
28
  var import_config2 = require("./config");
29
29
  async function runCli(options = {}) {
30
30
  var _a;
31
- const { provider, ...config } = await (0, import_config.loadConfig)();
31
+ const config = await (0, import_config.loadConfig)();
32
32
  const rsbuild = await (0, import__.createRsbuild)({
33
- provider,
34
33
  rsbuildConfig: config,
35
34
  entry: ((_a = config.source) == null ? void 0 : _a.entries) || (0, import_config.getDefaultEntries)()
36
35
  });
@@ -1,2 +1,3 @@
1
1
  import type { DefaultRsbuildPlugin } from '@rsbuild/shared';
2
- export declare const pluginAsset: (assetType: 'image' | 'media' | 'font', exts: string[]) => DefaultRsbuildPlugin;
2
+ export declare function getRegExpForExts(exts: string[]): RegExp;
3
+ export declare const pluginAsset: (assetType: 'image' | 'media' | 'font' | 'svg', exts: string[]) => DefaultRsbuildPlugin;
@@ -28,17 +28,25 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var asset_exports = {};
30
30
  __export(asset_exports, {
31
+ getRegExpForExts: () => getRegExpForExts,
31
32
  pluginAsset: () => pluginAsset
32
33
  });
33
34
  module.exports = __toCommonJS(asset_exports);
34
35
  var import_path = __toESM(require("path"));
35
36
  var import_shared = require("@rsbuild/shared");
37
+ function getRegExpForExts(exts) {
38
+ const matcher = exts.map((ext) => ext.trim()).map((ext) => ext.startsWith(".") ? ext.slice(1) : ext).join("|");
39
+ return new RegExp(
40
+ exts.length === 1 ? `\\.${matcher}$` : `\\.(${matcher})$`,
41
+ "i"
42
+ );
43
+ }
36
44
  const pluginAsset = (assetType, exts) => ({
37
45
  name: `plugin-${assetType}`,
38
46
  setup(api) {
39
47
  api.modifyBundlerChain((chain, { isProd }) => {
40
48
  const config = api.getNormalizedConfig();
41
- const regExp = (0, import_shared.getRegExpForExts)(exts);
49
+ const regExp = getRegExpForExts(exts);
42
50
  const distDir = (0, import_shared.getDistPath)(config.output, assetType);
43
51
  const filename = (0, import_shared.getFilename)(config.output, assetType, isProd);
44
52
  const maxSize = config.output.dataUriLimit[assetType];
@@ -54,5 +62,6 @@ const pluginAsset = (assetType, exts) => ({
54
62
  });
55
63
  // Annotate the CommonJS export names for ESM import in node:
56
64
  0 && (module.exports = {
65
+ getRegExpForExts,
57
66
  pluginAsset
58
67
  });
@@ -1,2 +1,2 @@
1
- import { DefaultRsbuildPlugin } from '@rsbuild/shared';
1
+ import { type DefaultRsbuildPlugin } from '@rsbuild/shared';
2
2
  export declare const pluginEntry: () => DefaultRsbuildPlugin;
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,21 +15,13 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
  var entry_exports = {};
30
20
  __export(entry_exports, {
31
21
  pluginEntry: () => pluginEntry
32
22
  });
33
23
  module.exports = __toCommonJS(entry_exports);
34
- var import_lodash = __toESM(require("lodash"));
24
+ var import_shared = require("@rsbuild/shared");
35
25
  const pluginEntry = () => ({
36
26
  name: "plugin-entry",
37
27
  setup(api) {
@@ -41,7 +31,7 @@ const pluginEntry = () => ({
41
31
  Object.keys(entry).forEach((entryName) => {
42
32
  const appendEntry = (file) => chain.entry(entryName).add(file);
43
33
  preEntry.forEach(appendEntry);
44
- import_lodash.default.castArray(entry[entryName]).forEach(appendEntry);
34
+ (0, import_shared.castArray)(entry[entryName]).forEach(appendEntry);
45
35
  });
46
36
  });
47
37
  }
@@ -33,7 +33,6 @@ __export(fileSize_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(fileSize_exports);
35
35
  var import_path = __toESM(require("path"));
36
- var import_chalk = require("@rsbuild/shared/chalk");
37
36
  var import_fs_extra = require("@rsbuild/shared/fs-extra");
38
37
  var import_shared = require("@rsbuild/shared");
39
38
  var import_filesize = __toESM(require("filesize"));
@@ -41,12 +40,12 @@ var import_gzip_size = __toESM(require("gzip-size"));
41
40
  const filterAsset = (asset) => !/\.map$/.test(asset) && !/\.LICENSE\.txt$/.test(asset);
42
41
  const getAssetColor = (size) => {
43
42
  if (size > 300 * 1e3) {
44
- return import_chalk.chalk.bold.red;
43
+ return import_shared.color.red;
45
44
  }
46
45
  if (size > 100 * 1e3) {
47
- return import_chalk.chalk.yellow;
46
+ return import_shared.color.yellow;
48
47
  }
49
- return import_chalk.chalk.green;
48
+ return import_shared.color.green;
50
49
  };
51
50
  async function printHeader(longestFileLength, longestLabelLength) {
52
51
  const longestLengths = [longestFileLength, longestLabelLength];
@@ -58,7 +57,7 @@ async function printHeader(longestFileLength, longestLabelLength) {
58
57
  }
59
58
  return `${prev + curLabel} `;
60
59
  }, " ");
61
- import_shared.logger.log(import_chalk.chalk.bold.blue(headerRow));
60
+ import_shared.logger.log(import_shared.color.bold(import_shared.color.blue(headerRow)));
62
61
  }
63
62
  async function printFileSizes(stats, distPath) {
64
63
  const formatAsset = (asset) => {
@@ -117,21 +116,20 @@ async function printFileSizes(stats, distPath) {
117
116
  const rightPadding = " ".repeat(longestLabelLength - sizeLength);
118
117
  sizeLabel += rightPadding;
119
118
  }
120
- let fileNameLabel = import_chalk.chalk.dim(asset.folder + import_path.default.sep) + import_chalk.chalk.cyan(asset.name);
119
+ let fileNameLabel = import_shared.color.dim(asset.folder + import_path.default.sep) + import_shared.color.cyan(asset.name);
121
120
  if (fileNameLength < longestFileLength) {
122
121
  const rightPadding = " ".repeat(longestFileLength - fileNameLength);
123
122
  fileNameLabel += rightPadding;
124
123
  }
125
124
  import_shared.logger.log(` ${fileNameLabel} ${sizeLabel} ${gzipSizeLabel}`);
126
125
  });
127
- const totalSizeLabel = `${import_chalk.chalk.bold.blue("Total size:")} ${(0, import_filesize.default)(
126
+ const totalSizeLabel = `${import_shared.color.bold(import_shared.color.blue("Total size:"))} ${(0, import_filesize.default)(
128
127
  totalSize,
129
128
  { round: 1 }
130
129
  )}`;
131
- const gzippedSizeLabel = `${import_chalk.chalk.bold.blue("Gzipped size:")} ${(0, import_filesize.default)(
132
- totalGzipSize,
133
- { round: 1 }
134
- )}`;
130
+ const gzippedSizeLabel = `${import_shared.color.bold(
131
+ import_shared.color.blue("Gzipped size:")
132
+ )} ${(0, import_filesize.default)(totalGzipSize, { round: 1 })}`;
135
133
  import_shared.logger.log(`
136
134
  ${totalSizeLabel}
137
135
  ${gzippedSizeLabel}
@@ -1,7 +1,7 @@
1
- import type { SharedHtmlConfig, DefaultRsbuildPlugin, SharedRsbuildPluginAPI, NormalizedSharedOutputConfig } from '@rsbuild/shared';
1
+ import type { HtmlConfig, DefaultRsbuildPlugin, SharedRsbuildPluginAPI, NormalizedOutputConfig } from '@rsbuild/shared';
2
2
  export declare function getMetaTags(entryName: string, config: {
3
- html: SharedHtmlConfig;
4
- output: NormalizedSharedOutputConfig;
5
- }): Promise<string>;
3
+ html: HtmlConfig;
4
+ output: NormalizedOutputConfig;
5
+ }): Promise<import("html-webpack-plugin").HtmlTagObject[]>;
6
6
  export declare const applyInjectTags: (api: SharedRsbuildPluginAPI) => void;
7
7
  export declare const pluginHtml: () => DefaultRsbuildPlugin;
@@ -39,24 +39,19 @@ var import_fs_extra = require("@rsbuild/shared/fs-extra");
39
39
  var import_lodash = __toESM(require("lodash"));
40
40
  var import_generateMetaTags = require("../utils/generateMetaTags");
41
41
  async function getMetaTags(entryName, config) {
42
- var _a;
43
42
  const { meta, metaByEntries } = config.html;
44
- const metaOptions = {
45
- ...meta != null ? meta : {},
46
- ...(_a = metaByEntries == null ? void 0 : metaByEntries[entryName]) != null ? _a : {}
47
- };
43
+ const metaOptions = {};
48
44
  if (config.output.charset === "utf8") {
49
45
  metaOptions.charset = { charset: "utf-8" };
50
46
  }
47
+ Object.assign(metaOptions, meta, metaByEntries == null ? void 0 : metaByEntries[entryName]);
51
48
  return (0, import_generateMetaTags.generateMetaTags)(metaOptions);
52
49
  }
53
50
  async function getTemplateParameters(entryName, config, assetPrefix) {
54
51
  const { mountId, templateParameters, templateParametersByEntries } = config.html;
55
- const meta = await getMetaTags(entryName, config);
56
52
  const title = (0, import_shared.getTitle)(entryName, config);
57
53
  const templateParams = (templateParametersByEntries == null ? void 0 : templateParametersByEntries[entryName]) || templateParameters;
58
54
  const baseParameters = {
59
- meta,
60
55
  title,
61
56
  mountId,
62
57
  entryName,
@@ -86,10 +81,10 @@ async function getChunks(entryName, entryValue) {
86
81
  const applyInjectTags = (api) => {
87
82
  api.modifyBundlerChain(async (chain, { HtmlPlugin, CHAIN_ID }) => {
88
83
  const config = api.getNormalizedConfig();
89
- const tags = import_lodash.default.castArray(config.html.tags).filter(Boolean);
84
+ const tags = (0, import_shared.castArray)(config.html.tags).filter(Boolean);
90
85
  const tagsByEntries = import_lodash.default.mapValues(
91
86
  config.html.tagsByEntries,
92
- (tags2) => import_lodash.default.castArray(tags2).filter(Boolean)
87
+ (tags2) => (0, import_shared.castArray)(tags2).filter(Boolean)
93
88
  );
94
89
  const shouldByEntries = import_lodash.default.some(tagsByEntries, "length");
95
90
  if (!tags.length && !shouldByEntries) {
@@ -132,6 +127,10 @@ const pluginHtml = () => ({
132
127
  const entryNames = Object.keys(entries);
133
128
  const htmlPaths = api.getHTMLPaths();
134
129
  const faviconUrls = [];
130
+ const metaPluginOptions = {
131
+ meta: [],
132
+ HtmlPlugin
133
+ };
135
134
  await Promise.all(
136
135
  entryNames.map(async (entryName, index) => {
137
136
  const entryValue = entries[entryName].values();
@@ -140,11 +139,18 @@ const pluginHtml = () => ({
140
139
  const favicon = (0, import_shared.getFavicon)(entryName, config);
141
140
  const filename = htmlPaths[entryName];
142
141
  const template = (0, import_shared.getTemplatePath)(entryName, config);
142
+ const metaTags = await getMetaTags(entryName, config);
143
143
  const templateParameters = await getTemplateParameters(
144
144
  entryName,
145
145
  config,
146
146
  assetPrefix
147
147
  );
148
+ if (metaTags.length) {
149
+ metaPluginOptions.meta.push({
150
+ tags: metaTags,
151
+ filename
152
+ });
153
+ }
148
154
  const pluginOptions = {
149
155
  chunks,
150
156
  inject,
@@ -181,6 +187,9 @@ const pluginHtml = () => ({
181
187
  chain.plugin(`${CHAIN_ID.PLUGIN.HTML}-${entryName}`).use(HtmlPlugin, [finalOptions]);
182
188
  })
183
189
  );
190
+ if (metaPluginOptions.meta.length) {
191
+ chain.plugin(CHAIN_ID.PLUGIN.HTML_META).use(import_shared.HtmlMetaPlugin, [metaPluginOptions]);
192
+ }
184
193
  if (config.security) {
185
194
  const { nonce } = config.security;
186
195
  if (nonce) {
@@ -43,10 +43,10 @@ const plugins = {
43
43
  cache: () => Promise.resolve().then(() => __toESM(require("./cache"))).then((m) => m.pluginCache()),
44
44
  yaml: () => Promise.resolve().then(() => __toESM(require("./yaml"))).then((m) => m.pluginYaml()),
45
45
  toml: () => Promise.resolve().then(() => __toESM(require("./toml"))).then((m) => m.pluginToml()),
46
- svg: () => Promise.resolve().then(() => __toESM(require("./svg"))).then((m) => m.pluginSvg()),
47
46
  splitChunks: () => Promise.resolve().then(() => __toESM(require("./splitChunks"))).then((m) => m.pluginSplitChunks()),
48
47
  inlineChunk: () => Promise.resolve().then(() => __toESM(require("./inlineChunk"))).then((m) => m.pluginInlineChunk()),
49
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
50
  font: () => Promise.resolve().then(() => __toESM(require("./asset"))).then((m) => m.pluginAsset("font", import_shared.FONT_EXTENSIONS)),
51
51
  image: () => Promise.resolve().then(() => __toESM(require("./asset"))).then((m) => m.pluginAsset("image", import_shared.IMAGE_EXTENSIONS)),
52
52
  media: () => Promise.resolve().then(() => __toESM(require("./asset"))).then((m) => m.pluginAsset("media", import_shared.MEDIA_EXTENSIONS)),
@@ -1,2 +1,2 @@
1
- import { DefaultRsbuildPlugin } from '@rsbuild/shared';
1
+ import type { DefaultRsbuildPlugin } from '@rsbuild/shared';
2
2
  export declare const pluginMoment: () => DefaultRsbuildPlugin;
@@ -21,13 +21,38 @@ __export(moment_exports, {
21
21
  pluginMoment: () => pluginMoment
22
22
  });
23
23
  module.exports = __toCommonJS(moment_exports);
24
+ class IgnorePlugin {
25
+ constructor(options) {
26
+ this.options = options;
27
+ this.checkIgnore = this.checkIgnore.bind(this);
28
+ }
29
+ checkIgnore(resolveData) {
30
+ if ("resourceRegExp" in this.options && this.options.resourceRegExp && this.options.resourceRegExp.test(resolveData.request)) {
31
+ if ("contextRegExp" in this.options && this.options.contextRegExp) {
32
+ if (this.options.contextRegExp.test(resolveData.context)) {
33
+ return false;
34
+ }
35
+ } else {
36
+ return false;
37
+ }
38
+ }
39
+ }
40
+ apply(compiler) {
41
+ compiler.hooks.normalModuleFactory.tap("IgnorePlugin", (nmf) => {
42
+ nmf.hooks.beforeResolve.tap("IgnorePlugin", this.checkIgnore);
43
+ });
44
+ compiler.hooks.contextModuleFactory.tap("IgnorePlugin", (cmf) => {
45
+ cmf.hooks.beforeResolve.tap("IgnorePlugin", this.checkIgnore);
46
+ });
47
+ }
48
+ }
24
49
  const pluginMoment = () => ({
25
50
  name: "plugin-moment",
26
51
  setup(api) {
27
- api.modifyBundlerChain(async (chain, { webpack }) => {
52
+ api.modifyBundlerChain(async (chain) => {
28
53
  const config = api.getNormalizedConfig();
29
54
  if (config.performance.removeMomentLocale) {
30
- chain.plugin("remove-moment-locale").use(webpack.IgnorePlugin, [
55
+ chain.plugin("remove-moment-locale").use(IgnorePlugin, [
31
56
  {
32
57
  resourceRegExp: /^\.\/locale$/,
33
58
  contextRegExp: /moment$/
@@ -32,7 +32,6 @@ __export(nodeAddons_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(nodeAddons_exports);
34
34
  var import_shared = require("@rsbuild/shared");
35
- var import_chalk = require("@rsbuild/shared/chalk");
36
35
  const pluginNodeAddons = () => ({
37
36
  name: "plugin-node-addons",
38
37
  setup(api) {
@@ -46,7 +45,7 @@ const pluginNodeAddons = () => ({
46
45
  const pkgJSON = pkgUp.sync({ cwd: resource });
47
46
  if (!pkgJSON) {
48
47
  throw new Error(
49
- `Failed to compile Node.js addons, couldn't find the package.json of ${import_chalk.chalk.yellow(
48
+ `Failed to compile Node.js addons, couldn't find the package.json of ${import_shared.color.yellow(
50
49
  resource
51
50
  )}.`
52
51
  );
@@ -82,8 +82,6 @@ function splitByExperience(ctx) {
82
82
  reuseExistingChunk: true
83
83
  };
84
84
  });
85
- (0, import_assert.default)(defaultConfig !== false);
86
- (0, import_assert.default)(override !== false);
87
85
  return {
88
86
  ...defaultConfig,
89
87
  ...override,
@@ -97,8 +95,6 @@ function splitByExperience(ctx) {
97
95
  }
98
96
  function splitByModule(ctx) {
99
97
  const { override, userDefinedCacheGroups, defaultConfig } = ctx;
100
- (0, import_assert.default)(defaultConfig !== false);
101
- (0, import_assert.default)(override !== false);
102
98
  return {
103
99
  ...defaultConfig,
104
100
  minSize: 0,
@@ -112,6 +108,7 @@ function splitByModule(ctx) {
112
108
  priority: -10,
113
109
  test: import_shared.NODE_MODULES_REGEX,
114
110
  // todo: not support in rspack
111
+ // @ts-expect-error
115
112
  name(module2) {
116
113
  return (0, import_shared.getPackageNameFromModulePath)(module2.context);
117
114
  }
@@ -123,8 +120,6 @@ function splitByModule(ctx) {
123
120
  function splitBySize(ctx) {
124
121
  var _a, _b;
125
122
  const { override, userDefinedCacheGroups, defaultConfig, rsbuildConfig } = ctx;
126
- (0, import_assert.default)(defaultConfig !== false);
127
- (0, import_assert.default)(override !== false);
128
123
  (0, import_assert.default)(rsbuildConfig.strategy === "split-by-size");
129
124
  return {
130
125
  ...defaultConfig,
@@ -140,8 +135,6 @@ function splitBySize(ctx) {
140
135
  }
141
136
  function splitCustom(ctx) {
142
137
  const { override, userDefinedCacheGroups, defaultConfig } = ctx;
143
- (0, import_assert.default)(defaultConfig !== false);
144
- (0, import_assert.default)(override !== false);
145
138
  return {
146
139
  ...defaultConfig,
147
140
  ...override,
@@ -157,8 +150,6 @@ function allInOne(_ctx) {
157
150
  }
158
151
  function singleVendor(ctx) {
159
152
  const { override, defaultConfig, userDefinedCacheGroups } = ctx;
160
- (0, import_assert.default)(defaultConfig !== false);
161
- (0, import_assert.default)(override !== false);
162
153
  const singleVendorCacheGroup = {
163
154
  singleVendor: {
164
155
  test: import_shared.NODE_MODULES_REGEX,
@@ -211,6 +202,7 @@ function pluginSplitChunks() {
211
202
  // Optimize both `initial` and `async` chunks
212
203
  chunks: "all",
213
204
  // When chunk size >= 50000 bytes, split it into separate chunk
205
+ // @ts-expect-error Rspack type missing
214
206
  enforceSizeThreshold: 5e4,
215
207
  cacheGroups: {}
216
208
  };
@@ -33,7 +33,6 @@ __export(startUrl_exports, {
33
33
  replacePlaceholder: () => replacePlaceholder
34
34
  });
35
35
  module.exports = __toCommonJS(startUrl_exports);
36
- var import_lodash = __toESM(require("lodash"));
37
36
  var import_path = require("path");
38
37
  var import_shared = require("@rsbuild/shared");
39
38
  var import_child_process = require("child_process");
@@ -74,10 +73,8 @@ async function openBrowser(url) {
74
73
  }
75
74
  return false;
76
75
  } catch (err) {
77
- import_shared.logger.error(
78
- "Failed to open start URL with apple script:",
79
- JSON.stringify(err)
80
- );
76
+ import_shared.logger.error("Failed to open start URL with apple script.");
77
+ import_shared.logger.error(err);
81
78
  return false;
82
79
  }
83
80
  }
@@ -86,7 +83,8 @@ async function openBrowser(url) {
86
83
  await open(url);
87
84
  return true;
88
85
  } catch (err) {
89
- import_shared.logger.error("Failed to open start URL:", JSON.stringify(err));
86
+ import_shared.logger.error("Failed to open start URL.");
87
+ import_shared.logger.error(err);
90
88
  return false;
91
89
  }
92
90
  }
@@ -116,7 +114,7 @@ function pluginStartUrl() {
116
114
  urls.push(`${protocol}://localhost:${port}`);
117
115
  } else {
118
116
  urls.push(
119
- ...import_lodash.default.castArray(startUrl).map(
117
+ ...(0, import_shared.castArray)(startUrl).map(
120
118
  (item) => replacePlaceholder(item, port)
121
119
  )
122
120
  );
@@ -130,7 +128,7 @@ function pluginStartUrl() {
130
128
  }
131
129
  };
132
130
  if (beforeStartUrl) {
133
- Promise.all((0, import_shared.ensureArray)(beforeStartUrl).map((fn) => fn())).then(
131
+ Promise.all((0, import_shared.castArray)(beforeStartUrl).map((fn) => fn())).then(
134
132
  openUrls
135
133
  );
136
134
  } else {
@@ -26,10 +26,7 @@ var import_shared = require("@rsbuild/shared");
26
26
  const createDefaultConfig = () => ({
27
27
  dev: (0, import_shared.getDefaultDevConfig)(),
28
28
  html: (0, import_shared.getDefaultHtmlConfig)(),
29
- source: {
30
- ...(0, import_shared.getDefaultSourceConfig)(),
31
- define: {}
32
- },
29
+ source: (0, import_shared.getDefaultSourceConfig)(),
33
30
  output: (0, import_shared.getDefaultOutputConfig)(),
34
31
  tools: (0, import_shared.getDefaultToolsConfig)(),
35
32
  security: (0, import_shared.getDefaultSecurityConfig)(),
@@ -1,14 +1,13 @@
1
1
  import { InitConfigsOptions } from './initConfigs';
2
- import { BuildOptions, Stats, MultiStats } from '@rsbuild/shared';
3
- import type { Compiler, MultiCompiler } from '../types';
2
+ import type { Stats, MultiStats, BuildOptions, RspackCompiler, RspackMultiCompiler } from '@rsbuild/shared';
4
3
  export type BuildExecuter = {
5
- (compiler: Compiler): Promise<{
4
+ (compiler: RspackCompiler): Promise<{
6
5
  stats?: Stats;
7
6
  }>;
8
- (compiler: MultiCompiler): Promise<{
7
+ (compiler: RspackMultiCompiler): Promise<{
9
8
  stats?: MultiStats;
10
9
  }>;
11
- (compiler: Compiler | MultiCompiler): Promise<{
10
+ (compiler: RspackCompiler | RspackMultiCompiler): Promise<{
12
11
  stats?: Stats | MultiStats;
13
12
  }>;
14
13
  };
@@ -1,4 +1,5 @@
1
- import type { Context, RspackConfig } from '../types';
1
+ import { type RspackConfig } from '@rsbuild/shared';
2
+ import type { Context } from '../types';
2
3
  export declare function createCompiler({
3
4
  context,
4
5
  rspackConfigs
@@ -24,7 +24,6 @@ module.exports = __toCommonJS(createContext_exports);
24
24
  var import_path = require("path");
25
25
  var import_shared = require("@rsbuild/shared");
26
26
  var import_initHooks = require("./initHooks");
27
- var import_validate = require("../config/validate");
28
27
  var import_defaults = require("../config/defaults");
29
28
  async function createContext(options, userRsbuildConfig) {
30
29
  const rsbuildConfig = (0, import_defaults.withDefaultConfig)(userRsbuildConfig);
@@ -33,13 +32,10 @@ async function createContext(options, userRsbuildConfig) {
33
32
  rsbuildConfig.output,
34
33
  "rspack"
35
34
  );
36
- const configValidatingTask = Promise.resolve();
37
- await (0, import_validate.validateRsbuildConfig)(rsbuildConfig);
38
35
  const tsconfigPath = (0, import_path.join)(context.rootPath, import_shared.TS_CONFIG_FILE);
39
36
  return {
40
37
  ...context,
41
38
  hooks: (0, import_initHooks.initHooks)(),
42
- configValidatingTask,
43
39
  config: { ...rsbuildConfig },
44
40
  originalConfig: userRsbuildConfig,
45
41
  tsconfigPath: await (0, import_shared.isFileExists)(tsconfigPath) ? tsconfigPath : void 0
@@ -10,5 +10,5 @@ export declare function initConfigs({
10
10
  pluginStore,
11
11
  rsbuildOptions
12
12
  }: InitConfigsOptions): Promise<{
13
- rspackConfigs: import("../types").RspackConfig[];
13
+ rspackConfigs: import("@rsbuild/shared").RspackConfig[];
14
14
  }>;
@@ -39,14 +39,13 @@ async function initConfigs({
39
39
  pluginStore,
40
40
  rsbuildOptions
41
41
  }) {
42
- await context.configValidatingTask;
43
42
  await (0, import_shared.initPlugins)({
44
43
  pluginAPI: context.pluginAPI,
45
44
  pluginStore
46
45
  });
47
46
  await modifyRsbuildConfig(context);
48
47
  context.normalizedConfig = (0, import_normalize.normalizeConfig)(context.config);
49
- const targets = (0, import_shared.ensureArray)(rsbuildOptions.target);
48
+ const targets = (0, import_shared.castArray)(rsbuildOptions.target);
50
49
  const rspackConfigs = await Promise.all(
51
50
  targets.map((target) => (0, import_rspackConfig.generateRspackConfig)({ target, context }))
52
51
  );
@@ -1,5 +1,5 @@
1
- import { OnExitFn, OnAfterBuildFn, OnBeforeBuildFn, OnDevCompileDoneFn, ModifyRsbuildConfigFn, OnAfterStartDevServerFn, OnBeforeStartDevServerFn, OnAfterCreateCompilerFn, OnBeforeCreateCompilerFn, ModifyBundlerChainFn } from '@rsbuild/shared';
2
- import type { RspackConfig, RsbuildConfig, ModifyRspackConfigFn } from '../types';
1
+ import { OnExitFn, OnAfterBuildFn, OnBeforeBuildFn, OnDevCompileDoneFn, ModifyRsbuildConfigFn, OnAfterStartDevServerFn, OnBeforeStartDevServerFn, OnAfterCreateCompilerFn, OnBeforeCreateCompilerFn, ModifyBundlerChainFn, type RspackConfig } from '@rsbuild/shared';
2
+ import type { RsbuildConfig, ModifyRspackConfigFn } from '../types';
3
3
  export declare function initHooks(): {
4
4
  /** parameters are not bundler-related */
5
5
  onExitHook: import("@rsbuild/shared").AsyncHook<OnExitFn>;
@@ -1,6 +1,5 @@
1
- import { InitConfigsOptions } from './initConfigs';
2
- import { InspectConfigOptions } from '@rsbuild/shared';
3
- import type { RspackConfig } from '../types';
1
+ import { type InitConfigsOptions } from './initConfigs';
2
+ import { type RspackConfig, type InspectConfigOptions } from '@rsbuild/shared';
4
3
  export declare function inspectConfig({
5
4
  context,
6
5
  pluginStore,
@@ -14,7 +13,7 @@ export declare function inspectConfig({
14
13
  rsbuildConfig: string;
15
14
  bundlerConfigs: string[];
16
15
  origin: {
17
- rsbuildConfig: Readonly<import("../types").RsbuildConfig>;
16
+ rsbuildConfig: Readonly<import("@rsbuild/shared").RsbuildConfig>;
18
17
  bundlerConfigs: RspackConfig[];
19
18
  };
20
19
  }>;
@@ -1,5 +1,5 @@
1
- import { type RsbuildTarget } from '@rsbuild/shared';
2
- import type { Context, RspackConfig } from '../types';
1
+ import { type RspackConfig, type RsbuildTarget } from '@rsbuild/shared';
2
+ import type { Context } from '../types';
3
3
  export declare function generateRspackConfig({
4
4
  target,
5
5
  context
@@ -32,7 +32,6 @@ __export(rspackConfig_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(rspackConfig_exports);
34
34
  var import_shared = require("@rsbuild/shared");
35
- var import_lodash = require("lodash");
36
35
  var import_shared2 = require("../shared");
37
36
  async function modifyRspackConfig(context, rspackConfig, utils) {
38
37
  var _a;
@@ -60,7 +59,7 @@ async function getConfigUtils(config, chainUtils) {
60
59
  rspack,
61
60
  mergeConfig: merge,
62
61
  addRules(rules) {
63
- const ruleArr = (0, import_lodash.castArray)(rules);
62
+ const ruleArr = (0, import_shared.castArray)(rules);
64
63
  if (!config.module) {
65
64
  config.module = {};
66
65
  }
@@ -70,14 +69,14 @@ async function getConfigUtils(config, chainUtils) {
70
69
  config.module.rules.unshift(...ruleArr);
71
70
  },
72
71
  prependPlugins(plugins) {
73
- const pluginArr = (0, import_lodash.castArray)(plugins);
72
+ const pluginArr = (0, import_shared.castArray)(plugins);
74
73
  if (!config.plugins) {
75
74
  config.plugins = [];
76
75
  }
77
76
  config.plugins.unshift(...pluginArr);
78
77
  },
79
78
  appendPlugins(plugins) {
80
- const pluginArr = (0, import_lodash.castArray)(plugins);
79
+ const pluginArr = (0, import_shared.castArray)(plugins);
81
80
  if (!config.plugins) {
82
81
  config.plugins = [];
83
82
  }
@@ -92,8 +91,7 @@ async function getConfigUtils(config, chainUtils) {
92
91
  }
93
92
  async function getChainUtils(target) {
94
93
  const nodeEnv = process.env.NODE_ENV;
95
- const { default: HtmlPlugin } = await Promise.resolve().then(() => __toESM(require("@rspack/plugin-html")));
96
- const { default: webpack } = await Promise.resolve().then(() => __toESM(require("webpack")));
94
+ const { default: HtmlPlugin } = await Promise.resolve().then(() => __toESM(require("html-webpack-plugin")));
97
95
  return {
98
96
  env: nodeEnv,
99
97
  target,
@@ -103,8 +101,7 @@ async function getChainUtils(target) {
103
101
  isWebWorker: target === "web-worker",
104
102
  getCompiledPath: import_shared2.getCompiledPath,
105
103
  CHAIN_ID: import_shared.CHAIN_ID,
106
- HtmlPlugin,
107
- webpack
104
+ HtmlPlugin
108
105
  };
109
106
  }
110
107
  const convertToRspackConfig = (config) => {
@@ -1,7 +1,6 @@
1
- import { StartDevServerOptions } from '@rsbuild/shared';
2
- import { InitConfigsOptions } from './initConfigs';
3
- import type { Compiler, MultiCompiler } from '../types';
1
+ import { StartDevServerOptions, type RspackCompiler, type RspackMultiCompiler } from '@rsbuild/shared';
2
+ import { type InitConfigsOptions } from './initConfigs';
4
3
  type ServerOptions = Exclude<StartDevServerOptions['serverOptions'], undefined>;
5
- export declare function createDevServer(options: InitConfigsOptions, port: number, serverOptions: ServerOptions, customCompiler?: Compiler | MultiCompiler): Promise<import("@modern-js/server").Server>;
4
+ export declare function createDevServer(options: InitConfigsOptions, port: number, serverOptions: ServerOptions, customCompiler?: RspackCompiler | RspackMultiCompiler): Promise<import("@modern-js/server").Server>;
6
5
  export declare function startDevServer(options: InitConfigsOptions, startDevServerOptions?: StartDevServerOptions): Promise<import("@rsbuild/shared").StartServerResult>;
7
6
  export {};