@rsbuild/core 0.2.7 → 0.2.8

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 (102) hide show
  1. package/dist/cli/commands.d.ts +12 -15
  2. package/dist/cli/commands.js +1 -1
  3. package/dist/cli/config.d.ts +12 -12
  4. package/dist/cli/prepare.d.ts +1 -1
  5. package/dist/cli/prepare.js +1 -1
  6. package/dist/client/hmr/createSocketUrl.d.ts +6 -11
  7. package/dist/client/hmr/index.d.ts +1 -1
  8. package/dist/client/hmr.js +236 -33
  9. package/dist/createRsbuild.d.ts +1 -1
  10. package/dist/index.d.ts +2 -2
  11. package/dist/loadEnv.d.ts +6 -9
  12. package/dist/plugins/asset.d.ts +1 -1
  13. package/dist/plugins/basic.d.ts +1 -1
  14. package/dist/plugins/bundleAnalyzer.d.ts +1 -1
  15. package/dist/plugins/cache.d.ts +1 -1
  16. package/dist/plugins/cleanOutput.d.ts +1 -1
  17. package/dist/plugins/define.d.ts +1 -1
  18. package/dist/plugins/entry.d.ts +1 -1
  19. package/dist/plugins/entry.js +7 -2
  20. package/dist/plugins/externals.d.ts +1 -1
  21. package/dist/plugins/fileSize.d.ts +1 -1
  22. package/dist/plugins/html.d.ts +5 -5
  23. package/dist/plugins/index.d.ts +1 -1
  24. package/dist/plugins/inlineChunk.d.ts +1 -1
  25. package/dist/plugins/moment.d.ts +1 -1
  26. package/dist/plugins/networkPerformance.d.ts +1 -1
  27. package/dist/plugins/nodeAddons.d.ts +1 -1
  28. package/dist/plugins/performance.d.ts +1 -1
  29. package/dist/plugins/preloadOrPrefetch.d.ts +1 -1
  30. package/dist/plugins/splitChunks.d.ts +1 -1
  31. package/dist/plugins/startUrl.d.ts +1 -1
  32. package/dist/plugins/target.d.ts +1 -1
  33. package/dist/plugins/toml.d.ts +1 -1
  34. package/dist/plugins/wasm.d.ts +1 -1
  35. package/dist/plugins/yaml.d.ts +1 -1
  36. package/dist/provider/config.d.ts +1 -1
  37. package/dist/provider/core/build.d.ts +10 -14
  38. package/dist/provider/core/createCompiler.d.ts +4 -7
  39. package/dist/provider/core/createContext.d.ts +1 -1
  40. package/dist/provider/core/createContext.js +1 -1
  41. package/dist/provider/core/devMiddleware.d.ts +1 -1
  42. package/dist/provider/core/initConfigs.d.ts +7 -14
  43. package/dist/provider/core/initHooks.d.ts +18 -18
  44. package/dist/provider/core/initPlugins.d.ts +4 -7
  45. package/dist/provider/core/inspectConfig.d.ts +4 -10
  46. package/dist/provider/core/rspackConfig.d.ts +4 -7
  47. package/dist/provider/core/rspackConfig.js +2 -2
  48. package/dist/provider/css-modules-typescript-pre-loader/index.d.ts +3 -3
  49. package/dist/provider/css-modules-typescript-pre-loader/postcssIcssExtractPlugin.d.ts +5 -5
  50. package/dist/provider/htmlPluginUtil.d.ts +9 -0
  51. package/dist/provider/htmlPluginUtil.js +47 -0
  52. package/dist/provider/index.d.ts +2 -1
  53. package/dist/provider/index.js +5 -0
  54. package/dist/provider/plugins/css.d.ts +7 -19
  55. package/dist/provider/plugins/hmr.d.ts +1 -1
  56. package/dist/provider/plugins/less.d.ts +1 -1
  57. package/dist/provider/plugins/minimize.d.ts +1 -1
  58. package/dist/provider/plugins/output.d.ts +1 -1
  59. package/dist/provider/plugins/progress.d.ts +1 -1
  60. package/dist/provider/plugins/resolve.d.ts +1 -1
  61. package/dist/provider/plugins/rspackProfile.d.ts +1 -1
  62. package/dist/provider/plugins/sass.d.ts +1 -1
  63. package/dist/provider/plugins/server.d.ts +1 -1
  64. package/dist/provider/plugins/swc.d.ts +1 -1
  65. package/dist/provider/plugins/swc.js +29 -37
  66. package/dist/provider/plugins/transition.d.ts +1 -1
  67. package/dist/provider/provider.d.ts +1 -1
  68. package/dist/provider/shared.d.ts +1 -1
  69. package/dist/rspack/HtmlAppIconPlugin.d.ts +8 -8
  70. package/dist/rspack/HtmlAppIconPlugin.js +15 -18
  71. package/dist/rspack/HtmlBasicPlugin.d.ts +8 -8
  72. package/dist/rspack/HtmlBasicPlugin.js +12 -25
  73. package/dist/rspack/HtmlCrossOriginPlugin.d.ts +6 -6
  74. package/dist/rspack/HtmlCrossOriginPlugin.js +13 -26
  75. package/dist/rspack/HtmlNetworkPerformancePlugin.d.ts +5 -5
  76. package/dist/rspack/HtmlNetworkPerformancePlugin.js +2 -12
  77. package/dist/rspack/HtmlNoncePlugin.d.ts +6 -6
  78. package/dist/rspack/HtmlNoncePlugin.js +8 -21
  79. package/dist/rspack/HtmlTagsPlugin.d.ts +13 -13
  80. package/dist/rspack/HtmlTagsPlugin.js +2 -12
  81. package/dist/rspack/InlineChunkHtmlPlugin.d.ts +39 -49
  82. package/dist/rspack/InlineChunkHtmlPlugin.js +2 -12
  83. package/dist/rspack/RemoveCssSourcemapPlugin.d.ts +4 -4
  84. package/dist/rspack/preload/HtmlPreloadOrPrefetchPlugin.d.ts +8 -8
  85. package/dist/rspack/preload/HtmlPreloadOrPrefetchPlugin.js +3 -13
  86. package/dist/rspack/preload/helpers/determineAsValue.d.ts +4 -7
  87. package/dist/rspack/preload/helpers/doesChunkBelongToHtml.d.ts +6 -9
  88. package/dist/rspack/preload/helpers/extractChunks.d.ts +4 -7
  89. package/dist/rspack/preload/helpers/index.d.ts +1 -1
  90. package/dist/rspack/preload/helpers/type.d.ts +10 -10
  91. package/dist/server/compilerDevMiddleware.d.ts +15 -19
  92. package/dist/server/devServer.d.ts +7 -15
  93. package/dist/server/getDevMiddlewares.d.ts +10 -10
  94. package/dist/server/httpServer.d.ts +3 -3
  95. package/dist/server/index.d.ts +1 -1
  96. package/dist/server/middlewares.d.ts +4 -4
  97. package/dist/server/prodServer.d.ts +16 -19
  98. package/dist/server/proxy.d.ts +3 -3
  99. package/dist/server/restart.d.ts +3 -5
  100. package/dist/server/socketServer.d.ts +17 -17
  101. package/dist/types.d.ts +11 -11
  102. package/package.json +3 -3
