@rsbuild/core 0.0.12 → 0.0.13

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 (80) 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/html.d.ts +4 -4
  8. package/dist/plugins/html.js +18 -9
  9. package/dist/plugins/index.js +1 -1
  10. package/dist/plugins/startUrl.js +6 -8
  11. package/dist/rspack-provider/config/defaults.js +1 -4
  12. package/dist/rspack-provider/core/build.d.ts +4 -5
  13. package/dist/rspack-provider/core/createCompiler.d.ts +2 -1
  14. package/dist/rspack-provider/core/createContext.js +0 -4
  15. package/dist/rspack-provider/core/initConfigs.d.ts +1 -1
  16. package/dist/rspack-provider/core/initConfigs.js +1 -2
  17. package/dist/rspack-provider/core/initHooks.d.ts +2 -2
  18. package/dist/rspack-provider/core/inspectConfig.d.ts +3 -4
  19. package/dist/rspack-provider/core/rspackConfig.d.ts +2 -2
  20. package/dist/rspack-provider/core/rspackConfig.js +4 -5
  21. package/dist/rspack-provider/core/startDevServer.d.ts +3 -4
  22. package/dist/rspack-provider/core/startDevServer.js +1 -1
  23. package/dist/rspack-provider/index.d.ts +2 -1
  24. package/dist/rspack-provider/plugins/css.d.ts +2 -2
  25. package/dist/rspack-provider/plugins/css.js +2 -2
  26. package/dist/rspack-provider/plugins/minimize.d.ts +3 -2
  27. package/dist/rspack-provider/plugins/minimize.js +9 -4
  28. package/dist/rspack-provider/plugins/swc.d.ts +2 -2
  29. package/dist/rspack-provider/provider.d.ts +3 -3
  30. package/dist/rspack-provider/rspackPlugin/removeCssSourcemapPlugin.d.ts +1 -1
  31. package/dist/rspack-provider/shared/plugin.js +0 -2
  32. package/dist/rspack-provider/types/context.d.ts +1 -4
  33. package/dist/rspack-provider/types/hooks.d.ts +2 -10
  34. package/dist/rspack-provider/types/index.d.ts +1 -2
  35. package/dist/rspack-provider/types/index.js +1 -5
  36. package/dist/rspack-provider/types/plugin.d.ts +3 -4
  37. package/dist/utils/generateMetaTags.d.ts +2 -1
  38. package/dist/utils/generateMetaTags.js +4 -18
  39. package/package.json +7 -6
  40. package/static/openChrome.applescript +95 -0
  41. package/dist/plugins/checkSyntax.d.ts +0 -0
  42. package/dist/plugins/checkSyntax.js +0 -1
  43. package/dist/plugins/svg.d.ts +0 -2
  44. package/dist/plugins/svg.js +0 -60
  45. package/dist/rspack-provider/config/validate/dev.d.ts +0 -3
  46. package/dist/rspack-provider/config/validate/dev.js +0 -29
  47. package/dist/rspack-provider/config/validate/html.d.ts +0 -3
  48. package/dist/rspack-provider/config/validate/html.js +0 -29
  49. package/dist/rspack-provider/config/validate/index.d.ts +0 -4
  50. package/dist/rspack-provider/config/validate/index.js +0 -50
  51. package/dist/rspack-provider/config/validate/output.d.ts +0 -3
  52. package/dist/rspack-provider/config/validate/output.js +0 -29
  53. package/dist/rspack-provider/config/validate/performance.d.ts +0 -3
  54. package/dist/rspack-provider/config/validate/performance.js +0 -41
  55. package/dist/rspack-provider/config/validate/security.d.ts +0 -3
  56. package/dist/rspack-provider/config/validate/security.js +0 -29
  57. package/dist/rspack-provider/config/validate/source.d.ts +0 -3
  58. package/dist/rspack-provider/config/validate/source.js +0 -31
  59. package/dist/rspack-provider/config/validate/tools.d.ts +0 -3
  60. package/dist/rspack-provider/config/validate/tools.js +0 -35
  61. package/dist/rspack-provider/plugins/pug.d.ts +0 -2
  62. package/dist/rspack-provider/plugins/pug.js +0 -67
  63. package/dist/rspack-provider/types/config/dev.d.ts +0 -3
  64. package/dist/rspack-provider/types/config/dev.js +0 -16
  65. package/dist/rspack-provider/types/config/html.d.ts +0 -3
  66. package/dist/rspack-provider/types/config/html.js +0 -16
  67. package/dist/rspack-provider/types/config/index.d.ts +0 -34
  68. package/dist/rspack-provider/types/config/index.js +0 -34
  69. package/dist/rspack-provider/types/config/output.d.ts +0 -9
  70. package/dist/rspack-provider/types/config/output.js +0 -16
  71. package/dist/rspack-provider/types/config/performance.d.ts +0 -3
  72. package/dist/rspack-provider/types/config/performance.js +0 -16
  73. package/dist/rspack-provider/types/config/security.d.ts +0 -3
  74. package/dist/rspack-provider/types/config/security.js +0 -16
  75. package/dist/rspack-provider/types/config/source.d.ts +0 -11
  76. package/dist/rspack-provider/types/config/source.js +0 -16
  77. package/dist/rspack-provider/types/config/tools.d.ts +0 -21
  78. package/dist/rspack-provider/types/config/tools.js +0 -16
  79. package/dist/rspack-provider/types/rspack.d.ts +0 -107
  80. 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
  }
