From a122ce4baa8a482496c68c8957a1c8bc68592e5c Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 11 Jul 2024 16:18:33 +0800 Subject: [PATCH 1/2] fix: html-rspack-plugin typo --- packages/core/src/plugins/html.ts | 6 +++--- packages/core/src/types/config/tools.ts | 6 ++---- packages/core/tsconfig.json | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/core/src/plugins/html.ts b/packages/core/src/plugins/html.ts index 64bbe50d80..af3c1bb50d 100644 --- a/packages/core/src/plugins/html.ts +++ b/packages/core/src/plugins/html.ts @@ -16,8 +16,8 @@ import { } from '../helpers'; import type { HtmlInfo, TagConfig } from '../rspack/HtmlBasicPlugin'; import type { - HTMLPluginOptions, HtmlConfig, + HtmlRspackPlugin, ModifyHTMLTagsFn, NormalizedEnvironmentConfig, RsbuildPlugin, @@ -124,7 +124,7 @@ function getTemplateParameters( entryName: string, config: NormalizedEnvironmentConfig, assetPrefix: string, -): HTMLPluginOptions['templateParameters'] { +): HtmlRspackPlugin.Options['templateParameters'] { return (compilation, assets, assetTags, pluginOptions) => { const { mountId, templateParameters } = config.html; const defaultOptions = { @@ -233,7 +233,7 @@ export const pluginHtml = (modifyTagsFn?: ModifyHTMLTagsFn): RsbuildPlugin => ({ const metaTags = getMetaTags(entryName, config, templateContent); - const pluginOptions: HTMLPluginOptions = { + const pluginOptions: HtmlRspackPlugin.Options = { meta: metaTags, chunks, inject, diff --git a/packages/core/src/types/config/tools.ts b/packages/core/src/types/config/tools.ts index 845fa8501a..2cbd08efae 100644 --- a/packages/core/src/types/config/tools.ts +++ b/packages/core/src/types/config/tools.ts @@ -1,6 +1,5 @@ import type { rspack } from '@rspack/core'; import type { SwcLoaderOptions } from '@rspack/core'; -import type { Options as HTMLPluginOptions } from 'html-rspack-plugin'; import type RspackChain from 'rspack-chain'; import type { ModifyBundlerChainUtils, ModifyChainUtils } from '../hooks'; import type { @@ -13,6 +12,7 @@ import type { RspackConfig, RspackRule, } from '../rspack'; +import type { HtmlRspackPlugin } from '../thirdParty'; import type { AutoprefixerOptions, CSSExtractOptions, @@ -29,8 +29,6 @@ import type { } from '../utils'; import type { MaybePromise, OneOrMany } from '../utils'; -export type { HTMLPluginOptions }; - export type ToolsSwcConfig = ConfigChain; export type ToolsAutoprefixerConfig = ConfigChain; @@ -49,7 +47,7 @@ export type ToolsCSSLoaderConfig = ConfigChain; export type ToolsStyleLoaderConfig = ConfigChain; export type ToolsHtmlPluginConfig = ConfigChainWithContext< - HTMLPluginOptions, + HtmlRspackPlugin.Options, { entryName: string; entryValue: (string | string[] | Rspack.EntryDescription)[]; diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json index 06ead791ef..a98a127415 100644 --- a/packages/core/tsconfig.json +++ b/packages/core/tsconfig.json @@ -26,7 +26,7 @@ "rspack-chain": ["./compiled/rspack-chain"], "dotenv-expand": ["./compiled/dotenv-expand"], "webpack-merge": ["./compiled/webpack-merge"], - "http-rspack-plugin": ["./compiled/http-rspack-plugin"], + "html-rspack-plugin": ["./compiled/html-rspack-plugin"], "http-proxy-middleware": ["./compiled/http-proxy-middleware"], "webpack-bundle-analyzer": ["./compiled/webpack-bundle-analyzer"], "http-compression": ["./compiled/http-compression"], From 4b5ba64258cf7543f42af7689589e18b27968319 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 11 Jul 2024 16:19:41 +0800 Subject: [PATCH 2/2] fix: more --- packages/core/src/rspack/HtmlBasicPlugin.ts | 3 ++- packages/core/src/rspack/InlineChunkHtmlPlugin.ts | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/core/src/rspack/HtmlBasicPlugin.ts b/packages/core/src/rspack/HtmlBasicPlugin.ts index 7c2a21135b..24a30217b4 100644 --- a/packages/core/src/rspack/HtmlBasicPlugin.ts +++ b/packages/core/src/rspack/HtmlBasicPlugin.ts @@ -1,5 +1,4 @@ import type { Compilation, Compiler } from '@rspack/core'; -import type { HtmlTagObject } from 'html-rspack-plugin'; import { ensureAssetPrefix, isFunction, partition } from '../helpers'; import { getHTMLPlugin } from '../pluginHelper'; import type { HtmlRspackPlugin } from '../types'; @@ -12,6 +11,8 @@ import type { ModifyHTMLTagsFn, } from '../types'; +type HtmlTagObject = HtmlRspackPlugin.HtmlTagObject; + export type TagConfig = { tags?: HtmlTagDescriptor[]; hash?: HtmlTag['hash']; diff --git a/packages/core/src/rspack/InlineChunkHtmlPlugin.ts b/packages/core/src/rspack/InlineChunkHtmlPlugin.ts index e3002b2834..6c74006aee 100644 --- a/packages/core/src/rspack/InlineChunkHtmlPlugin.ts +++ b/packages/core/src/rspack/InlineChunkHtmlPlugin.ts @@ -7,14 +7,15 @@ */ import { join } from 'node:path'; import type { Compilation, Compiler } from '@rspack/core'; -import type { HtmlTagObject } from 'html-rspack-plugin'; import { addTrailingSlash, getPublicPathFromCompiler, isFunction, } from '../helpers'; import { getHTMLPlugin } from '../pluginHelper'; -import type { InlineChunkTest } from '../types'; +import type { HtmlRspackPlugin, InlineChunkTest } from '../types'; + +type HtmlTagObject = HtmlRspackPlugin.HtmlTagObject; export type InlineChunkHtmlPluginOptions = { styleTests: InlineChunkTest[];