@@ -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,14 +15,6 @@ 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 HtmlBasicPlugin_exports = {};
30
20
  __export(HtmlBasicPlugin_exports, {
@@ -32,7 +22,7 @@ __export(HtmlBasicPlugin_exports, {
32
22
  hasTitle: () => hasTitle
33
23
  });
34
24
  module.exports = __toCommonJS(HtmlBasicPlugin_exports);
35
- var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
25
+ var import_htmlPluginUtil = require("../provider/htmlPluginUtil");
36
26
  const hasTitle = (html) => html ? /<title/i.test(html) && /<\/title/i.test(html) : false;
37
27
  class HtmlBasicPlugin {
38
28
  constructor(options) {
@@ -64,22 +54,19 @@ class HtmlBasicPlugin {
64
54
  }
65
55
  };
66
56
  compiler.hooks.compilation.tap(this.name, (compilation) => {
67
- import_html_webpack_plugin.default.getHooks(compilation).alterAssetTagGroups.tap(
68
- this.name,
69
- (data) => {
70
- const entryName = data.plugin.options?.entryName;
71
- if (!entryName) {
72
- return data;
73
- }
74
- const { headTags } = data;
75
- const { templateContent } = this.options.info[entryName];
76
- if (!hasTitle(templateContent)) {
77
- addTitleTag(headTags, data.plugin.options?.title);
78
- }
79
- addFavicon(headTags, entryName);
57
+ (0, import_htmlPluginUtil.getHTMLPlugin)().getHooks(compilation).alterAssetTagGroups.tap(this.name, (data) => {
58
+ const entryName = data.plugin.options?.entryName;
59
+ if (!entryName) {
80
60
  return data;
81
61
  }
82
- );
62
+ const { headTags } = data;
63
+ const { templateContent } = this.options.info[entryName];
64
+ if (!hasTitle(templateContent)) {
65
+ addTitleTag(headTags, data.plugin.options?.title);
66
+ }
67
+ addFavicon(headTags, entryName);
68
+ return data;
69
+ });
83
70
  });
84
71
  }
85
72
  }
@@ -1,12 +1,12 @@
1
1
  import type { CrossOrigin } from '@rsbuild/shared';
2
2
  import type { Compiler, RspackPluginInstance } from '@rspack/core';
3
3
  type CrossOriginOptions = {
4
- crossOrigin: CrossOrigin;
4
+ crossOrigin: CrossOrigin;
5
5
  };
6
6
  export declare class HtmlCrossOriginPlugin implements RspackPluginInstance {
7
- readonly name: string;
8
- readonly crossOrigin: CrossOrigin;
9
- constructor(options: CrossOriginOptions);
10
- apply(compiler: Compiler): void;
7
+ readonly name: string;
8
+ readonly crossOrigin: CrossOrigin;
9
+ constructor(options: CrossOriginOptions);
10
+ apply(compiler: Compiler): void;
11
11
  }
12
- export {};
12
+ export {};
@@ -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 HtmlCrossOriginPlugin_exports = {};
30
20
  __export(HtmlCrossOriginPlugin_exports, {
31
21
  HtmlCrossOriginPlugin: () => HtmlCrossOriginPlugin
32
22
  });
33
23
  module.exports = __toCommonJS(HtmlCrossOriginPlugin_exports);
34
- var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
24
+ var import_htmlPluginUtil = require("../provider/htmlPluginUtil");
35
25
  class HtmlCrossOriginPlugin {
36
26
  constructor(options) {
37
27
  const { crossOrigin } = options;
@@ -45,21 +35,18 @@ class HtmlCrossOriginPlugin {
45
35
  return;
46
36
  }
47
37
  compiler.hooks.compilation.tap(this.name, (compilation) => {
48
- import_html_webpack_plugin.default.getHooks(compilation).alterAssetTags.tap(
49
- this.name,
50
- (alterAssetTags) => {
51
- const {
52
- assetTags: { scripts, styles }
53
- } = alterAssetTags;
54
- scripts.forEach(
55
- (script) => script.attributes.crossorigin = this.crossOrigin
56
- );
57
- styles.forEach(
58
- (style) => style.attributes.crossorigin = this.crossOrigin
59
- );
60
- return alterAssetTags;
61
- }
62
- );
38
+ (0, import_htmlPluginUtil.getHTMLPlugin)().getHooks(compilation).alterAssetTags.tap(this.name, (alterAssetTags) => {
39
+ const {
40
+ assetTags: { scripts, styles }
41
+ } = alterAssetTags;
42
+ scripts.forEach(
43
+ (script) => script.attributes.crossorigin = this.crossOrigin
44
+ );
45
+ styles.forEach(
46
+ (style) => style.attributes.crossorigin = this.crossOrigin
47
+ );
48
+ return alterAssetTags;
49
+ });
63
50
  });
64
51
  }
65
52
  }
@@ -2,9 +2,9 @@ import type { Compiler, RspackPluginInstance } from '@rspack/core';
2
2
  import { type Preconnect, type DnsPrefetch } from '@rsbuild/shared';
3
3
  type NetworkPerformanceType = 'preconnect' | 'dnsPrefetch';
4
4
  export declare class HtmlNetworkPerformancePlugin implements RspackPluginInstance {
5
- readonly options: DnsPrefetch | Preconnect;
6
- readonly type: NetworkPerformanceType;
7
- constructor(options: DnsPrefetch | Preconnect, type: NetworkPerformanceType);
8
- apply(compiler: Compiler): void;
5
+ readonly options: DnsPrefetch | Preconnect;
6
+ readonly type: NetworkPerformanceType;
7
+ constructor(options: DnsPrefetch | Preconnect, type: NetworkPerformanceType);
8
+ apply(compiler: Compiler): void;
9
9
  }
10
- export {};
10
+ export {};
@@ -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,14 +15,6 @@ 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 HtmlNetworkPerformancePlugin_exports = {};
30
20
  __export(HtmlNetworkPerformancePlugin_exports, {
@@ -32,7 +22,7 @@ __export(HtmlNetworkPerformancePlugin_exports, {
32
22
  });
33
23
  module.exports = __toCommonJS(HtmlNetworkPerformancePlugin_exports);
34
24
  var import_shared = require("@rsbuild/shared");
35
- var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
25
+ var import_htmlPluginUtil = require("../provider/htmlPluginUtil");
36
26
  function generateLinks(options, type) {
37
27
  const relMap = {
38
28
  preconnect: "preconnect",
@@ -57,7 +47,7 @@ class HtmlNetworkPerformancePlugin {
57
47
  compiler.hooks.compilation.tap(
58
48
  `HTML${this.type}Plugin`,
59
49
  (compilation) => {
60
- import_html_webpack_plugin.default.getHooks(compilation).alterAssetTagGroups.tap(
50
+ (0, import_htmlPluginUtil.getHTMLPlugin)().getHooks(compilation).alterAssetTagGroups.tap(
61
51
  `HTML${(0, import_shared.upperFirst)(this.type)}Plugin`,
62
52
  (htmlPluginData) => {
63
53
  const { headTags } = htmlPluginData;
@@ -1,11 +1,11 @@
1
1
  import type { Compiler, RspackPluginInstance } from '@rspack/core';
2
2
  type NonceOptions = {
3
- nonce: string;
3
+ nonce: string;
4
4
  };
5
5
  export declare class HtmlNoncePlugin implements RspackPluginInstance {
6
- readonly name: string;
7
- readonly nonce: string;
8
- constructor(options: NonceOptions);
9
- apply(compiler: Compiler): void;
6
+ readonly name: string;
7
+ readonly nonce: string;
8
+ constructor(options: NonceOptions);
9
+ apply(compiler: Compiler): void;
10
10
  }
11
- export {};
11
+ export {};
@@ -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 HtmlNoncePlugin_exports = {};
30
20
  __export(HtmlNoncePlugin_exports, {
31
21
  HtmlNoncePlugin: () => HtmlNoncePlugin
32
22
  });
33
23
  module.exports = __toCommonJS(HtmlNoncePlugin_exports);
34
- var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
24
+ var import_htmlPluginUtil = require("../provider/htmlPluginUtil");
35
25
  class HtmlNoncePlugin {
36
26
  constructor(options) {
37
27
  const { nonce } = options;
@@ -43,16 +33,13 @@ class HtmlNoncePlugin {
43
33
  return;
44
34
  }
45
35
  compiler.hooks.compilation.tap(this.name, (compilation) => {
46
- import_html_webpack_plugin.default.getHooks(compilation).alterAssetTags.tap(
47
- this.name,
48
- (alterAssetTags) => {
49
- const {
50
- assetTags: { scripts }
51
- } = alterAssetTags;
52
- scripts.forEach((script) => script.attributes.nonce = this.nonce);
53
- return alterAssetTags;
54
- }
55
- );
36
+ (0, import_htmlPluginUtil.getHTMLPlugin)().getHooks(compilation).alterAssetTags.tap(this.name, (alterAssetTags) => {
37
+ const {
38
+ assetTags: { scripts }
39
+ } = alterAssetTags;
40
+ scripts.forEach((script) => script.attributes.nonce = this.nonce);
41
+ return alterAssetTags;
42
+ });
56
43
  });
57
44
  }
58
45
  }
@@ -1,24 +1,24 @@
1
1
  import type { Compiler } from '@rspack/core';
2
2
  import { type HtmlInjectTag, type HtmlInjectTagDescriptor } from '@rsbuild/shared';
3
3
  export interface HtmlTagsPluginOptions {
4
- hash?: HtmlInjectTag['hash'];
5
- publicPath?: HtmlInjectTag['publicPath'];
6
- append?: HtmlInjectTag['append'];
7
- includes?: string[];
8
- tags?: HtmlInjectTagDescriptor[];
4
+ hash?: HtmlInjectTag['hash'];
5
+ publicPath?: HtmlInjectTag['publicPath'];
6
+ append?: HtmlInjectTag['append'];
7
+ includes?: string[];
8
+ tags?: HtmlInjectTagDescriptor[];
9
9
  }
10
10
  /** @see {@link https://developer.mozilla.org/en-US/docs/Glossary/Void_element} */
11
11
  export declare const VOID_TAGS: string[];
12
12
  /** @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head#see_also} */
13
13
  export declare const HEAD_TAGS: string[];
14
14
  export declare const FILE_ATTRS: {
15
- link: string;
16
- script: string;
15
+ link: string;
16
+ script: string;
17
17
  };
18
18
  export declare class HtmlTagsPlugin {
19
- readonly name: string;
20
- meta: Record<string, string>;
21
- ctx: HtmlTagsPluginOptions;
22
- constructor(opts: HtmlTagsPluginOptions);
23
- apply(compiler: Compiler): void;
24
- }
19
+ readonly name: string;
20
+ meta: Record<string, string>;
21
+ ctx: HtmlTagsPluginOptions;
22
+ constructor(opts: HtmlTagsPluginOptions);
23
+ apply(compiler: Compiler): void;
24
+ }
@@ -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,14 +15,6 @@ 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 HtmlTagsPlugin_exports = {};
30
20
  __export(HtmlTagsPlugin_exports, {
@@ -34,8 +24,8 @@ __export(HtmlTagsPlugin_exports, {
34
24
  VOID_TAGS: () => VOID_TAGS
35
25
  });
36
26
  module.exports = __toCommonJS(HtmlTagsPlugin_exports);
37
- var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
38
27
  var import_shared = require("@rsbuild/shared");
28
+ var import_htmlPluginUtil = require("../provider/htmlPluginUtil");
39
29
  const VOID_TAGS = [
40
30
  "area",
41
31
  "base",
@@ -80,7 +70,7 @@ class HtmlTagsPlugin {
80
70
  apply(compiler) {
81
71
  compiler.hooks.compilation.tap(this.name, (compilation) => {
82
72
  const compilationHash = compilation.hash || "";
83
- const hooks = import_html_webpack_plugin.default.getHooks(compilation);
73
+ const hooks = (0, import_htmlPluginUtil.getHTMLPlugin)().getHooks(compilation);
84
74
  hooks.alterAssetTagGroups.tap(this.name, (params) => {
85
75
  const includesCurrentFile = !this.ctx.includes || this.ctx.includes.includes(params.outputName);
86
76
  if (!includesCurrentFile || !this.ctx.tags?.length) {
@@ -1,56 +1,46 @@
1
1
  import { type InlineChunkTest } from '@rsbuild/shared';
2
2
  import type { Compiler, Compilation } from '@rspack/core';
3
- import HtmlWebpackPlugin from 'html-webpack-plugin';
4
3
  import type { HtmlTagObject } from 'html-webpack-plugin';
5
4
  export type InlineChunkHtmlPluginOptions = {
6
- styleTests: InlineChunkTest[];
7
- scriptTests: InlineChunkTest[];
8
- distPath: {
9
- js?: string;
10
- css?: string;
11
- };
5
+ styleTests: InlineChunkTest[];
6
+ scriptTests: InlineChunkTest[];
7
+ distPath: {
8
+ js?: string;
9
+ css?: string;
10
+ };
12
11
  };
13
12
  export declare class InlineChunkHtmlPlugin {
14
- name: string;
15
- styleTests: InlineChunkTest[];
16
- scriptTests: InlineChunkTest[];
17
- distPath: InlineChunkHtmlPluginOptions['distPath'];
18
- inlinedAssets: Set<string>;
19
- constructor({
20
- styleTests,
21
- scriptTests,
22
- distPath
23
- }: InlineChunkHtmlPluginOptions);
24
- /**
25
- * If we inlined the chunk to HTML,we should update the value of sourceMappingURL,
26
- * because the relative path of source code has been changed.
27
- * @param source
28
- */
29
- updateSourceMappingURL({
30
- source,
31
- compilation,
32
- publicPath,
33
- type
34
- }: {
35
- source: string;
36
- compilation: Compilation;
37
- publicPath: string;
38
- type: 'js' | 'css';
39
- }): string;
40
- matchTests(name: string, source: string, tests: InlineChunkTest[]): boolean;
41
- getInlinedScriptTag(publicPath: string, tag: HtmlTagObject, compilation: Compilation): HtmlWebpackPlugin.HtmlTagObject | {
42
- tagName: string;
43
- innerHTML: string;
44
- attributes: {
45
- [x: string]: string | boolean | null | undefined;
13
+ name: string;
14
+ styleTests: InlineChunkTest[];
15
+ scriptTests: InlineChunkTest[];
16
+ distPath: InlineChunkHtmlPluginOptions['distPath'];
17
+ inlinedAssets: Set<string>;
18
+ constructor({ styleTests, scriptTests, distPath, }: InlineChunkHtmlPluginOptions);
19
+ /**
20
+ * If we inlined the chunk to HTML,we should update the value of sourceMappingURL,
21
+ * because the relative path of source code has been changed.
22
+ * @param source
23
+ */
24
+ updateSourceMappingURL({ source, compilation, publicPath, type, }: {
25
+ source: string;
26
+ compilation: Compilation;
27
+ publicPath: string;
28
+ type: 'js' | 'css';
29
+ }): string;
30
+ matchTests(name: string, source: string, tests: InlineChunkTest[]): boolean;
31
+ getInlinedScriptTag(publicPath: string, tag: HtmlTagObject, compilation: Compilation): HtmlTagObject | {
32
+ tagName: string;
33
+ innerHTML: string;
34
+ attributes: {
35
+ [x: string]: string | boolean | null | undefined;
36
+ };
37
+ closeTag: boolean;
38
+ };
39
+ getInlinedCSSTag(publicPath: string, tag: HtmlTagObject, compilation: Compilation): HtmlTagObject | {
40
+ tagName: string;
41
+ innerHTML: string;
42
+ closeTag: boolean;
46
43
  };
47
- closeTag: boolean;
48
- };
49
- getInlinedCSSTag(publicPath: string, tag: HtmlTagObject, compilation: Compilation): HtmlWebpackPlugin.HtmlTagObject | {
50
- tagName: string;
51
- innerHTML: string;
52
- closeTag: boolean;
53
- };
54
- getInlinedTag(publicPath: string, tag: HtmlTagObject, compilation: Compilation): HtmlWebpackPlugin.HtmlTagObject;
55
- apply(compiler: Compiler): void;
56
- }
44
+ getInlinedTag(publicPath: string, tag: HtmlTagObject, compilation: Compilation): HtmlTagObject;
45
+ apply(compiler: Compiler): void;
46
+ }
@@ -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,14 +15,6 @@ 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 InlineChunkHtmlPlugin_exports = {};
30
20
  __export(InlineChunkHtmlPlugin_exports, {
@@ -33,7 +23,7 @@ __export(InlineChunkHtmlPlugin_exports, {
33
23
  module.exports = __toCommonJS(InlineChunkHtmlPlugin_exports);
34
24
  var import_path = require("path");
35
25
  var import_shared = require("@rsbuild/shared");
36
- var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
26
+ var import_htmlPluginUtil = require("../provider/htmlPluginUtil");
37
27
  class InlineChunkHtmlPlugin {
38
28
  constructor({
39
29
  styleTests,
@@ -160,7 +150,7 @@ class InlineChunkHtmlPlugin {
160
150
  compiler.hooks.compilation.tap(this.name, (compilation) => {
161
151
  const publicPath = (0, import_shared.getPublicPathFromCompiler)(compiler);
162
152
  const tagFunction = (tag) => this.getInlinedTag(publicPath, tag, compilation);
163
- const hooks = import_html_webpack_plugin.default.getHooks(compilation);
153
+ const hooks = (0, import_htmlPluginUtil.getHTMLPlugin)().getHooks(compilation);
164
154
  hooks.alterAssetTagGroups.tap(this.name, (assets) => {
165
155
  assets.headTags = assets.headTags.map(tagFunction);
166
156
  assets.bodyTags = assets.bodyTags.map(tagFunction);
@@ -1,6 +1,6 @@
1
1
  import type { Compiler } from '@rspack/core';
2
2
  export declare class RemoveCssSourcemapPlugin {
3
- name: string;
4
- constructor();
5
- apply(compiler: Compiler): void;
6
- }
3
+ name: string;
4
+ constructor();
5
+ apply(compiler: Compiler): void;
6
+ }
@@ -15,15 +15,15 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import type { Compiler, RspackPluginInstance } from '@rspack/core';
18
- import HtmlWebpackPlugin from 'html-webpack-plugin';
18
+ import type HtmlWebpackPlugin from 'html-webpack-plugin';
19
19
  import { type PreloadOrPreFetchOption } from '@rsbuild/shared';
20
20
  type LinkType = 'preload' | 'prefetch';
21
21
  export declare class HtmlPreloadOrPrefetchPlugin implements RspackPluginInstance {
22
- readonly options: PreloadOrPreFetchOption;
23
- resourceHints: HtmlWebpackPlugin.HtmlTagObject[];
24
- type: LinkType;
25
- HTMLCount: number;
26
- constructor(options: true | PreloadOrPreFetchOption, type: LinkType, HTMLCount: number);
27
- apply(compiler: Compiler): void;
22
+ readonly options: PreloadOrPreFetchOption;
23
+ resourceHints: HtmlWebpackPlugin.HtmlTagObject[];
24
+ type: LinkType;
25
+ HTMLCount: number;
26
+ constructor(options: true | PreloadOrPreFetchOption, type: LinkType, HTMLCount: number);
27
+ apply(compiler: Compiler): void;
28
28
  }
29
- export {};
29
+ export {};
@@ -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,23 +15,15 @@ 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 HtmlPreloadOrPrefetchPlugin_exports = {};
30
20
  __export(HtmlPreloadOrPrefetchPlugin_exports, {
31
21
  HtmlPreloadOrPrefetchPlugin: () => HtmlPreloadOrPrefetchPlugin
32
22
  });
33
23
  module.exports = __toCommonJS(HtmlPreloadOrPrefetchPlugin_exports);
34
- var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
35
24
  var import_shared = require("@rsbuild/shared");
36
25
  var import_helpers = require("./helpers");
26
+ var import_htmlPluginUtil = require("../../provider/htmlPluginUtil");
37
27
  /**
38
28
  * @license
39
29
  * Copyright 2018 Google Inc.
@@ -140,7 +130,7 @@ class HtmlPreloadOrPrefetchPlugin {
140
130
  }
141
131
  apply(compiler) {
142
132
  compiler.hooks.compilation.tap(this.constructor.name, (compilation) => {
143
- import_html_webpack_plugin.default.getHooks(compilation).beforeAssetTagGeneration.tap(
133
+ (0, import_htmlPluginUtil.getHTMLPlugin)().getHooks(compilation).beforeAssetTagGeneration.tap(
144
134
  `HTML${(0, import_shared.upperFirst)(this.type)}Plugin`,
145
135
  (htmlPluginData) => {
146
136
  this.resourceHints = generateLinks(
@@ -153,7 +143,7 @@ class HtmlPreloadOrPrefetchPlugin {
153
143
  return htmlPluginData;
154
144
  }
155
145
  );
156
- import_html_webpack_plugin.default.getHooks(compilation).alterAssetTags.tap(
146
+ (0, import_htmlPluginUtil.getHTMLPlugin)().getHooks(compilation).alterAssetTags.tap(
157
147
  `HTML${(0, import_shared.upperFirst)(this.type)}Plugin`,
158
148
  (htmlPluginData) => {
159
149
  if (this.resourceHints) {
@@ -16,10 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
  import type { As } from './type';
19
- export declare function determineAsValue({
20
- href,
21
- file
22
- }: {
23
- href: string;
24
- file: string;
25
- }): As;
19
+ export declare function determineAsValue({ href, file, }: {
20
+ href: string;
21
+ file: string;
22
+ }): As;
@@ -19,13 +19,10 @@ import type { Chunk } from 'webpack';
19
19
  import type { PreloadOrPreFetchOption } from '@rsbuild/shared';
20
20
  import { BeforeAssetTagGenerationHtmlPluginData } from './type';
21
21
  interface DoesChunkBelongToHtmlOptions {
22
- chunk: Chunk;
23
- compilation?: Compilation;
24
- htmlPluginData: BeforeAssetTagGenerationHtmlPluginData;
25
- pluginOptions?: PreloadOrPreFetchOption;
22
+ chunk: Chunk;
23
+ compilation?: Compilation;
24
+ htmlPluginData: BeforeAssetTagGenerationHtmlPluginData;
25
+ pluginOptions?: PreloadOrPreFetchOption;
26
26
  }
27
- export declare function doesChunkBelongToHtml({
28
- chunk,
29
- htmlPluginData
30
- }: DoesChunkBelongToHtmlOptions): boolean;
31
- export {};
27
+ export declare function doesChunkBelongToHtml({ chunk, htmlPluginData, }: DoesChunkBelongToHtmlOptions): boolean;
28
+ export {};
@@ -18,11 +18,8 @@ import { Chunk, Compilation } from 'webpack';
18
18
  import type { PreloadIncludeType } from '@rsbuild/shared';
19
19
  export type ChunkGroup = Compilation['chunkGroups'][0];
20
20
  interface ExtractChunks {
21
- compilation: Compilation;
22
- includeType?: PreloadIncludeType;
21
+ compilation: Compilation;
22
+ includeType?: PreloadIncludeType;
23
23
  }
24
- export declare function extractChunks({
25
- compilation,
26
- includeType
27
- }: ExtractChunks): Chunk[];
28
- export {};
24
+ export declare function extractChunks({ compilation, includeType, }: ExtractChunks): Chunk[];
25
+ export {};