Skip to content

Commit

Permalink
fix: compatible static methods with html-webpack-plugin 5.6.0 (#8157)
Browse files Browse the repository at this point in the history
* fix: compatible static methods with html-webpack-plugin 5.6.0

* fix: compatible static methods with html-webpack-plugin 5.6.0

* fix: compatible static methods with html-webpack-plugin 5.6.0
  • Loading branch information
LingyuCoder authored Oct 17, 2024
1 parent 0017a68 commit 27ec0b5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/rspack/etc/core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2545,9 +2545,11 @@ export type HotUpdateMainFilename = FilenameTemplate;

// @public (undocumented)
export const HtmlRspackPlugin: typeof HtmlRspackPluginImpl & {
getHooks: (compilation: Compilation) => HtmlRspackPluginHooks;
getCompilationHooks: (compilation: Compilation) => HtmlRspackPluginHooks;
getCompilationOptions: (compilation: Compilation) => HtmlRspackPluginOptions | void;
createHtmlTagObject: (tagName: string, attributes?: Record<string, string | boolean>, innerHTML?: string | undefined) => JsHtmlPluginTag;
version: number;
};

// @public (undocumented)
Expand Down
11 changes: 10 additions & 1 deletion packages/rspack/src/builtin-plugin/HtmlRspackPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ const compilationOptionsMap: WeakMap<Compilation, HtmlRspackPluginOptions> =
new WeakMap();

const HtmlRspackPlugin = HtmlRspackPluginImpl as typeof HtmlRspackPluginImpl & {
/**
* @deprecated Use `getCompilationHooks` instead.
*/
getHooks: (compilation: Compilation) => HtmlRspackPluginHooks;
getCompilationHooks: (compilation: Compilation) => HtmlRspackPluginHooks;
getCompilationOptions: (
compilation: Compilation
Expand All @@ -387,6 +391,7 @@ const HtmlRspackPlugin = HtmlRspackPluginImpl as typeof HtmlRspackPluginImpl & {
attributes?: Record<string, string | boolean>,
innerHTML?: string | undefined
) => JsHtmlPluginTag;
version: number;
};

const voidTags = [
Expand Down Expand Up @@ -429,7 +434,9 @@ HtmlRspackPlugin.getCompilationOptions = (compilation: Compilation) => {
return compilationOptionsMap.get(compilation);
};

HtmlRspackPlugin.getCompilationHooks = (compilation: Compilation) => {
HtmlRspackPlugin.getHooks = HtmlRspackPlugin.getCompilationHooks = (
compilation: Compilation
) => {
if (!(compilation instanceof Compilation)) {
throw new TypeError(
"The 'compilation' argument must be an instance of Compilation"
Expand All @@ -454,4 +461,6 @@ HtmlRspackPlugin.getCompilationHooks = (compilation: Compilation) => {
return hooks;
};

HtmlRspackPlugin.version = 5;

export { HtmlRspackPlugin };

2 comments on commit 27ec0b5

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

Name Base (2024-10-17 1626c72) Current Change
10000_development-mode + exec 2.18 s ± 39 ms 2.13 s ± 31 ms -2.32 %
10000_development-mode_hmr + exec 670 ms ± 28 ms 667 ms ± 7.8 ms -0.49 %
10000_production-mode + exec 2.69 s ± 39 ms 2.68 s ± 47 ms -0.68 %
arco-pro_development-mode + exec 1.82 s ± 80 ms 1.78 s ± 61 ms -2.31 %
arco-pro_development-mode_hmr + exec 426 ms ± 1.4 ms 426 ms ± 0.97 ms -0.09 %
arco-pro_production-mode + exec 3.32 s ± 57 ms 3.16 s ± 62 ms -4.99 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.33 s ± 92 ms 3.2 s ± 81 ms -3.81 %
threejs_development-mode_10x + exec 1.6 s ± 16 ms 1.61 s ± 9.1 ms +0.44 %
threejs_development-mode_10x_hmr + exec 760 ms ± 21 ms 758 ms ± 22 ms -0.31 %
threejs_production-mode_10x + exec 4.97 s ± 24 ms 5 s ± 45 ms +0.74 %

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Ran ecosystem CI: Open

suite result
modernjs ✅ success
_selftest ✅ success
rspress ✅ success
rslib ✅ success
rsbuild ✅ success
examples ✅ success
devserver ✅ success

Please sign in to comment.