Skip to content

Commit

Permalink
fix: compatible static methods with html-webpack-plugin 5.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LingyuCoder committed Oct 17, 2024
1 parent 0017a68 commit 4b933a2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/rspack/src/builtin-plugin/HtmlRspackPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ export type HtmlRspackPluginOptions = {

/** Inject a [base](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base) tag */
base?:
| string
| { href?: string; target?: "_self" | "_blank" | "_parent" | "_top" };
| string
| { href?: string; target?: "_self" | "_blank" | "_parent" | "_top" };

/**
* Modern browsers support non blocking javascript loading ('defer') to improve the page startup performance.
Expand Down Expand Up @@ -378,6 +378,7 @@ const compilationOptionsMap: WeakMap<Compilation, HtmlRspackPluginOptions> =
new WeakMap();

const HtmlRspackPlugin = HtmlRspackPluginImpl as typeof HtmlRspackPluginImpl & {
getHooks: (compilation: Compilation) => HtmlRspackPluginHooks;
getCompilationHooks: (compilation: Compilation) => HtmlRspackPluginHooks;
getCompilationOptions: (
compilation: Compilation
Expand All @@ -387,6 +388,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 +431,7 @@ 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 +456,6 @@ HtmlRspackPlugin.getCompilationHooks = (compilation: Compilation) => {
return hooks;
};

HtmlRspackPlugin.version = 5;

export { HtmlRspackPlugin };

0 comments on commit 4b933a2

Please sign in to comment.