@rsbuild/webpack 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 (53) hide show
  1. package/dist/config/defaults.js +1 -4
  2. package/dist/core/createContext.js +0 -4
  3. package/dist/core/initConfigs.js +1 -2
  4. package/dist/core/webpackConfig.js +7 -8
  5. package/dist/plugins/babel.d.ts +1 -1
  6. package/dist/plugins/minimize.js +5 -2
  7. package/dist/plugins/tsLoader.js +2 -3
  8. package/dist/shared/plugin.js +0 -1
  9. package/dist/types/config/index.d.ts +6 -14
  10. package/dist/types/config/index.js +0 -10
  11. package/dist/types/config/security.d.ts +3 -3
  12. package/dist/types/config/source.d.ts +3 -13
  13. package/dist/types/config/tools.d.ts +8 -11
  14. package/dist/types/context.d.ts +0 -2
  15. package/dist/types/hooks.d.ts +7 -2
  16. package/dist/types/thirdParty/index.d.ts +0 -1
  17. package/package.json +8 -7
  18. package/dist/config/validate/dev.d.ts +0 -3
  19. package/dist/config/validate/dev.js +0 -29
  20. package/dist/config/validate/experiments.d.ts +0 -3
  21. package/dist/config/validate/experiments.js +0 -29
  22. package/dist/config/validate/html.d.ts +0 -3
  23. package/dist/config/validate/html.js +0 -29
  24. package/dist/config/validate/index.d.ts +0 -4
  25. package/dist/config/validate/index.js +0 -52
  26. package/dist/config/validate/output.d.ts +0 -3
  27. package/dist/config/validate/output.js +0 -37
  28. package/dist/config/validate/performance.d.ts +0 -3
  29. package/dist/config/validate/performance.js +0 -47
  30. package/dist/config/validate/security.d.ts +0 -4
  31. package/dist/config/validate/security.js +0 -38
  32. package/dist/config/validate/source.d.ts +0 -3
  33. package/dist/config/validate/source.js +0 -34
  34. package/dist/config/validate/tools.d.ts +0 -3
  35. package/dist/config/validate/tools.js +0 -48
  36. package/dist/exports/HtmlWebpackPlugin.d.ts +0 -2
  37. package/dist/exports/HtmlWebpackPlugin.js +0 -35
  38. package/dist/plugins/pug.d.ts +0 -2
  39. package/dist/plugins/pug.js +0 -52
  40. package/dist/types/config/dev.d.ts +0 -3
  41. package/dist/types/config/dev.js +0 -16
  42. package/dist/types/config/experiments.d.ts +0 -3
  43. package/dist/types/config/experiments.js +0 -16
  44. package/dist/types/config/html.d.ts +0 -3
  45. package/dist/types/config/html.js +0 -16
  46. package/dist/types/config/output.d.ts +0 -9
  47. package/dist/types/config/output.js +0 -16
  48. package/dist/types/config/performance.d.ts +0 -3
  49. package/dist/types/config/performance.js +0 -16
  50. package/dist/types/thirdParty/CopyWebpackPlugin.d.ts +0 -62
  51. package/dist/types/thirdParty/CopyWebpackPlugin.js +0 -16
  52. package/dist/webpackLoaders/pugLoader.d.ts +0 -3
  53. package/dist/webpackLoaders/pugLoader.js +0 -44
@@ -33,10 +33,7 @@ const createDefaultConfig = () => ({
33
33
  pluginOptions: {}
34
34
  }
35
35
  },
36
- source: {
37
- ...(0, import_shared.getDefaultSourceConfig)(),
38
- define: {}
39
- },
36
+ source: (0, import_shared.getDefaultSourceConfig)(),
40
37
  output: (0, import_shared.getDefaultOutputConfig)(),