@@ -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)),
@@ -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,7 +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")));
94
+ const { default: HtmlPlugin } = await Promise.resolve().then(() => __toESM(require("html-webpack-plugin")));
96
95
  const { default: webpack } = await Promise.resolve().then(() => __toESM(require("webpack")));
97
96
  return {
98
97
  env: nodeEnv,
@@ -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 {};
@@ -34,8 +34,8 @@ __export(startDevServer_exports, {
34
34
  module.exports = __toCommonJS(startDevServer_exports);
35
35
  var import_shared = require("@rsbuild/shared");
36
36
  var import_createCompiler = require("./createCompiler");
37
- var import_initConfigs = require("./initConfigs");
38
37
  var import_devMiddleware = require("./devMiddleware");
38
+ var import_initConfigs = require("./initConfigs");
39
39
  async function createDevServer(options, port, serverOptions, customCompiler) {
40
40
  const { Server } = await Promise.resolve().then(() => __toESM(require("@modern-js/server")));
41
41
  let compiler;
@@ -1,4 +1,5 @@
1
1
  export { getRspackVersion } from './shared/rspackVersion';
2
2
  export { rspackProvider } from './provider';
3
3
  export type { RspackProvider } from './provider';
4
- export type { RsbuildConfig, NormalizedConfig, ModifyRspackConfigFn, RsbuildPluginAPI, Rspack, RspackConfig } from './types';
4
+ export type { RsbuildConfig, NormalizedConfig, ModifyRspackConfigFn, RsbuildPluginAPI } from './types';
5
+ export type { Rspack, RspackConfig } from '@rsbuild/shared';
@@ -1,5 +1,5 @@
1
- import { type BundlerChain, type Context, type ModifyBundlerChainUtils } from '@rsbuild/shared';
2
- import type { RsbuildPlugin, NormalizedConfig, RspackRule } from '../types';
1
+ import { type BundlerChain, type Context, type RspackRule, type ModifyBundlerChainUtils } from '@rsbuild/shared';
2
+ import type { RsbuildPlugin, NormalizedConfig } from '../types';
3
3
  export declare const enableNativeCss: (config: NormalizedConfig) => boolean;
4
4
  export declare function applyBaseCSSRule({
5
5
  rule,
@@ -34,8 +34,8 @@ __export(css_exports, {
34
34
  pluginCss: () => pluginCss
35
35
  });
36
36
  module.exports = __toCommonJS(css_exports);
37
- var import_shared = require("@rsbuild/shared");
38
37
  var import_path = __toESM(require("path"));
38
+ var import_shared = require("@rsbuild/shared");
39
39
  var import_shared2 = require("../shared");
40
40
  const enableNativeCss = (config) => !config.output.disableCssExtract;
41
41
  async function applyBaseCSSRule({
@@ -185,7 +185,7 @@ const pluginCss = () => {
185
185
  (0, import_shared.setConfig)(rspackConfig, "experiments.css", false);
186
186
  return;
187
187
  }
188
- let localIdentName = config.output.cssModules.localIdentName || config.output.cssModuleLocalIdentName || // Using shorter classname in production to reduce bundle size
188
+ let localIdentName = config.output.cssModules.localIdentName || // Using shorter classname in production to reduce bundle size
189
189
  (isProd ? "[local]-[hash:6]" : "[path][name]__[local]-[hash:6]");
190
190
  if (localIdentName.includes(":base64")) {
191
191
  import_shared.logger.warn(
@@ -1,4 +1,5 @@
1
- import { BundlerChain } from '@rsbuild/shared';
1
+ import { type BundlerChain } from '@rsbuild/shared';
2
2
  import type { RsbuildPlugin, NormalizedConfig } from '../types';
3
- export declare function applyJSMinimizer(chain: BundlerChain, config: NormalizedConfig): Promise<void>;
3
+ export declare function applyJSMinimizer(chain: BundlerChain, config: NormalizedConfig): void;
4
+ export declare function applyCSSMinimizer(chain: BundlerChain): void;
4
5
  export declare const pluginMinimize: () => RsbuildPlugin;
@@ -18,13 +18,14 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var minimize_exports = {};
20
20
  __export(minimize_exports, {
21
+ applyCSSMinimizer: () => applyCSSMinimizer,
21
22
  applyJSMinimizer: () => applyJSMinimizer,
22
23
  pluginMinimize: () => pluginMinimize
23
24
  });
24
25
  module.exports = __toCommonJS(minimize_exports);
25
26
  var import_shared = require("@rsbuild/shared");
26
27
  var import_core = require("@rspack/core");
27
- async function applyJSMinimizer(chain, config) {
28
+ function applyJSMinimizer(chain, config) {
28
29
  const options = {};
29
30
  const { removeConsole } = config.performance;
30
31
  if (removeConsole === true) {
@@ -51,22 +52,26 @@ async function applyJSMinimizer(chain, config) {
51
52
  options.asciiOnly = config.output.charset === "ascii";
52
53
  chain.optimization.minimizer(import_shared.CHAIN_ID.MINIMIZER.JS).use(import_core.SwcJsMinimizerRspackPlugin, [options]).end();
53
54
  }
55
+ function applyCSSMinimizer(chain) {
56
+ chain.optimization.minimizer(import_shared.CHAIN_ID.MINIMIZER.CSS).use(import_core.SwcCssMinimizerRspackPlugin, []).end();
57
+ }
54
58
  const pluginMinimize = () => ({
55
59
  name: "plugin-minimize",
56
60
  setup(api) {
57
- api.modifyBundlerChain(async (chain, { isProd }) => {
61
+ api.modifyBundlerChain((chain, { isProd }) => {
58
62
  const config = api.getNormalizedConfig();
59
63
  const isMinimize = isProd && !config.output.disableMinimize;
60
64
  chain.optimization.minimize(isMinimize);
61
65
  if (isMinimize) {
62
- await applyJSMinimizer(chain, config);
63
- await (0, import_shared.applyCSSMinimizer)(chain, config);
66
+ applyJSMinimizer(chain, config);
67
+ applyCSSMinimizer(chain);
64
68
  }
65
69
  });
66
70
  }
67
71
  });
68
72
  // Annotate the CommonJS export names for ESM import in node:
69
73
  0 && (module.exports = {
74
+ applyCSSMinimizer,
70
75
  applyJSMinimizer,
71
76
  pluginMinimize
72
77
  });
@@ -1,5 +1,5 @@
1
- import { type RsbuildTarget } from '@rsbuild/shared';
2
- import type { RsbuildPlugin, NormalizedConfig, BuiltinSwcLoaderOptions } from '../types';
1
+ import { type RsbuildTarget, type BuiltinSwcLoaderOptions } from '@rsbuild/shared';
2
+ import type { RsbuildPlugin, NormalizedConfig } from '../types';
3
3
  export declare function getDefaultSwcConfig(config: NormalizedConfig, rootPath: string, target: RsbuildTarget): Promise<BuiltinSwcLoaderOptions>;
4
4
  /**
5
5
  * Provide some swc configs of rspack
@@ -1,6 +1,6 @@
1
- import { type RsbuildProvider } from '@rsbuild/shared';
2
- import type { Compiler, RspackConfig, RsbuildConfig, NormalizedConfig, MultiCompiler } from './types';
3
- export type RspackProvider = RsbuildProvider<RsbuildConfig, RspackConfig, NormalizedConfig, Compiler | MultiCompiler>;
1
+ import { type RsbuildProvider, type RspackConfig, type RspackCompiler, type RspackMultiCompiler } from '@rsbuild/shared';
2
+ import type { RsbuildConfig, NormalizedConfig } from './types';
3
+ export type RspackProvider = RsbuildProvider<RsbuildConfig, RspackConfig, NormalizedConfig, RspackCompiler | RspackMultiCompiler>;
4
4
  export declare function rspackProvider({
5
5
  rsbuildConfig: originalRsbuildConfig
6
6
  }: {
@@ -1,5 +1,5 @@
1
1
  import type { Compiler } from '@rspack/core';
2
- import type HtmlPlugin from '@rspack/plugin-html';
2
+ import type HtmlPlugin from 'html-webpack-plugin';
3
3
  export declare class RemoveCssSourcemapPlugin {
4
4
  name: string;
5
5
  htmlPlugin: typeof HtmlPlugin;
@@ -52,8 +52,6 @@ const applyDefaultPlugins = (plugins) => (0, import_shared.awaitableGetter)([
52
52
  plugins.wasm(),
53
53
  plugins.moment(),
54
54
  plugins.nodeAddons(),
55
- // pug plugin should after html plugin
56
- Promise.resolve().then(() => __toESM(require("../plugins/pug"))).then((m) => m.pluginPug()),
57
55
  plugins.define(),
58
56
  Promise.resolve().then(() => __toESM(require("../plugins/css"))).then((m) => m.pluginCss()),
59
57
  Promise.resolve().then(() => __toESM(require("../plugins/less"))).then((m) => m.pluginLess()),
@@ -1,6 +1,5 @@
1
- import type { Context as BaseContext } from '@rsbuild/shared';
1
+ import type { Context as BaseContext, RsbuildConfig, NormalizedConfig } from '@rsbuild/shared';
2
2
  import type { Hooks } from '../core/initHooks';
3
- import type { RsbuildConfig, NormalizedConfig } from './config';
4
3
  import type { RsbuildPluginAPI } from './plugin';
5
4
  /** The inner context. */
6
5
  export type Context = BaseContext & {
@@ -8,8 +7,6 @@ export type Context = BaseContext & {
8
7
  hooks: Readonly<Hooks>;
9
8
  /** Current Rsbuild config. */
10
9
  config: Readonly<RsbuildConfig>;
11
- /** The async task to validate schema of config. */
12
- configValidatingTask: Promise<void>;
13
10
  /** The original Rsbuild config passed from the createRsbuild method. */
14
11
  originalConfig: Readonly<RsbuildConfig>;
15
12
  /** The normalized Rsbuild config. */
@@ -1,11 +1,3 @@
1
- import type { ModifyChainUtils } from '@rsbuild/shared';
2
- import type { RspackConfig, RspackRule, RspackPluginInstance } from './rspack';
3
- export type ModifyRspackConfigUtils = ModifyChainUtils & {
4
- addRules: (rules: RspackRule | RspackRule[]) => void;
5
- prependPlugins: (plugins: RspackPluginInstance | RspackPluginInstance[]) => void;
6
- appendPlugins: (plugins: RspackPluginInstance | RspackPluginInstance[]) => void;
7
- removePlugin: (pluginName: string) => void;
8
- mergeConfig: typeof import('@rsbuild/shared/webpack-merge').merge;
9
- rspack: typeof import('@rspack/core');
10
- };
1
+ import type { ModifyRspackConfigUtils } from '@rsbuild/shared';
2
+ import type { RspackConfig } from '@rsbuild/shared';
11
3
  export type ModifyRspackConfigFn = (config: RspackConfig, utils: ModifyRspackConfigUtils) => Promise<RspackConfig | void> | RspackConfig | void;