41
38
  security: {
42
39
  ...(0, import_shared.getDefaultSecurityConfig)(),
@@ -25,7 +25,6 @@ module.exports = __toCommonJS(createContext_exports);
25
25
  var import_path = require("path");
26
26
  var import_shared = require("@rsbuild/shared");
27
27
  var import_initHooks = require("./initHooks");
28
- var import_validate = require("../config/validate");
29
28
  var import_defaults = require("../config/defaults");
30
29
  function createPrimaryContext(options, userRsbuildConfig) {
31
30
  const rsbuildConfig = (0, import_defaults.withDefaultConfig)(userRsbuildConfig);
@@ -34,18 +33,15 @@ function createPrimaryContext(options, userRsbuildConfig) {
34
33
  rsbuildConfig.output,
35
34
  "webpack"
36
35
  );
37
- const configValidatingTask = Promise.resolve();
38
36
  return {
39
37
  ...context,
40
38
  hooks: (0, import_initHooks.initHooks)(),
41
- configValidatingTask,
42
39
  config: { ...rsbuildConfig },
43
40
  originalConfig: userRsbuildConfig
44
41
  };
45
42
  }
46
43
  async function createContext(options, rsbuildConfig) {
47
44
  (0, import_shared.debug)("create context");
48
- await (0, import_validate.validateRsbuildConfig)(rsbuildConfig);
49
45
  const ctx = createPrimaryContext(options, rsbuildConfig);
50
46
  const tsconfigPath = (0, import_path.join)(ctx.rootPath, import_shared.TS_CONFIG_FILE);
51
47
  if (await (0, import_shared.isFileExists)(tsconfigPath)) {
@@ -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 webpackConfigs = await Promise.all(
51
50
  targets.map((target) => (0, import_webpackConfig.generateWebpackConfig)({ target, context }))
52
51
  );
@@ -32,7 +32,6 @@ __export(webpackConfig_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(webpackConfig_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 modifyWebpackChain(context, utils, chain) {
38
37
  var _a;
@@ -42,7 +41,7 @@ async function modifyWebpackChain(context, utils, chain) {
42
41
  utils
43
42
  );
44
43
  if ((_a = context.config.tools) == null ? void 0 : _a.webpackChain) {
45
- (0, import_shared.ensureArray)(context.config.tools.webpackChain).forEach((item) => {
44
+ (0, import_shared.castArray)(context.config.tools.webpackChain).forEach((item) => {
46
45
  item(modifiedChain, utils);
47
46
  });
48
47
  }
@@ -69,7 +68,7 @@ async function modifyWebpackConfig(context, webpackConfig, utils) {
69
68
  }
70
69
  async function getChainUtils(target) {
71
70
  const { default: webpack } = await Promise.resolve().then(() => __toESM(require("webpack")));
72
- const { default: HtmlWebpackPlugin } = await Promise.resolve().then(() => __toESM(require("html-webpack-plugin")));
71
+ const { default: HtmlPlugin } = await Promise.resolve().then(() => __toESM(require("html-webpack-plugin")));
73
72
  const nodeEnv = process.env.NODE_ENV;
74
73
  const nameMap = {
75
74
  web: "client",
@@ -88,8 +87,8 @@ async function getChainUtils(target) {
88
87
  isWebWorker: target === "web-worker",
89
88
  CHAIN_ID: import_shared.CHAIN_ID,
90
89
  getCompiledPath: import_shared2.getCompiledPath,
91
- HtmlWebpackPlugin,
92
- HtmlPlugin: HtmlWebpackPlugin
90
+ HtmlPlugin,
91
+ HtmlWebpackPlugin: HtmlPlugin
93
92
  };
94
93
  }
95
94
  async function getConfigUtils(config, chainUtils) {
@@ -98,7 +97,7 @@ async function getConfigUtils(config, chainUtils) {
98
97
  ...chainUtils,
99
98
  mergeConfig: merge,
100
99
  addRules(rules) {
101
- const ruleArr = (0, import_lodash.castArray)(rules);
100
+ const ruleArr = (0, import_shared.castArray)(rules);
102
101
  if (!config.module) {
103
102
  config.module = {};
104
103
  }
@@ -108,14 +107,14 @@ async function getConfigUtils(config, chainUtils) {
108
107
  config.module.rules.unshift(...ruleArr);
109
108
  },
110
109
  prependPlugins(plugins) {
111
- const pluginArr = (0, import_lodash.castArray)(plugins);
110
+ const pluginArr = (0, import_shared.castArray)(plugins);
112
111
  if (!config.plugins) {
113
112
  config.plugins = [];
114
113
  }
115
114
  config.plugins.unshift(...pluginArr);
116
115
  },
117
116
  appendPlugins(plugins) {
118
- const pluginArr = (0, import_lodash.castArray)(plugins);
117
+ const pluginArr = (0, import_shared.castArray)(plugins);
119
118
  if (!config.plugins) {
120
119
  config.plugins = [];
121
120
  }
@@ -1,3 +1,3 @@
1
1
  import type { RsbuildPlugin, NormalizedConfig } from '../types';
2
- export declare const getUseBuiltIns: (config: NormalizedConfig) => false | "entry" | "usage";
2
+ export declare const getUseBuiltIns: (config: NormalizedConfig) => false | "usage" | "entry";
3
3
  export declare const pluginBabel: () => RsbuildPlugin;
@@ -32,6 +32,7 @@ __export(minimize_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(minimize_exports);
34
34
  var import_shared = require("@rsbuild/shared");
35
+ var import_plugin_css_minimizer = require("@rsbuild/plugin-css-minimizer");
35
36
  async function applyJSMinimizer(chain, config) {
36
37
  const { default: TerserPlugin } = await Promise.resolve().then(() => __toESM(require("terser-webpack-plugin")));
37
38
  const finalOptions = await (0, import_shared.getJSMinifyOptions)(config);
@@ -44,13 +45,15 @@ async function applyJSMinimizer(chain, config) {
44
45
  const pluginMinimize = () => ({
45
46
  name: "plugin-minimize",
46
47
  setup(api) {
47
- api.modifyBundlerChain(async (chain, { isProd }) => {
48
+ api.modifyBundlerChain(async (chain, { isProd, CHAIN_ID: CHAIN_ID2 }) => {
48
49
  const config = api.getNormalizedConfig();
49
50
  const isMinimize = isProd && !config.output.disableMinimize;
50
51
  chain.optimization.minimize(isMinimize);
51
52
  if (isMinimize) {
52
53
  await applyJSMinimizer(chain, config);
53
- await (0, import_shared.applyCSSMinimizer)(chain, config);
54
+ await (0, import_plugin_css_minimizer.applyCSSMinimizer)(chain, CHAIN_ID2, {
55
+ pluginOptions: config.tools.minifyCss
56
+ });
54
57
  }
55
58
  });
56
59
  }
@@ -33,7 +33,6 @@ __export(tsLoader_exports, {
33
33
  module.exports = __toCommonJS(tsLoader_exports);
34
34
  var import_shared = require("@rsbuild/shared");
35
35
  var import_plugin_babel = require("@rsbuild/plugin-babel");
36
- var import_lodash = __toESM(require("lodash"));
37
36
  var import_web = require("@rsbuild/babel-preset/web");
38
37
  var import_babel = require("./babel");
39
38
  const pluginTsLoader = () => {
@@ -67,10 +66,10 @@ const pluginTsLoader = () => {
67
66
  const excludes = [];
68
67
  const tsLoaderUtils = {
69
68
  addIncludes(items) {
70
- includes.push(...import_lodash.default.castArray(items));
69
+ includes.push(...(0, import_shared.castArray)(items));
71
70
  },
72
71
  addExcludes(items) {
73
- excludes.push(...import_lodash.default.castArray(items));
72
+ excludes.push(...(0, import_shared.castArray)(items));
74
73
  }
75
74
  };
76
75
  const tsLoaderOptions = (0, import_shared.mergeChainedOptions)(
@@ -66,7 +66,6 @@ const applyDefaultPlugins = (plugins) => {
66
66
  (_b = plugins.cleanOutput) == null ? void 0 : _b.call(plugins),
67
67
  Promise.resolve().then(() => __toESM(require("../plugins/hmr"))).then((m) => m.pluginHMR()),
68
68
  plugins.svg(),
69
- Promise.resolve().then(() => __toESM(require("../plugins/pug"))).then((m) => m.pluginPug()),
70
69
  Promise.resolve().then(() => __toESM(require("../plugins/copy"))).then((m) => m.pluginCopy()),
71
70
  Promise.resolve().then(() => __toESM(require("../plugins/react"))).then((m) => m.pluginReactWebpack()),
72
71
  plugins.font(),
@@ -1,12 +1,12 @@
1
1
  import type { DeepReadonly } from '@rsbuild/shared';
2
- import type { DevConfig, NormalizedDevConfig } from './dev';
3
- import type { ExperimentsConfig, NormalizedExperimentsConfig } from './experiments';
4
- import type { HtmlConfig, NormalizedHtmlConfig } from './html';
5
- import type { NormalizedOutputConfig, OutputConfig } from './output';
6
- import type { NormalizedPerformanceConfig, PerformanceConfig } from './performance';
7
2
  import type { NormalizedSecurityConfig, SecurityConfig } from './security';
8
3
  import type { NormalizedSourceConfig, SourceConfig } from './source';
9
4
  import type { NormalizedToolsConfig, ToolsConfig } from './tools';
5
+ import type { DevConfig, HtmlConfig, OutputConfig, ExperimentsConfig, PerformanceConfig, NormalizedDevConfig, NormalizedHtmlConfig, NormalizedOutputConfig, NormalizedExperimentsConfig, NormalizedPerformanceConfig } from '@rsbuild/shared';
6
+ export type { DevConfig, HtmlConfig, OutputConfig, ExperimentsConfig, PerformanceConfig, NormalizedDevConfig, NormalizedHtmlConfig, NormalizedOutputConfig, NormalizedExperimentsConfig, NormalizedPerformanceConfig };
7
+ export * from './security';
8
+ export * from './source';
9
+ export * from './tools';
10
10
  /** The Rsbuild config when using Webpack as the bundler */
11
11
  export interface RsbuildConfig {
12
12
  dev?: DevConfig;
@@ -27,12 +27,4 @@ export type NormalizedConfig = DeepReadonly<{
27
27
  security: NormalizedSecurityConfig;
28
28
  performance: NormalizedPerformanceConfig;
29
29
  experiments: NormalizedExperimentsConfig;
30
- }>;
31
- export * from './dev';
32
- export * from './experiments';
33
- export * from './html';
34
- export * from './output';
35
- export * from './performance';
36
- export * from './security';
37
- export * from './source';
38
- export * from './tools';
30
+ }>;
@@ -15,21 +15,11 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
15
15
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
16
  var config_exports = {};
17
17
  module.exports = __toCommonJS(config_exports);
18
- __reExport(config_exports, require("./dev"), module.exports);
19
- __reExport(config_exports, require("./experiments"), module.exports);
20
- __reExport(config_exports, require("./html"), module.exports);
21
- __reExport(config_exports, require("./output"), module.exports);
22
- __reExport(config_exports, require("./performance"), module.exports);
23
18
  __reExport(config_exports, require("./security"), module.exports);
24
19
  __reExport(config_exports, require("./source"), module.exports);
25
20
  __reExport(config_exports, require("./tools"), module.exports);
26
21
  // Annotate the CommonJS export names for ESM import in node:
27
22
  0 && (module.exports = {
28
- ...require("./dev"),
29
- ...require("./experiments"),
30
- ...require("./html"),
31
- ...require("./output"),
32
- ...require("./performance"),
33
23
  ...require("./security"),
34
24
  ...require("./source"),
35
25
  ...require("./tools")
@@ -1,9 +1,9 @@
1
- import type { SriOptions, SharedSecurityConfig, NormalizedSharedSecurityConfig } from '@rsbuild/shared';
2
- export type SecurityConfig = SharedSecurityConfig & {
1
+ import type { SriOptions, SecurityConfig as BaseSecurityConfig, NormalizedSecurityConfig as BaseNormalizedSecurityConfig } from '@rsbuild/shared';
2
+ export type SecurityConfig = BaseSecurityConfig & {
3
3
  /**
4
4
  * Adding an integrity attribute (`integrity`) to sub-resources introduced by HTML allows the browser to
5
5
  * verify the integrity of the introduced resource, thus preventing tampering with the downloaded resource.
6
6
  */
7
7
  sri?: SriOptions | boolean;
8
8
  };
9
- export type NormalizedSecurityConfig = NormalizedSharedSecurityConfig & Required<Pick<SecurityConfig, 'sri'>>;
9
+ export type NormalizedSecurityConfig = BaseNormalizedSecurityConfig & Required<Pick<SecurityConfig, 'sri'>>;
@@ -1,4 +1,4 @@
1
- import type { SharedSourceConfig, NormalizedSharedSourceConfig, ChainedConfig } from '@rsbuild/shared';
1
+ import type { ChainedConfig, SourceConfig as BaseSourceConfig, NormalizedSourceConfig as BaseNormalizedSourceConfig } from '@rsbuild/shared';
2
2
  export type ModuleScopes = Array<string | RegExp>;
3
3
  export type TransformImport = {
4
4
  libraryName: string;
@@ -10,27 +10,17 @@ export type TransformImport = {
10
10
  customName?: ((member: string) => string | undefined) | string;
11
11
  customStyleName?: ((member: string) => string | undefined) | string;
12
12
  };
13
- export interface SourceConfig extends SharedSourceConfig {
14
- /**
15
- * Replaces variables in your code with other values or expressions at compile time.
16
- */
17
- define?: Record<string, any>;
13
+ export interface SourceConfig extends BaseSourceConfig {
18
14
  /**
19
15
  * Restrict importing paths. After configuring this option, all source files can only import code from
20
16
  * the specific paths, and import code from other paths is not allowed.
21
17
  */
22
18
  moduleScopes?: ChainedConfig<ModuleScopes>;
23
- /**
24
- * Configure babel-plugin-import or swc-plugin-import or Rspack builtins plugin import
25
- */
26
- transformImport?: false | TransformImport[];
27
19
  }
28
- export interface NormalizedSourceConfig extends NormalizedSharedSourceConfig {
29
- define: Record<string, any>;
20
+ export interface NormalizedSourceConfig extends BaseNormalizedSourceConfig {
30
21
  /**
31
22
  * Restrict importing paths. After configuring this option, all source files can only import code from
32
23
  * the specific paths, and import code from other paths is not allowed.
33
24
  */
34
25
  moduleScopes?: ChainedConfig<ModuleScopes>;
35
- transformImport?: false | TransformImport[];
36
26
  }
@@ -1,7 +1,8 @@
1
- import type { ArrayOrNot, ChainedConfig, FileFilterUtil, SharedToolsConfig, TerserPluginOptions } from '@rsbuild/shared';
1
+ import type { ArrayOrNot, ChainedConfig, FileFilterUtil, TerserPluginOptions, ToolsConfig as BaseToolsConfig } from '@rsbuild/shared';
2
2
  import type { BabelTransformOptions, BabelConfigUtils } from '@rsbuild/plugin-babel';
3
+ import type { PluginCssMinimizerOptions } from '@rsbuild/plugin-css-minimizer';
3
4
  import type { ModifyWebpackChainUtils, ModifyWebpackConfigUtils } from '../hooks';
4
- import type { CSSExtractOptions, HTMLPluginOptions, TSLoaderOptions, WebpackChain, WebpackConfig } from '../thirdParty';
5
+ import type { WebpackChain, WebpackConfig, TSLoaderOptions, CSSExtractOptions } from '../thirdParty';
5
6
  import type { NormalizedCSSExtractOptions } from '../thirdParty/css';
6
7
  export type ToolsTerserConfig = ChainedConfig<TerserPluginOptions>;
7
8
  export type ToolsTSLoaderConfig = ChainedConfig<TSLoaderOptions, {
@@ -9,14 +10,10 @@ export type ToolsTSLoaderConfig = ChainedConfig<TSLoaderOptions, {
9
10
  addExcludes: FileFilterUtil;
10
11
  }>;
11
12
  export type ToolsCssExtractConfig = CSSExtractOptions | ((options: CSSExtractOptions) => CSSExtractOptions | void);
12
- export type ToolsHtmlPluginConfig = ChainedConfig<HTMLPluginOptions, {
13
- entryName: string;
14
- entryValue: WebpackConfig['entry'];
15
- }>;
16
13
  export type ToolsWebpackConfig = ChainedConfig<WebpackConfig, ModifyWebpackConfigUtils>;
17
14
  export type ToolsWebpackChainConfig = ArrayOrNot<(chain: WebpackChain, utils: ModifyWebpackChainUtils) => void>;
18
15
  export type ToolsBabelConfig = ChainedConfig<BabelTransformOptions, BabelConfigUtils>;
19
- export interface ToolsConfig extends SharedToolsConfig {
16
+ export interface ToolsConfig extends BaseToolsConfig {
20
17
  /**
21
18
  * Modify the options of [babel-loader](https://github.com/babel/babel-loader)
22
19
  * When `tools.babel`'s type is Function,the default babel config will be passed in as the first parameter, the config object can be modified directly, or a value can be returned as the final result.
@@ -33,10 +30,6 @@ export interface ToolsConfig extends SharedToolsConfig {
33
30
  * When `tools.tsLoader` is not undefined, Rsbuild will use ts-loader instead of babel-loader to compile TypeScript code.
34
31
  */
35
32
  tsLoader?: ToolsTSLoaderConfig;
36
- /**
37
- * Modify the options of [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin).
38
- */
39
- htmlPlugin?: false | ToolsHtmlPluginConfig;
40
33
  /**
41
34
  * Modify the options of [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin).
42
35
  */
@@ -49,6 +42,10 @@ export interface ToolsConfig extends SharedToolsConfig {
49
42
  * Configure webpack by [webpack-chain](https://github.com/neutrinojs/webpack-chain).
50
43
  */
51
44
  webpackChain?: ToolsWebpackChainConfig;
45
+ /**
46
+ * Modify the options of [css-minimizer-webpack-plugin](https://github.com/webpack-contrib/css-minimizer-webpack-plugin).
47
+ */
48
+ minifyCss?: PluginCssMinimizerOptions['pluginOptions'];
52
49
  }
53
50
  export interface NormalizedToolsConfig extends ToolsConfig {
54
51
  cssExtract: NormalizedCSSExtractOptions;
@@ -8,8 +8,6 @@ export type Context = BaseContext & {
8
8
  hooks: Readonly<Hooks>;
9
9
  /** Current Rsbuild config. */
10
10
  config: Readonly<RsbuildConfig>;
11
- /** The async task to validate schema of config. */
12
- configValidatingTask: Promise<void>;
13
11
  /** The original Rsbuild config passed from the createRsbuild method. */
14
12
  originalConfig: Readonly<RsbuildConfig>;
15
13
  /** The normalized Rsbuild config. */
@@ -2,10 +2,15 @@ import type { ChainIdentifier, ModifyChainUtils } from '@rsbuild/shared';
2
2
  import type { WebpackChain, WebpackConfig } from './thirdParty';
3
3
  import type { RuleSetRule, WebpackPluginInstance } from 'webpack';
4
4
  export type ModifyWebpackChainUtils = ModifyChainUtils & {
5
- /** @deprecated Use target instead. */
6
- name: string;
7
5
  webpack: typeof import('webpack');
8
6
  CHAIN_ID: ChainIdentifier;
7
+ /**
8
+ * @deprecated Use target instead.
9
+ * */
10
+ name: string;
11
+ /**
12
+ * @deprecated Use HtmlPlugin instead.
13
+ */
9
14
  HtmlWebpackPlugin: typeof import('html-webpack-plugin');
10
15
  };
11
16
  export type ModifyWebpackConfigUtils = ModifyWebpackChainUtils & {
@@ -2,7 +2,6 @@ import type { WebpackChain } from '@rsbuild/shared';
2
2
  import type webpack from 'webpack';
3
3
  import type { Configuration as WebpackConfig } from 'webpack';
4
4
  import type { Options as RawTSLoaderOptions } from 'ts-loader';
5
- export type { CopyPluginOptions } from './CopyWebpackPlugin';
6
5
  export type { Options as HTMLPluginOptions } from 'html-webpack-plugin';
7
6
  export type { SubresourceIntegrityPluginOptions as SubresourceIntegrityOptions } from 'webpack-subresource-integrity';
8
7
  export type TSLoaderOptions = Partial<RawTSLoaderOptions>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/webpack",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "homepage": "https://rsbuild.dev",
5
5
  "repository": {
6
6
  "type": "git",
@@ -42,7 +42,7 @@
42
42
  "dependencies": {
43
43
  "@babel/core": "^7.23.2",
44
44
  "@babel/preset-react": "^7.22.15",
45
- "@modern-js/server": "^2.39.0",
45
+ "@modern-js/server": "^2.39.2",
46
46
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
47
47
  "babel-loader": "9.1.3",
48
48
  "babel-plugin-import": "1.13.5",
@@ -59,10 +59,11 @@
59
59
  "tsconfig-paths-webpack-plugin": "4.1.0",
60
60
  "webpack": "^5.89.0",
61
61
  "webpack-subresource-integrity": "5.1.0",
62
- "@rsbuild/babel-preset": "0.0.12",
63
- "@rsbuild/core": "0.0.12",
64
- "@rsbuild/plugin-babel": "0.0.12",
65
- "@rsbuild/shared": "0.0.12"
62
+ "@rsbuild/babel-preset": "0.0.13",
63
+ "@rsbuild/core": "0.0.13",
64
+ "@rsbuild/plugin-babel": "0.0.13",
65
+ "@rsbuild/plugin-css-minimizer": "0.0.13",
66
+ "@rsbuild/shared": "0.0.13"
66
67
  },
67
68
  "devDependencies": {
68
69
  "@types/lodash": "^4.14.200",
@@ -70,7 +71,7 @@
70
71
  "react": "^18.2.0",
71
72
  "react-dom": "^18.2.0",
72
73
  "typescript": "^5.2.2",
73
- "@rsbuild/test-helper": "0.0.12"
74
+ "@rsbuild/test-helper": "0.0.13"
74
75
  },
75
76
  "engines": {
76
77
  "node": ">=14.0.0"
@@ -1,3 +0,0 @@
1
- import { z } from '@rsbuild/shared';
2
- import type { DevConfig } from '../../types';
3
- export declare const devConfigSchema: z.ZodType<DevConfig>;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var dev_exports = {};
20
- __export(dev_exports, {
21
- devConfigSchema: () => devConfigSchema
22
- });
23
- module.exports = __toCommonJS(dev_exports);
24
- var import_shared = require("@rsbuild/shared");
25
- const devConfigSchema = import_shared.sharedDevConfigSchema;
26
- // Annotate the CommonJS export names for ESM import in node:
27
- 0 && (module.exports = {
28
- devConfigSchema
29
- });
@@ -1,3 +0,0 @@
1
- import { z } from '@rsbuild/shared';
2
- import type { ExperimentsConfig } from '../../types';
3
- export declare const experimentsConfigSchema: z.ZodType<ExperimentsConfig>;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var experiments_exports = {};
20
- __export(experiments_exports, {
21
- experimentsConfigSchema: () => experimentsConfigSchema
22
- });
23
- module.exports = __toCommonJS(experiments_exports);
24
- var import_shared = require("@rsbuild/shared");
25
- const experimentsConfigSchema = import_shared.sharedExperimentsConfigSchema;
26
- // Annotate the CommonJS export names for ESM import in node:
27
- 0 && (module.exports = {
28
- experimentsConfigSchema
29
- });
@@ -1,3 +0,0 @@
1
- import { z } from '@rsbuild/shared';
2
- import type { HtmlConfig } from '../../types';
3
- export declare const htmlConfigSchema: z.ZodType<HtmlConfig>;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var html_exports = {};
20
- __export(html_exports, {
21
- htmlConfigSchema: () => htmlConfigSchema
22
- });
23
- module.exports = __toCommonJS(html_exports);
24
- var import_shared = require("@rsbuild/shared");
25
- const htmlConfigSchema = import_shared.sharedHtmlConfigSchema;
26
- // Annotate the CommonJS export names for ESM import in node:
27
- 0 && (module.exports = {
28
- htmlConfigSchema
29
- });
@@ -1,4 +0,0 @@
1
- import { z } from '@rsbuild/shared/zod';
2
- import { RsbuildConfig } from '../../types';
3
- export declare const configSchema: z.ZodType<RsbuildConfig>;
4
- export declare const validateRsbuildConfig: (data: unknown) => Promise<unknown>;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var validate_exports = {};
20
- __export(validate_exports, {
21
- configSchema: () => configSchema,
22
- validateRsbuildConfig: () => validateRsbuildConfig
23
- });
24
- module.exports = __toCommonJS(validate_exports);
25
- var import_zod = require("@rsbuild/shared/zod");
26
- var import_shared = require("@rsbuild/shared");
27
- var import_dev = require("./dev");
28
- var import_experiments = require("./experiments");
29
- var import_html = require("./html");
30
- var import_output = require("./output");
31
- var import_performance = require("./performance");
32
- var import_security = require("./security");
33
- var import_source = require("./source");
34
- var import_tools = require("./tools");
35
- const configSchema = import_zod.z.partialObj({
36
- source: import_source.sourceConfigSchema,
37
- dev: import_dev.devConfigSchema,
38
- html: import_html.htmlConfigSchema,
39
- experiments: import_experiments.experimentsConfigSchema,
40
- output: import_output.outputConfigSchema,
41
- performance: import_performance.performanceConfigSchema,
42
- security: import_security.securityConfigSchema,
43
- tools: import_tools.toolsConfigSchema
44
- });
45
- const validateRsbuildConfig = async (data) => {
46
- return (0, import_shared.validateRsbuildConfig)(configSchema, data);
47
- };
48
- // Annotate the CommonJS export names for ESM import in node:
49
- 0 && (module.exports = {
50
- configSchema,
51
- validateRsbuildConfig
52
- });
@@ -1,3 +0,0 @@
1
- import { z } from '@rsbuild/shared';
2
- import type { OutputConfig } from '../../types';
3
- export declare const outputConfigSchema: z.ZodType<OutputConfig>;
@@ -1,37 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var output_exports = {};
20
- __export(output_exports, {
21
- outputConfigSchema: () => outputConfigSchema
22
- });
23
- module.exports = __toCommonJS(output_exports);
24
- var import_shared = require("@rsbuild/shared");
25
- const AdditionalOptionsSchema = import_shared.z.partialObj({ concurrency: import_shared.z.number() });
26
- const CopyPluginPatternsSchema = import_shared.z.array(import_shared.z.any());
27
- const CopyPluginOptionsSchema = import_shared.z.object({
28
- patterns: CopyPluginPatternsSchema,
29
- options: import_shared.z.optional(AdditionalOptionsSchema)
30
- });
31
- const outputConfigSchema = import_shared.sharedOutputConfigSchema.extend({
32
- copy: import_shared.z.union([CopyPluginOptionsSchema, CopyPluginPatternsSchema])
33
- }).partial();
34
- // Annotate the CommonJS export names for ESM import in node:
35
- 0 && (module.exports = {
36
- outputConfigSchema
37
- });
@@ -1,3 +0,0 @@
1
- import { z } from '@rsbuild/shared';
2
- import type { PerformanceConfig } from '../../types';
3
- export declare const performanceConfigSchema: z.ZodType<PerformanceConfig>;
@@ -1,47 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var performance_exports = {};
20
- __export(performance_exports, {
21
- performanceConfigSchema: () => performanceConfigSchema
22
- });
23
- module.exports = __toCommonJS(performance_exports);
24
- var import_shared = require("@rsbuild/shared");
25
- const BaseChunkSplitSchema = import_shared.BaseSplitRulesSchema.extend({
26
- strategy: import_shared.z.enum([
27
- "split-by-module",
28
- "split-by-experience",
29
- "all-in-one",
30
- "single-vendor"
31
- ]),
32
- forceSplitting: import_shared.ForceSplittingSchema,
33
- override: import_shared.z.any().optional()
34
- });
35
- const RsbuildChunkSplitSchema = import_shared.z.union([
36
- BaseChunkSplitSchema,
37
- import_shared.SplitBySizeSchema,
38
- import_shared.SplitCustomSchema
39
- ]);
40
- const performanceConfigSchema = import_shared.sharedPerformanceConfigSchema.extend({
41
- bundleAnalyze: import_shared.z.any(),
42
- chunkSplit: RsbuildChunkSplitSchema
43
- }).partial();
44
- // Annotate the CommonJS export names for ESM import in node:
45
- 0 && (module.exports = {
46
- performanceConfigSchema
47
- });
@@ -1,4 +0,0 @@
1
- import { z, SriOptions } from '@rsbuild/shared';
2
- import type { SecurityConfig } from '../../types';
3
- export declare const SriOptionsSchema: z.ZodType<SriOptions>;
4
- export declare const securityConfigSchema: z.ZodType<SecurityConfig>;
@@ -1,38 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var security_exports = {};
20
- __export(security_exports, {
21
- SriOptionsSchema: () => SriOptionsSchema,
22
- securityConfigSchema: () => securityConfigSchema
23
- });
24
- module.exports = __toCommonJS(security_exports);
25
- var import_shared = require("@rsbuild/shared");
26
- const SriOptionsSchema = import_shared.z.partialObj({
27
- hashFuncNames: import_shared.z.array(import_shared.z.string()).min(1),
28
- enabled: import_shared.z.literals(["auto", true, false]),
29
- hashLoading: import_shared.z.enum(["eager", "lazy"])
30
- });
31
- const securityConfigSchema = import_shared.sharedSecurityConfigSchema.extend({
32
- sri: import_shared.z.union([SriOptionsSchema, import_shared.z.boolean()])
33
- }).partial();
34
- // Annotate the CommonJS export names for ESM import in node:
35
- 0 && (module.exports = {
36
- SriOptionsSchema,
37
- securityConfigSchema
38
- });
@@ -1,3 +0,0 @@
1
- import { z } from '@rsbuild/shared';
2
- import type { SourceConfig } from '../../types';
3
- export declare const sourceConfigSchema: z.ZodType<SourceConfig>;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var source_exports = {};
20
- __export(source_exports, {
21
- sourceConfigSchema: () => sourceConfigSchema
22
- });
23
- module.exports = __toCommonJS(source_exports);
24
- var import_shared = require("@rsbuild/shared");
25
- const sourceConfigSchema = import_shared.sharedSourceConfigSchema.extend({
26
- define: import_shared.z.record(import_shared.z.any()),
27
- moduleScopes: import_shared.z.chained(
28
- import_shared.z.array(import_shared.z.union([import_shared.z.string(), import_shared.z.instanceof(RegExp)]))
29
- )
30
- }).partial();
31
- // Annotate the CommonJS export names for ESM import in node:
32
- 0 && (module.exports = {
33
- sourceConfigSchema
34
- });
@@ -1,3 +0,0 @@
1
- import { z } from '@rsbuild/shared';
2
- import type { ToolsConfig } from '../../types';
3
- export declare const toolsConfigSchema: z.ZodType<ToolsConfig>;
@@ -1,48 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var tools_exports = {};
20
- __export(tools_exports, {
21
- toolsConfigSchema: () => toolsConfigSchema
22
- });
23
- module.exports = __toCommonJS(tools_exports);
24
- var import_shared = require("@rsbuild/shared");
25
- const toolsConfigSchema = import_shared.sharedToolsConfigSchema.extend({
26
- terser: import_shared.z.chained(import_shared.z.any()),
27
- tsLoader: import_shared.z.chained(
28
- import_shared.z.any(),
29
- import_shared.z.object({
30
- addIncludes: import_shared.z.string(),
31
- addExcludes: import_shared.FileFilterUtilSchema
32
- })
33
- ),
34
- htmlPlugin: import_shared.z.chained(
35
- import_shared.z.any(),
36
- import_shared.z.object({ entryName: import_shared.z.string(), entryValue: import_shared.z.any() })
37
- ),
38
- cssExtract: import_shared.z.partialObj({
39
- pluginOptions: import_shared.z.any(),
40
- loaderOptions: import_shared.z.any()
41
- }),
42
- webpack: import_shared.z.chained(import_shared.z.any(), import_shared.z.any()),
43
- webpackChain: import_shared.z.arrayOrNot(import_shared.z.function())
44
- }).partial();
45
- // Annotate the CommonJS export names for ESM import in node:
46
- 0 && (module.exports = {
47
- toolsConfigSchema
48
- });
@@ -1,2 +0,0 @@
1
- import HtmlWebpackPlugin from 'html-webpack-plugin';
2
- export default HtmlWebpackPlugin;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var HtmlWebpackPlugin_exports = {};
30
- __export(HtmlWebpackPlugin_exports, {
31
- default: () => HtmlWebpackPlugin_default
32
- });
33
- module.exports = __toCommonJS(HtmlWebpackPlugin_exports);
34
- var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
35
- var HtmlWebpackPlugin_default = import_html_webpack_plugin.default;
@@ -1,2 +0,0 @@
1
- import type { RsbuildPlugin } from '../types';
2
- export declare const pluginPug: () => RsbuildPlugin;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var pug_exports = {};
30
- __export(pug_exports, {
31
- pluginPug: () => pluginPug
32
- });
33
- module.exports = __toCommonJS(pug_exports);
34
- var import_path = __toESM(require("path"));
35
- var import_shared = require("@rsbuild/shared");
36
- const pluginPug = () => ({
37
- name: "plugin-pug",
38
- setup(api) {
39
- api.modifyWebpackChain(async (chain, { CHAIN_ID }) => {
40
- const config = api.getNormalizedConfig();
41
- const { pug } = config.tools;
42
- if (!pug) {
43
- return;
44
- }
45
- chain.module.rule(CHAIN_ID.RULE.PUG).test(/\.pug$/).use(CHAIN_ID.USE.PUG).loader(import_path.default.resolve(__dirname, "../webpackLoaders/pugLoader")).options((0, import_shared.mergeChainedOptions)({}, pug === true ? {} : pug));
46
- });
47
- }
48
- });
49
- // Annotate the CommonJS export names for ESM import in node:
50
- 0 && (module.exports = {
51
- pluginPug
52
- });
@@ -1,3 +0,0 @@
1
- import type { SharedDevConfig, NormalizedSharedDevConfig } from '@rsbuild/shared';
2
- export type DevConfig = SharedDevConfig;
3
- export type NormalizedDevConfig = NormalizedSharedDevConfig;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var dev_exports = {};
16
- module.exports = __toCommonJS(dev_exports);
@@ -1,3 +0,0 @@
1
- import type { SharedExperimentsConfig } from '@rsbuild/shared';
2
- export type ExperimentsConfig = SharedExperimentsConfig;
3
- export type NormalizedExperimentsConfig = Required<ExperimentsConfig>;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var experiments_exports = {};
16
- module.exports = __toCommonJS(experiments_exports);
@@ -1,3 +0,0 @@
1
- import type { SharedHtmlConfig, NormalizedSharedHtmlConfig } from '@rsbuild/shared';
2
- export type HtmlConfig = SharedHtmlConfig;
3
- export type NormalizedHtmlConfig = NormalizedSharedHtmlConfig;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var html_exports = {};
16
- module.exports = __toCommonJS(html_exports);
@@ -1,9 +0,0 @@
1
- import type { SharedOutputConfig, NormalizedSharedOutputConfig } from '@rsbuild/shared';
2
- import type { CopyPluginOptions } from '../thirdParty';
3
- export type OutputConfig = SharedOutputConfig & {
4
- /**
5
- * Copies the specified file or directory to the dist directory.
6
- */
7
- copy?: CopyPluginOptions | CopyPluginOptions['patterns'];
8
- };
9
- export type NormalizedOutputConfig = OutputConfig & NormalizedSharedOutputConfig;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var output_exports = {};
16
- module.exports = __toCommonJS(output_exports);
@@ -1,3 +0,0 @@
1
- import type { SharedPerformanceConfig, NormalizedSharedPerformanceConfig } from '@rsbuild/shared';
2
- export type PerformanceConfig = SharedPerformanceConfig;
3
- export type NormalizedPerformanceConfig = NormalizedSharedPerformanceConfig;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var performance_exports = {};
16
- module.exports = __toCommonJS(performance_exports);
@@ -1,62 +0,0 @@
1
- /**
2
- * Ref: https://github.com/webpack-contrib/copy-webpack-plugin/blob/master/types/index.d.ts
3
- */
4
- /// <reference types="node" />
5
- export type CopyPluginOptions = {
6
- patterns: Pattern[];
7
- options?: AdditionalOptions | undefined;
8
- };
9
- type ToFunction = (pathData: {
10
- context: string;
11
- absoluteFilename?: string;
12
- }) => string | Promise<string>;
13
- type To = string | ToFunction;
14
- type ToType = 'dir' | 'file' | 'template';
15
- type TransformerFunction = (input: Buffer, absoluteFilename: string) => string | Buffer | Promise<string> | Promise<Buffer>;
16
- type TransformerCacheObject = {
17
- keys: {
18
- [key: string]: any;
19
- };
20
- } | {
21
- keys: (defaultCacheKeys: {
22
- [key: string]: any;
23
- }, absoluteFilename: string) => Promise<{
24
- [key: string]: any;
25
- }>;
26
- };
27
- type TransformerObject = {
28
- transformer: TransformerFunction;
29
- cache?: boolean | TransformerCacheObject | undefined;
30
- };
31
- type Transform = TransformerFunction | TransformerObject;
32
- type Filter = (filepath: string) => boolean | Promise<boolean>;
33
- type TransformAllFunction = (data: {
34
- data: Buffer;
35
- sourceFilename: string;
36
- absoluteFilename: string;
37
- }[]) => string | Buffer | Promise<string> | Promise<Buffer>;
38
- type Info = Record<string, any> | ((item: {
39
- absoluteFilename: string;
40
- sourceFilename: string;
41
- filename: string;
42
- toType: ToType;
43
- }) => Record<string, any>);
44
- type ObjectPattern = {
45
- from: string;
46
- globOptions?: Record<string, any>;
47
- context?: string | undefined;
48
- to?: To | undefined;
49
- toType?: ToType | undefined;
50
- info?: Info | undefined;
51
- filter?: Filter | undefined;
52
- transform?: Transform | undefined;
53
- transformAll?: TransformAllFunction | undefined;
54
- force?: boolean | undefined;
55
- priority?: number | undefined;
56
- noErrorOnMissing?: boolean | undefined;
57
- };
58
- type Pattern = string | ObjectPattern;
59
- type AdditionalOptions = {
60
- concurrency?: number | undefined;
61
- };
62
- export {};
@@ -1,16 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var CopyWebpackPlugin_exports = {};
16
- module.exports = __toCommonJS(CopyWebpackPlugin_exports);
@@ -1,3 +0,0 @@
1
- import type { PugOptions } from '@rsbuild/shared';
2
- import type { webpack } from '../types';
3
- export default function (this: webpack.LoaderContext<PugOptions>, source: string): string;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var pugLoader_exports = {};
30
- __export(pugLoader_exports, {
31
- default: () => pugLoader_default
32
- });
33
- module.exports = __toCommonJS(pugLoader_exports);
34
- var import_pug = __toESM(require("@rsbuild/shared/pug"));
35
- function pugLoader_default(source) {
36
- const options = {
37
- filename: this.resourcePath,
38
- doctype: "html",
39
- compileDebug: false,
40
- ...this.getOptions()
41
- };
42
- const templateCode = import_pug.default.compileClient(source, options);
43
- return `${templateCode}; module.exports = template;`;
44
- }