@addfox/rsbuild-plugin-extension-entry 0.1.1-beta.2 → 0.1.1-beta.4
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.
- package/README.md +4 -0
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -8,6 +8,10 @@ const NO_HTML_ENTRIES = new Set([
|
|
|
8
8
|
"background",
|
|
9
9
|
"content"
|
|
10
10
|
]);
|
|
11
|
+
function entryBuildsHtmlPage(entry) {
|
|
12
|
+
if (NO_HTML_ENTRIES.has(entry.name)) return false;
|
|
13
|
+
return true === entry.html || null != entry.htmlPath;
|
|
14
|
+
}
|
|
11
15
|
const SHARED_VENDOR_CHUNK_NAME = "shared-vendor";
|
|
12
16
|
const SHARED_VENDOR_TEST = /[\\/]node_modules[\\/]/;
|
|
13
17
|
const toWebPath = (p)=>p.replace(/\\/g, "/");
|
|
@@ -51,7 +55,7 @@ function buildStandardPaths(entry) {
|
|
|
51
55
|
const isEntryDir = entryDir === entry.name.toLowerCase();
|
|
52
56
|
const isSingleHtml = htmlFile === `${entry.name}.html`;
|
|
53
57
|
htmlPath = isEntryDir ? `${entry.name}/${htmlFile}` : isSingleHtml ? `${entry.name}.html` : `${entry.name}/${htmlFile}`;
|
|
54
|
-
}
|
|
58
|
+
} else if (entryBuildsHtmlPage(entry)) htmlPath = `${entry.name}/index.html`;
|
|
55
59
|
return {
|
|
56
60
|
js: jsPath,
|
|
57
61
|
css: cssPath,
|
|
@@ -102,8 +106,7 @@ function createScriptInjectMap(entries) {
|
|
|
102
106
|
return map;
|
|
103
107
|
}
|
|
104
108
|
function needsHtmlGeneration(entry) {
|
|
105
|
-
|
|
106
|
-
return true === entry.html || null != entry.htmlPath;
|
|
109
|
+
return entryBuildsHtmlPage(entry);
|
|
107
110
|
}
|
|
108
111
|
function buildSourceEntry(entries) {
|
|
109
112
|
const entry = {};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { resolve, basename, extname, dirname, relative } from \"path\";\r\nimport { existsSync } from \"fs\";\r\nimport type { RsbuildConfig, RsbuildPluginAPI } from \"@rsbuild/core\";\r\nimport type { AddfoxResolvedConfig, EntryInfo, ScriptInjectPosition, BrowserTarget } from \"@addfox/core\";\r\nimport { parseAddfoxEntryFromHtml } from \"@addfox/core\";\r\n\r\n/** hotReload: undefined = not set, object = enabled, false = explicitly disabled. Only when false do we disable Rspack HMR. */\r\ntype HotReloadConfig = AddfoxResolvedConfig[\"hotReload\"];\r\n\r\nfunction isHotReloadDisabled(value: HotReloadConfig): boolean {\r\n return value === false;\r\n}\r\n\r\nconst NO_HTML_ENTRIES = new Set([\"background\", \"content\"]);\r\n\r\n/** Chunk name for shared vendor (react, react-dom, webextension-polyfill) to avoid duplicate in popup/options. */\r\nexport const SHARED_VENDOR_CHUNK_NAME = \"shared-vendor\";\r\n\r\n/** Matches node_modules used by HTML entries for a single shared chunk (WXT-style). */\r\nconst SHARED_VENDOR_TEST = /[\\\\/]node_modules[\\\\/]/;\r\n\r\nconst toWebPath = (p: string): string => p.replace(/\\\\/g, \"/\");\r\n\r\ninterface ChunkFilenamePathData {\r\n chunk?: { name?: string; id?: string };\r\n}\r\n\r\ntype ChunkFilenameFn = (pathData: ChunkFilenamePathData) => string;\r\n\r\ninterface EntryOutputMap {\r\n html: Record<string, string>;\r\n js: Record<string, string>;\r\n css: Record<string, string>;\r\n}\r\n\r\ninterface PerformanceConfig {\r\n chunkSplit?: Record<string, unknown>;\r\n}\r\n\r\ninterface WatchFilesOption {\r\n paths?: string | string[];\r\n options?: unknown;\r\n}\r\n\r\ninterface DevConfig {\r\n watchFiles?: WatchFilesOption;\r\n}\r\n\r\ninterface SourceConfig {\r\n entry?: Record<string, unknown>;\r\n}\r\n\r\ninterface HtmlConfig {\r\n template?: unknown;\r\n inject?: unknown;\r\n outputStructure?: string;\r\n}\r\n\r\ninterface ToolsConfig {\r\n htmlPlugin?: unknown;\r\n}\r\n\r\ninterface OutputConfig {\r\n distPath?: Record<string, unknown>;\r\n cleanDistPath?: boolean;\r\n assetPrefix?: string;\r\n copy?: unknown;\r\n}\r\n\r\ninterface TemplateContext {\r\n value: string;\r\n entryName: string;\r\n}\r\n\r\ninterface HtmlPluginContext {\r\n entryName: string;\r\n entryValue: unknown;\r\n}\r\n\r\ninterface Compilation {\r\n fileDependencies: { add: (p: string) => void };\r\n}\r\n\r\ninterface Compiler {\r\n hooks: {\r\n compilation: {\r\n tap: (name: string, fn: (compilation: Compilation) => void) => void;\r\n };\r\n };\r\n}\r\n\r\n/** Check if a plugin is HMR plugin. */\r\nfunction isHmrPlugin(p: unknown): boolean {\r\n if (!p || typeof p !== \"object\") return false;\r\n const obj = p as { constructor?: { name?: string }; name?: string };\r\n return (\r\n obj.constructor?.name === \"HotModuleReplacementPlugin\" ||\r\n obj.name === \"HotModuleReplacementPlugin\"\r\n );\r\n}\r\n\r\n/** Disable Rspack HMR so dist is not filled with *.hot-update.js (extension build watch). */\r\nfunction disableRspackHmrInPlace(config: Record<string, unknown>): void {\r\n const devServer = config.devServer as Record<string, unknown> | undefined;\r\n if (devServer) {\r\n devServer.hot = false;\r\n } else {\r\n config.devServer = { hot: false };\r\n }\r\n\r\n const plugins = config.plugins;\r\n if (Array.isArray(plugins)) {\r\n config.plugins = plugins.filter((p: unknown) => !isHmrPlugin(p));\r\n }\r\n}\r\n\r\n/** For entries with scriptInject: read htmlPath, strip data-addfox-entry script, return content to use as template. */\r\nfunction getStrippedTemplateContent(htmlPath: string): string | undefined {\r\n const parsed = parseAddfoxEntryFromHtml(htmlPath);\r\n return parsed?.strippedHtml;\r\n}\r\n\r\n/** Build output paths for an entry that follows script path. */\r\nfunction buildScriptFollowingPaths(\r\n entry: EntryInfo,\r\n appDir: string\r\n): { js: string; css: string; html?: string } {\r\n const relScript = toWebPath(relative(appDir, entry.scriptPath));\r\n const scriptExt = extname(entry.scriptPath);\r\n const scriptBase = scriptExt ? relScript.slice(0, -scriptExt.length) : relScript;\r\n\r\n return {\r\n js: `${scriptBase}.js`,\r\n css: `${scriptBase}.css`,\r\n html: entry.htmlPath ? toWebPath(relative(appDir, entry.htmlPath)) : undefined,\r\n };\r\n}\r\n\r\n/** Build output paths for a standard entry. */\r\nfunction buildStandardPaths(entry: EntryInfo): { js: string; css: string; html?: string } {\r\n const scriptStem = basename(entry.scriptPath, extname(entry.scriptPath));\r\n const isSingleScript = scriptStem === entry.name;\r\n\r\n const jsPath = isSingleScript ? `${entry.name}.js` : `${entry.name}/index.js`;\r\n const cssPath = isSingleScript ? `${entry.name}.css` : `${entry.name}/index.css`;\r\n\r\n let htmlPath: string | undefined;\r\n if (entry.htmlPath) {\r\n const htmlFile = basename(entry.htmlPath).toLowerCase();\r\n const entryDir = basename(dirname(entry.htmlPath)).toLowerCase();\r\n const isEntryDir = entryDir === entry.name.toLowerCase();\r\n const isSingleHtml = htmlFile === `${entry.name}.html`;\r\n\r\n htmlPath = isEntryDir\r\n ? `${entry.name}/${htmlFile}`\r\n : isSingleHtml\r\n ? `${entry.name}.html`\r\n : `${entry.name}/${htmlFile}`;\r\n }\r\n\r\n return { js: jsPath, css: cssPath, html: htmlPath };\r\n}\r\n\r\n/** Build output path mappings for all entries. */\r\nfunction buildEntryOutputMap(entries: EntryInfo[], appDir: string): EntryOutputMap {\r\n const html: Record<string, string> = {};\r\n const js: Record<string, string> = {};\r\n const css: Record<string, string> = {};\r\n\r\n for (const entry of entries) {\r\n const paths = entry.outputFollowsScriptPath\r\n ? buildScriptFollowingPaths(entry, appDir)\r\n : buildStandardPaths(entry);\r\n\r\n js[entry.name] = paths.js;\r\n css[entry.name] = paths.css;\r\n if (paths.html) {\r\n html[entry.name] = paths.html;\r\n }\r\n }\r\n\r\n return { html, js, css };\r\n}\r\n\r\n/** Build JS chunk filename function for output. */\r\nexport function buildJsChunkFilenameFn(\r\n outputMap: Pick<EntryOutputMap, \"js\">,\r\n entryNames: Set<string>\r\n): ChunkFilenameFn {\r\n return (pathData) => {\r\n const name = pathData.chunk?.name ?? pathData.chunk?.id ?? \"chunk\";\r\n const nameStr = String(name);\r\n\r\n if (nameStr === SHARED_VENDOR_CHUNK_NAME) {\r\n return \"static/js/shared-vendor.js\";\r\n }\r\n if (entryNames.has(nameStr)) {\r\n return outputMap.js[nameStr] ?? `${nameStr}/index.js`;\r\n }\r\n return `static/js/${nameStr}.js`;\r\n };\r\n}\r\n\r\n/** Build CSS chunk filename function for output. */\r\nexport function buildCssChunkFilenameFn(\r\n outputMap: Pick<EntryOutputMap, \"css\">,\r\n entryNames: Set<string>\r\n): ChunkFilenameFn {\r\n return (pathData) => {\r\n const name = pathData.chunk?.name ?? pathData.chunk?.id ?? \"chunk\";\r\n const nameStr = String(name);\r\n\r\n if (entryNames.has(nameStr)) {\r\n return outputMap.css[nameStr] ?? `${nameStr}/index.css`;\r\n }\r\n return `static/css/${nameStr}.css`;\r\n };\r\n}\r\n\r\n/** Create a map of entry names to their HTML template paths. */\r\nfunction createTemplateMap(entries: EntryInfo[]): Record<string, string> {\r\n const map: Record<string, string> = {};\r\n for (const entry of entries) {\r\n if (entry.htmlPath) {\r\n map[entry.name] = entry.htmlPath;\r\n }\r\n }\r\n return map;\r\n}\r\n\r\n/** Create a map of entry names to their script inject positions. */\r\nfunction createScriptInjectMap(entries: EntryInfo[]): Record<string, ScriptInjectPosition> {\r\n const map: Record<string, ScriptInjectPosition> = {};\r\n for (const entry of entries) {\r\n if (entry.scriptInject) {\r\n map[entry.name] = entry.scriptInject;\r\n }\r\n }\r\n return map;\r\n}\r\n\r\n/** Determine if an entry needs HTML generation. */\r\nfunction needsHtmlGeneration(entry: EntryInfo): boolean {\r\n if (NO_HTML_ENTRIES.has(entry.name)) return false;\r\n return entry.html === true || entry.htmlPath != null;\r\n}\r\n\r\n/** Build the source entry configuration. */\r\nfunction buildSourceEntry(entries: EntryInfo[]): Record<string, string | { import: string; html?: boolean }> {\r\n const entry: Record<string, string | { import: string; html?: boolean }> = {};\r\n\r\n for (const e of entries) {\r\n entry[e.name] = needsHtmlGeneration(e)\r\n ? e.scriptPath\r\n : { import: e.scriptPath, html: false };\r\n }\r\n\r\n return entry;\r\n}\r\n\r\nfunction ensurePerformanceConfig(config: RsbuildConfig): PerformanceConfig {\r\n const cfg = config as RsbuildConfig & { performance?: PerformanceConfig };\r\n if (!cfg.performance) {\r\n cfg.performance = {};\r\n }\r\n const perf = cfg.performance;\r\n if (!perf.chunkSplit) {\r\n perf.chunkSplit = {};\r\n }\r\n return perf;\r\n}\r\n\r\n/** Setup chunk split configuration for shared vendor. */\r\nfunction setupChunkSplit(config: RsbuildConfig): void {\r\n const performance = ensurePerformanceConfig(config);\r\n const chunkSplit = performance.chunkSplit as Record<string, unknown>;\r\n const prevOverride = chunkSplit.override as Record<string, unknown> | undefined;\r\n\r\n chunkSplit.override = {\r\n ...prevOverride,\r\n chunks: \"all\",\r\n cacheGroups: {\r\n ...(prevOverride?.cacheGroups as Record<string, unknown> | undefined),\r\n [SHARED_VENDOR_CHUNK_NAME]: {\r\n test: SHARED_VENDOR_TEST,\r\n name: SHARED_VENDOR_CHUNK_NAME,\r\n priority: 30,\r\n enforce: true,\r\n reuseExistingChunk: true,\r\n },\r\n },\r\n };\r\n}\r\n\r\nfunction ensureDevConfig(config: RsbuildConfig): DevConfig {\r\n const cfg = config as RsbuildConfig & { dev?: DevConfig };\r\n if (!cfg.dev) {\r\n cfg.dev = {};\r\n }\r\n return cfg.dev;\r\n}\r\n\r\n/** Setup watch files for HTML templates. */\r\nfunction setupWatchFiles(config: RsbuildConfig, htmlPaths: string[]): void {\r\n if (htmlPaths.length === 0) return;\r\n\r\n const dev = ensureDevConfig(config);\r\n const prevWatch = dev.watchFiles;\r\n const existingPaths = Array.isArray(prevWatch?.paths)\r\n ? prevWatch.paths\r\n : typeof prevWatch?.paths === \"string\"\r\n ? [prevWatch.paths]\r\n : [];\r\n\r\n dev.watchFiles = {\r\n ...(prevWatch && typeof prevWatch === \"object\" ? prevWatch : {}),\r\n paths: [...existingPaths, ...htmlPaths],\r\n };\r\n}\r\n\r\nfunction ensureOutputConfig(config: RsbuildConfig): OutputConfig {\r\n const cfg = config as RsbuildConfig & { output?: OutputConfig };\r\n if (!cfg.output) {\r\n cfg.output = {};\r\n }\r\n return cfg.output;\r\n}\r\n\r\n/** Setup output configuration including dist path and copy rules. */\r\nfunction setupOutputConfig(\r\n config: RsbuildConfig,\r\n resolvedConfig: AddfoxResolvedConfig,\r\n publicDir: string,\r\n distPath: string\r\n): void {\r\n\r\n const output = ensureOutputConfig(config);\r\n\r\n // Use provided distPath (browser-specific, e.g., .addfox/extension/extension-chromium)\r\n const existingDistPath = output.distPath && typeof output.distPath === \"object\"\r\n ? output.distPath\r\n : {};\r\n output.distPath = { ...existingDistPath, root: distPath };\r\n\r\n output.cleanDistPath = output.cleanDistPath ?? true;\r\n output.assetPrefix = output.assetPrefix ?? \"/\";\r\n\r\n // Add public dir copy rule if it exists\r\n if (existsSync(publicDir)) {\r\n const copyRules = Array.isArray(output.copy) ? output.copy : [];\r\n output.copy = [...copyRules, { from: publicDir }];\r\n }\r\n\r\n setupChunkSplit(config);\r\n}\r\n\r\n/** Create the HTML template handler function. */\r\nfunction createTemplateHandler(\r\n templateMap: Record<string, string>,\r\n prevTemplate: unknown\r\n): (ctx: TemplateContext) => string | void {\r\n return (ctx: TemplateContext): string | void => {\r\n if (templateMap[ctx.entryName]) {\r\n return templateMap[ctx.entryName];\r\n }\r\n if (typeof prevTemplate === \"function\") {\r\n return prevTemplate(ctx);\r\n }\r\n return undefined;\r\n };\r\n}\r\n\r\n/** Create the HTML inject position handler. */\r\nfunction createInjectHandler(\r\n scriptInjectMap: Record<string, ScriptInjectPosition>\r\n): ScriptInjectPosition | ((ctx: { entryName: string }) => ScriptInjectPosition) {\r\n const hasInjectMap = Object.keys(scriptInjectMap).length > 0;\r\n\r\n return hasInjectMap\r\n ? ({ entryName }: { entryName: string }) => scriptInjectMap[entryName] ?? \"head\"\r\n : \"head\";\r\n}\r\n\r\n/** Create the HTML plugin configuration handler. */\r\nfunction createHtmlPluginHandler(\r\n outputMap: EntryOutputMap,\r\n entryByName: Map<string, EntryInfo>,\r\n prevHtmlPlugin: unknown\r\n): (htmlConfig: Record<string, unknown>, ctx: HtmlPluginContext) => void {\r\n return (htmlConfig: Record<string, unknown>, ctx: HtmlPluginContext): void => {\r\n // Call previous handler if exists\r\n if (prevHtmlPlugin && typeof prevHtmlPlugin === \"function\") {\r\n prevHtmlPlugin(htmlConfig, ctx);\r\n }\r\n\r\n // Set output filename\r\n if (outputMap.html[ctx.entryName]) {\r\n htmlConfig.filename = outputMap.html[ctx.entryName];\r\n }\r\n\r\n // Apply stripped template content for scriptInject entries\r\n const entry = entryByName.get(ctx.entryName);\r\n if (entry?.scriptInject && entry.htmlPath && existsSync(entry.htmlPath)) {\r\n const content = getStrippedTemplateContent(entry.htmlPath);\r\n if (content) {\r\n htmlConfig.templateContent = content;\r\n }\r\n }\r\n };\r\n}\r\n\r\n/** Create rspack plugin for watching HTML template files. */\r\nfunction createWatchTemplatesPlugin(htmlPaths: string[]): {\r\n name: string;\r\n apply: (compiler: Compiler) => void;\r\n} {\r\n return {\r\n name: \"rsbuild-plugin-extension-entry:watch-templates\",\r\n apply(compiler: Compiler): void {\r\n compiler.hooks.compilation.tap(\"rsbuild-plugin-extension-entry:watch-templates\", (compilation) => {\r\n for (const p of htmlPaths) {\r\n if (existsSync(p)) {\r\n compilation.fileDependencies.add(p);\r\n }\r\n }\r\n });\r\n },\r\n };\r\n}\r\n\r\ninterface WatchOptionsLike {\r\n ignored?: string | RegExp | Array<string | RegExp>;\r\n}\r\n\r\n/** Setup rspack configuration before compiler creation. */\r\nfunction setupRspackConfig(\r\n bundlerConfig: Record<string, unknown>,\r\n context: {\r\n root: string;\r\n outputRoot: string;\r\n outDir: string;\r\n htmlPaths: string[];\r\n outputMap: EntryOutputMap;\r\n entryNames: Set<string>;\r\n /** When true, Rspack HMR is disabled (only when addfox hotReload config is off). */\r\n hotReloadDisabled: boolean;\r\n }\r\n): void {\r\n const { root, outputRoot, outDir, htmlPaths, outputMap, entryNames, hotReloadDisabled } = context;\r\n const distPath = resolve(root, outputRoot, outDir);\r\n\r\n if (hotReloadDisabled) {\r\n disableRspackHmrInPlace(bundlerConfig);\r\n }\r\n\r\n // Add watch templates plugin\r\n if (htmlPaths.length > 0) {\r\n const rspackConfig = bundlerConfig as { plugins?: unknown[] };\r\n rspackConfig.plugins = rspackConfig.plugins ?? [];\r\n rspackConfig.plugins.push(createWatchTemplatesPlugin(htmlPaths));\r\n }\r\n\r\n // Setup watch options to ignore dist path\r\n const watchOpts = (bundlerConfig.watchOptions as WatchOptionsLike | undefined) ?? {};\r\n const existingIgnored = watchOpts.ignored;\r\n const ignoredList: (string | RegExp)[] = Array.isArray(existingIgnored)\r\n ? [...existingIgnored, distPath]\r\n : existingIgnored != null\r\n ? [existingIgnored, distPath]\r\n : [distPath];\r\n bundlerConfig.watchOptions = { ...watchOpts, ignored: ignoredList as string[] };\r\n\r\n // Setup output configuration\r\n if (bundlerConfig.output) {\r\n const output = bundlerConfig.output as Record<string, unknown>;\r\n output.path = distPath;\r\n\r\n const jsChunkName = buildJsChunkFilenameFn(outputMap, entryNames);\r\n const cssChunkName = buildCssChunkFilenameFn(outputMap, entryNames);\r\n\r\n output.filename = jsChunkName as unknown as string;\r\n output.chunkFilename = output.chunkFilename ?? jsChunkName;\r\n output.cssFilename = cssChunkName as unknown as string;\r\n output.cssChunkFilename = output.cssChunkFilename ?? cssChunkName;\r\n output.publicPath = \"/\";\r\n }\r\n\r\n // Setup optimization\r\n if (bundlerConfig.optimization) {\r\n const optimization = bundlerConfig.optimization as Record<string, unknown>;\r\n optimization.runtimeChunk = false;\r\n optimization.splitChunks = optimization.splitChunks ?? {};\r\n\r\n const split = optimization.splitChunks as Record<string, unknown>;\r\n // Only HTML entries participate in splitting so background/content vendor stays in their chunks\r\n split.chunks = typeof split.chunks === \"function\"\r\n ? split.chunks\r\n : (chunk: { name?: string }) => (chunk.name ? !NO_HTML_ENTRIES.has(chunk.name) : true);\r\n }\r\n}\r\n\r\nfunction ensureSourceConfig(config: RsbuildConfig): SourceConfig {\r\n const cfg = config as RsbuildConfig & { source?: SourceConfig };\r\n if (!cfg.source) {\r\n cfg.source = {};\r\n }\r\n return cfg.source;\r\n}\r\n\r\nfunction ensureHtmlConfig(config: RsbuildConfig): HtmlConfig {\r\n const cfg = config as RsbuildConfig & { html?: HtmlConfig };\r\n if (!cfg.html) {\r\n cfg.html = {};\r\n }\r\n return cfg.html;\r\n}\r\n\r\nfunction ensureToolsConfig(config: RsbuildConfig): ToolsConfig {\r\n const cfg = config as RsbuildConfig & { tools?: ToolsConfig };\r\n if (!cfg.tools) {\r\n cfg.tools = {};\r\n }\r\n return cfg.tools;\r\n}\r\n\r\n/** Modify Rsbuild configuration for extension entries. */\r\nfunction modifyRsbuildConfig(\r\n config: RsbuildConfig,\r\n context: {\r\n entry: Record<string, string | { import: string; html?: boolean }>;\r\n templateMap: Record<string, string>;\r\n scriptInjectMap: Record<string, ScriptInjectPosition>;\r\n outputMap: EntryOutputMap;\r\n entryByName: Map<string, EntryInfo>;\r\n htmlPaths: string[];\r\n resolvedConfig: AddfoxResolvedConfig;\r\n publicDir: string;\r\n distPath: string;\r\n }\r\n): void {\r\n const { entry, templateMap, scriptInjectMap, outputMap, entryByName, htmlPaths, resolvedConfig, publicDir, distPath } = context;\r\n\r\n // Setup source entry\r\n const source = ensureSourceConfig(config);\r\n source.entry = { ...(source.entry ?? {}), ...entry };\r\n\r\n // Setup HTML\r\n const html = ensureHtmlConfig(config);\r\n const prevTemplate = html.template;\r\n html.template = createTemplateHandler(templateMap, prevTemplate);\r\n html.inject = createInjectHandler(scriptInjectMap);\r\n html.outputStructure = html.outputStructure ?? \"nested\";\r\n\r\n // Setup HTML plugin\r\n const tools = ensureToolsConfig(config);\r\n const prevHtmlPlugin = tools.htmlPlugin;\r\n tools.htmlPlugin = createHtmlPluginHandler(outputMap, entryByName, prevHtmlPlugin);\r\n\r\n // Watch HTML templates\r\n setupWatchFiles(config, htmlPaths);\r\n\r\n // Setup output (use distPath for browser-specific output)\r\n setupOutputConfig(config, resolvedConfig, publicDir, distPath);\r\n}\r\n\r\n/**\r\n * Main entry plugin function.\r\n * @param resolvedConfig - Resolved Addfox configuration\r\n * @param entries - Discovered entries\r\n * @param distPath - Output directory path (browser-specific, e.g., .addfox/extension/extension-chromium)\r\n */\r\nexport type EntryPluginDevOptions = {\r\n /** When Firefox and hot reload is on, disable Rspack HMR (use web-ext reload instead). */\r\n browser?: BrowserTarget;\r\n};\r\n\r\nfunction shouldDisableRspackHmrForFirefox(\r\n browser: BrowserTarget | undefined,\r\n hotReload: AddfoxResolvedConfig[\"hotReload\"]\r\n): boolean {\r\n if (browser !== \"firefox\") return false;\r\n return hotReload !== false;\r\n}\r\n\r\nexport function entryPlugin(\r\n resolvedConfig: AddfoxResolvedConfig,\r\n entries: EntryInfo[],\r\n distPath: string,\r\n devOptions?: EntryPluginDevOptions\r\n) {\r\n const { outputRoot, root, appDir } = resolvedConfig;\r\n const publicDir = resolve(root, \"public\");\r\n\r\n // Build all lookup maps and configurations\r\n const entry = buildSourceEntry(entries);\r\n const entryNames = new Set(Object.keys(entry));\r\n const templateMap = createTemplateMap(entries);\r\n const scriptInjectMap = createScriptInjectMap(entries);\r\n const outputMap = buildEntryOutputMap(entries, appDir);\r\n const entryByName = new Map(entries.map((e) => [e.name, e]));\r\n const htmlPaths = entries.filter((e) => e.htmlPath).map((e) => e.htmlPath!);\r\n\r\n const modifyConfigContext = {\r\n entry,\r\n templateMap,\r\n scriptInjectMap,\r\n outputMap,\r\n entryByName,\r\n htmlPaths,\r\n resolvedConfig,\r\n publicDir,\r\n distPath,\r\n };\r\n\r\n return {\r\n name: \"rsbuild-plugin-extension-entry\",\r\n setup(api: RsbuildPluginAPI) {\r\n api.modifyRsbuildConfig((config) => {\r\n modifyRsbuildConfig(config, modifyConfigContext);\r\n });\r\n\r\n api.onBeforeCreateCompiler(async ({ bundlerConfigs }) => {\r\n const bundlerConfig = bundlerConfigs[0];\r\n if (!bundlerConfig) return;\r\n\r\n setupRspackConfig(bundlerConfig, {\r\n root,\r\n outputRoot,\r\n outDir: distPath,\r\n htmlPaths,\r\n outputMap,\r\n entryNames,\r\n hotReloadDisabled:\r\n isHotReloadDisabled(resolvedConfig.hotReload) ||\r\n shouldDisableRspackHmrForFirefox(devOptions?.browser, resolvedConfig.hotReload),\r\n });\r\n });\r\n },\r\n };\r\n}\r\n"],"names":["isHotReloadDisabled","value","NO_HTML_ENTRIES","Set","SHARED_VENDOR_CHUNK_NAME","SHARED_VENDOR_TEST","toWebPath","p","isHmrPlugin","obj","disableRspackHmrInPlace","config","devServer","plugins","Array","getStrippedTemplateContent","htmlPath","parsed","parseAddfoxEntryFromHtml","buildScriptFollowingPaths","entry","appDir","relScript","relative","scriptExt","extname","scriptBase","undefined","buildStandardPaths","scriptStem","basename","isSingleScript","jsPath","cssPath","htmlFile","entryDir","dirname","isEntryDir","isSingleHtml","buildEntryOutputMap","entries","html","js","css","paths","buildJsChunkFilenameFn","outputMap","entryNames","pathData","name","nameStr","String","buildCssChunkFilenameFn","createTemplateMap","map","createScriptInjectMap","needsHtmlGeneration","buildSourceEntry","e","ensurePerformanceConfig","cfg","perf","setupChunkSplit","performance","chunkSplit","prevOverride","ensureDevConfig","setupWatchFiles","htmlPaths","dev","prevWatch","existingPaths","ensureOutputConfig","setupOutputConfig","resolvedConfig","publicDir","distPath","output","existingDistPath","existsSync","copyRules","createTemplateHandler","templateMap","prevTemplate","ctx","createInjectHandler","scriptInjectMap","hasInjectMap","Object","entryName","createHtmlPluginHandler","entryByName","prevHtmlPlugin","htmlConfig","content","createWatchTemplatesPlugin","compiler","compilation","setupRspackConfig","bundlerConfig","context","root","outputRoot","outDir","hotReloadDisabled","resolve","rspackConfig","watchOpts","existingIgnored","ignoredList","jsChunkName","cssChunkName","optimization","split","chunk","ensureSourceConfig","ensureHtmlConfig","ensureToolsConfig","modifyRsbuildConfig","source","tools","shouldDisableRspackHmrForFirefox","browser","hotReload","entryPlugin","devOptions","Map","modifyConfigContext","api","bundlerConfigs"],"mappings":";;;AASA,SAASA,oBAAoBC,KAAsB;IACjD,OAAOA,AAAU,UAAVA;AACT;AAEA,MAAMC,kBAAkB,IAAIC,IAAI;IAAC;IAAc;CAAU;AAGlD,MAAMC,2BAA2B;AAGxC,MAAMC,qBAAqB;AAE3B,MAAMC,YAAY,CAACC,IAAsBA,EAAE,OAAO,CAAC,OAAO;AAuE1D,SAASC,YAAYD,CAAU;IAC7B,IAAI,CAACA,KAAK,AAAa,YAAb,OAAOA,GAAgB,OAAO;IACxC,MAAME,MAAMF;IACZ,OACEE,IAAI,WAAW,EAAE,SAAS,gCAC1BA,AAAa,iCAAbA,IAAI,IAAI;AAEZ;AAGA,SAASC,wBAAwBC,MAA+B;IAC9D,MAAMC,YAAYD,OAAO,SAAS;IAClC,IAAIC,WACFA,UAAU,GAAG,GAAG;SAEhBD,OAAO,SAAS,GAAG;QAAE,KAAK;IAAM;IAGlC,MAAME,UAAUF,OAAO,OAAO;IAC9B,IAAIG,MAAM,OAAO,CAACD,UAChBF,OAAO,OAAO,GAAGE,QAAQ,MAAM,CAAC,CAACN,IAAe,CAACC,YAAYD;AAEjE;AAGA,SAASQ,2BAA2BC,QAAgB;IAClD,MAAMC,SAASC,yBAAyBF;IACxC,OAAOC,QAAQ;AACjB;AAGA,SAASE,0BACPC,KAAgB,EAChBC,MAAc;IAEd,MAAMC,YAAYhB,UAAUiB,SAASF,QAAQD,MAAM,UAAU;IAC7D,MAAMI,YAAYC,QAAQL,MAAM,UAAU;IAC1C,MAAMM,aAAaF,YAAYF,UAAU,KAAK,CAAC,GAAG,CAACE,UAAU,MAAM,IAAIF;IAEvE,OAAO;QACL,IAAI,GAAGI,WAAW,GAAG,CAAC;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":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { resolve, basename, extname, dirname, relative } from \"path\";\r\nimport { existsSync } from \"fs\";\r\nimport type { RsbuildConfig, RsbuildPluginAPI } from \"@rsbuild/core\";\r\nimport type { AddfoxResolvedConfig, EntryInfo, ScriptInjectPosition, BrowserTarget } from \"@addfox/core\";\r\nimport { parseAddfoxEntryFromHtml } from \"@addfox/core\";\r\n\r\n/** hotReload: undefined = not set, object = enabled, false = explicitly disabled. Only when false do we disable Rspack HMR. */\r\ntype HotReloadConfig = AddfoxResolvedConfig[\"hotReload\"];\r\n\r\nfunction isHotReloadDisabled(value: HotReloadConfig): boolean {\r\n return value === false;\r\n}\r\n\r\nconst NO_HTML_ENTRIES = new Set([\"background\", \"content\"]);\r\n\r\n/** Same rule as {@link needsHtmlGeneration} — kept near path builders that depend on it. */\r\nfunction entryBuildsHtmlPage(entry: EntryInfo): boolean {\r\n if (NO_HTML_ENTRIES.has(entry.name)) return false;\r\n return entry.html === true || entry.htmlPath != null;\r\n}\r\n\r\n/** Chunk name for shared vendor (react, react-dom, webextension-polyfill) to avoid duplicate in popup/options. */\r\nexport const SHARED_VENDOR_CHUNK_NAME = \"shared-vendor\";\r\n\r\n/** Matches node_modules used by HTML entries for a single shared chunk (WXT-style). */\r\nconst SHARED_VENDOR_TEST = /[\\\\/]node_modules[\\\\/]/;\r\n\r\nconst toWebPath = (p: string): string => p.replace(/\\\\/g, \"/\");\r\n\r\ninterface ChunkFilenamePathData {\r\n chunk?: { name?: string; id?: string };\r\n}\r\n\r\ntype ChunkFilenameFn = (pathData: ChunkFilenamePathData) => string;\r\n\r\ninterface EntryOutputMap {\r\n html: Record<string, string>;\r\n js: Record<string, string>;\r\n css: Record<string, string>;\r\n}\r\n\r\ninterface PerformanceConfig {\r\n chunkSplit?: Record<string, unknown>;\r\n}\r\n\r\ninterface WatchFilesOption {\r\n paths?: string | string[];\r\n options?: unknown;\r\n}\r\n\r\ninterface DevConfig {\r\n watchFiles?: WatchFilesOption;\r\n}\r\n\r\ninterface SourceConfig {\r\n entry?: Record<string, unknown>;\r\n}\r\n\r\ninterface HtmlConfig {\r\n template?: unknown;\r\n inject?: unknown;\r\n outputStructure?: string;\r\n}\r\n\r\ninterface ToolsConfig {\r\n htmlPlugin?: unknown;\r\n}\r\n\r\ninterface OutputConfig {\r\n distPath?: Record<string, unknown>;\r\n cleanDistPath?: boolean;\r\n assetPrefix?: string;\r\n copy?: unknown;\r\n}\r\n\r\ninterface TemplateContext {\r\n value: string;\r\n entryName: string;\r\n}\r\n\r\ninterface HtmlPluginContext {\r\n entryName: string;\r\n entryValue: unknown;\r\n}\r\n\r\ninterface Compilation {\r\n fileDependencies: { add: (p: string) => void };\r\n}\r\n\r\ninterface Compiler {\r\n hooks: {\r\n compilation: {\r\n tap: (name: string, fn: (compilation: Compilation) => void) => void;\r\n };\r\n };\r\n}\r\n\r\n/** Check if a plugin is HMR plugin. */\r\nfunction isHmrPlugin(p: unknown): boolean {\r\n if (!p || typeof p !== \"object\") return false;\r\n const obj = p as { constructor?: { name?: string }; name?: string };\r\n return (\r\n obj.constructor?.name === \"HotModuleReplacementPlugin\" ||\r\n obj.name === \"HotModuleReplacementPlugin\"\r\n );\r\n}\r\n\r\n/** Disable Rspack HMR so dist is not filled with *.hot-update.js (extension build watch). */\r\nfunction disableRspackHmrInPlace(config: Record<string, unknown>): void {\r\n const devServer = config.devServer as Record<string, unknown> | undefined;\r\n if (devServer) {\r\n devServer.hot = false;\r\n } else {\r\n config.devServer = { hot: false };\r\n }\r\n\r\n const plugins = config.plugins;\r\n if (Array.isArray(plugins)) {\r\n config.plugins = plugins.filter((p: unknown) => !isHmrPlugin(p));\r\n }\r\n}\r\n\r\n/** For entries with scriptInject: read htmlPath, strip data-addfox-entry script, return content to use as template. */\r\nfunction getStrippedTemplateContent(htmlPath: string): string | undefined {\r\n const parsed = parseAddfoxEntryFromHtml(htmlPath);\r\n return parsed?.strippedHtml;\r\n}\r\n\r\n/** Build output paths for an entry that follows script path. */\r\nfunction buildScriptFollowingPaths(\r\n entry: EntryInfo,\r\n appDir: string\r\n): { js: string; css: string; html?: string } {\r\n const relScript = toWebPath(relative(appDir, entry.scriptPath));\r\n const scriptExt = extname(entry.scriptPath);\r\n const scriptBase = scriptExt ? relScript.slice(0, -scriptExt.length) : relScript;\r\n\r\n return {\r\n js: `${scriptBase}.js`,\r\n css: `${scriptBase}.css`,\r\n html: entry.htmlPath ? toWebPath(relative(appDir, entry.htmlPath)) : undefined,\r\n };\r\n}\r\n\r\n/** Build output paths for a standard entry. */\r\nfunction buildStandardPaths(entry: EntryInfo): { js: string; css: string; html?: string } {\r\n const scriptStem = basename(entry.scriptPath, extname(entry.scriptPath));\r\n const isSingleScript = scriptStem === entry.name;\r\n\r\n const jsPath = isSingleScript ? `${entry.name}.js` : `${entry.name}/index.js`;\r\n const cssPath = isSingleScript ? `${entry.name}.css` : `${entry.name}/index.css`;\r\n\r\n let htmlPath: string | undefined;\r\n if (entry.htmlPath) {\r\n const htmlFile = basename(entry.htmlPath).toLowerCase();\r\n const entryDir = basename(dirname(entry.htmlPath)).toLowerCase();\r\n const isEntryDir = entryDir === entry.name.toLowerCase();\r\n const isSingleHtml = htmlFile === `${entry.name}.html`;\r\n\r\n htmlPath = isEntryDir\r\n ? `${entry.name}/${htmlFile}`\r\n : isSingleHtml\r\n ? `${entry.name}.html`\r\n : `${entry.name}/${htmlFile}`;\r\n } else if (entryBuildsHtmlPage(entry)) {\r\n // e.g. Vue/React: app/popup/index.ts only — manifest uses popup/index.html (@addfox/core) but\r\n // Rsbuild defaults to popup.html at dist root if filename is unset.\r\n htmlPath = `${entry.name}/index.html`;\r\n }\r\n\r\n return { js: jsPath, css: cssPath, html: htmlPath };\r\n}\r\n\r\n/** Build output path mappings for all entries. */\r\nfunction buildEntryOutputMap(entries: EntryInfo[], appDir: string): EntryOutputMap {\r\n const html: Record<string, string> = {};\r\n const js: Record<string, string> = {};\r\n const css: Record<string, string> = {};\r\n\r\n for (const entry of entries) {\r\n const paths = entry.outputFollowsScriptPath\r\n ? buildScriptFollowingPaths(entry, appDir)\r\n : buildStandardPaths(entry);\r\n\r\n js[entry.name] = paths.js;\r\n css[entry.name] = paths.css;\r\n if (paths.html) {\r\n html[entry.name] = paths.html;\r\n }\r\n }\r\n\r\n return { html, js, css };\r\n}\r\n\r\n/** Build JS chunk filename function for output. */\r\nexport function buildJsChunkFilenameFn(\r\n outputMap: Pick<EntryOutputMap, \"js\">,\r\n entryNames: Set<string>\r\n): ChunkFilenameFn {\r\n return (pathData) => {\r\n const name = pathData.chunk?.name ?? pathData.chunk?.id ?? \"chunk\";\r\n const nameStr = String(name);\r\n\r\n if (nameStr === SHARED_VENDOR_CHUNK_NAME) {\r\n return \"static/js/shared-vendor.js\";\r\n }\r\n if (entryNames.has(nameStr)) {\r\n return outputMap.js[nameStr] ?? `${nameStr}/index.js`;\r\n }\r\n return `static/js/${nameStr}.js`;\r\n };\r\n}\r\n\r\n/** Build CSS chunk filename function for output. */\r\nexport function buildCssChunkFilenameFn(\r\n outputMap: Pick<EntryOutputMap, \"css\">,\r\n entryNames: Set<string>\r\n): ChunkFilenameFn {\r\n return (pathData) => {\r\n const name = pathData.chunk?.name ?? pathData.chunk?.id ?? \"chunk\";\r\n const nameStr = String(name);\r\n\r\n if (entryNames.has(nameStr)) {\r\n return outputMap.css[nameStr] ?? `${nameStr}/index.css`;\r\n }\r\n return `static/css/${nameStr}.css`;\r\n };\r\n}\r\n\r\n/** Create a map of entry names to their HTML template paths. */\r\nfunction createTemplateMap(entries: EntryInfo[]): Record<string, string> {\r\n const map: Record<string, string> = {};\r\n for (const entry of entries) {\r\n if (entry.htmlPath) {\r\n map[entry.name] = entry.htmlPath;\r\n }\r\n }\r\n return map;\r\n}\r\n\r\n/** Create a map of entry names to their script inject positions. */\r\nfunction createScriptInjectMap(entries: EntryInfo[]): Record<string, ScriptInjectPosition> {\r\n const map: Record<string, ScriptInjectPosition> = {};\r\n for (const entry of entries) {\r\n if (entry.scriptInject) {\r\n map[entry.name] = entry.scriptInject;\r\n }\r\n }\r\n return map;\r\n}\r\n\r\n/** Determine if an entry needs HTML generation. */\r\nfunction needsHtmlGeneration(entry: EntryInfo): boolean {\r\n return entryBuildsHtmlPage(entry);\r\n}\r\n\r\n/** Build the source entry configuration. */\r\nfunction buildSourceEntry(entries: EntryInfo[]): Record<string, string | { import: string; html?: boolean }> {\r\n const entry: Record<string, string | { import: string; html?: boolean }> = {};\r\n\r\n for (const e of entries) {\r\n entry[e.name] = needsHtmlGeneration(e)\r\n ? e.scriptPath\r\n : { import: e.scriptPath, html: false };\r\n }\r\n\r\n return entry;\r\n}\r\n\r\nfunction ensurePerformanceConfig(config: RsbuildConfig): PerformanceConfig {\r\n const cfg = config as RsbuildConfig & { performance?: PerformanceConfig };\r\n if (!cfg.performance) {\r\n cfg.performance = {};\r\n }\r\n const perf = cfg.performance;\r\n if (!perf.chunkSplit) {\r\n perf.chunkSplit = {};\r\n }\r\n return perf;\r\n}\r\n\r\n/** Setup chunk split configuration for shared vendor. */\r\nfunction setupChunkSplit(config: RsbuildConfig): void {\r\n const performance = ensurePerformanceConfig(config);\r\n const chunkSplit = performance.chunkSplit as Record<string, unknown>;\r\n const prevOverride = chunkSplit.override as Record<string, unknown> | undefined;\r\n\r\n chunkSplit.override = {\r\n ...prevOverride,\r\n chunks: \"all\",\r\n cacheGroups: {\r\n ...(prevOverride?.cacheGroups as Record<string, unknown> | undefined),\r\n [SHARED_VENDOR_CHUNK_NAME]: {\r\n test: SHARED_VENDOR_TEST,\r\n name: SHARED_VENDOR_CHUNK_NAME,\r\n priority: 30,\r\n enforce: true,\r\n reuseExistingChunk: true,\r\n },\r\n },\r\n };\r\n}\r\n\r\nfunction ensureDevConfig(config: RsbuildConfig): DevConfig {\r\n const cfg = config as RsbuildConfig & { dev?: DevConfig };\r\n if (!cfg.dev) {\r\n cfg.dev = {};\r\n }\r\n return cfg.dev;\r\n}\r\n\r\n/** Setup watch files for HTML templates. */\r\nfunction setupWatchFiles(config: RsbuildConfig, htmlPaths: string[]): void {\r\n if (htmlPaths.length === 0) return;\r\n\r\n const dev = ensureDevConfig(config);\r\n const prevWatch = dev.watchFiles;\r\n const existingPaths = Array.isArray(prevWatch?.paths)\r\n ? prevWatch.paths\r\n : typeof prevWatch?.paths === \"string\"\r\n ? [prevWatch.paths]\r\n : [];\r\n\r\n dev.watchFiles = {\r\n ...(prevWatch && typeof prevWatch === \"object\" ? prevWatch : {}),\r\n paths: [...existingPaths, ...htmlPaths],\r\n };\r\n}\r\n\r\nfunction ensureOutputConfig(config: RsbuildConfig): OutputConfig {\r\n const cfg = config as RsbuildConfig & { output?: OutputConfig };\r\n if (!cfg.output) {\r\n cfg.output = {};\r\n }\r\n return cfg.output;\r\n}\r\n\r\n/** Setup output configuration including dist path and copy rules. */\r\nfunction setupOutputConfig(\r\n config: RsbuildConfig,\r\n resolvedConfig: AddfoxResolvedConfig,\r\n publicDir: string,\r\n distPath: string\r\n): void {\r\n\r\n const output = ensureOutputConfig(config);\r\n\r\n // Use provided distPath (browser-specific, e.g., .addfox/extension/extension-chromium)\r\n const existingDistPath = output.distPath && typeof output.distPath === \"object\"\r\n ? output.distPath\r\n : {};\r\n output.distPath = { ...existingDistPath, root: distPath };\r\n\r\n output.cleanDistPath = output.cleanDistPath ?? true;\r\n output.assetPrefix = output.assetPrefix ?? \"/\";\r\n\r\n // Add public dir copy rule if it exists\r\n if (existsSync(publicDir)) {\r\n const copyRules = Array.isArray(output.copy) ? output.copy : [];\r\n output.copy = [...copyRules, { from: publicDir }];\r\n }\r\n\r\n setupChunkSplit(config);\r\n}\r\n\r\n/** Create the HTML template handler function. */\r\nfunction createTemplateHandler(\r\n templateMap: Record<string, string>,\r\n prevTemplate: unknown\r\n): (ctx: TemplateContext) => string | void {\r\n return (ctx: TemplateContext): string | void => {\r\n if (templateMap[ctx.entryName]) {\r\n return templateMap[ctx.entryName];\r\n }\r\n if (typeof prevTemplate === \"function\") {\r\n return prevTemplate(ctx);\r\n }\r\n return undefined;\r\n };\r\n}\r\n\r\n/** Create the HTML inject position handler. */\r\nfunction createInjectHandler(\r\n scriptInjectMap: Record<string, ScriptInjectPosition>\r\n): ScriptInjectPosition | ((ctx: { entryName: string }) => ScriptInjectPosition) {\r\n const hasInjectMap = Object.keys(scriptInjectMap).length > 0;\r\n\r\n return hasInjectMap\r\n ? ({ entryName }: { entryName: string }) => scriptInjectMap[entryName] ?? \"head\"\r\n : \"head\";\r\n}\r\n\r\n/** Create the HTML plugin configuration handler. */\r\nfunction createHtmlPluginHandler(\r\n outputMap: EntryOutputMap,\r\n entryByName: Map<string, EntryInfo>,\r\n prevHtmlPlugin: unknown\r\n): (htmlConfig: Record<string, unknown>, ctx: HtmlPluginContext) => void {\r\n return (htmlConfig: Record<string, unknown>, ctx: HtmlPluginContext): void => {\r\n // Call previous handler if exists\r\n if (prevHtmlPlugin && typeof prevHtmlPlugin === \"function\") {\r\n prevHtmlPlugin(htmlConfig, ctx);\r\n }\r\n\r\n // Set output filename\r\n if (outputMap.html[ctx.entryName]) {\r\n htmlConfig.filename = outputMap.html[ctx.entryName];\r\n }\r\n\r\n // Apply stripped template content for scriptInject entries\r\n const entry = entryByName.get(ctx.entryName);\r\n if (entry?.scriptInject && entry.htmlPath && existsSync(entry.htmlPath)) {\r\n const content = getStrippedTemplateContent(entry.htmlPath);\r\n if (content) {\r\n htmlConfig.templateContent = content;\r\n }\r\n }\r\n };\r\n}\r\n\r\n/** Create rspack plugin for watching HTML template files. */\r\nfunction createWatchTemplatesPlugin(htmlPaths: string[]): {\r\n name: string;\r\n apply: (compiler: Compiler) => void;\r\n} {\r\n return {\r\n name: \"rsbuild-plugin-extension-entry:watch-templates\",\r\n apply(compiler: Compiler): void {\r\n compiler.hooks.compilation.tap(\"rsbuild-plugin-extension-entry:watch-templates\", (compilation) => {\r\n for (const p of htmlPaths) {\r\n if (existsSync(p)) {\r\n compilation.fileDependencies.add(p);\r\n }\r\n }\r\n });\r\n },\r\n };\r\n}\r\n\r\ninterface WatchOptionsLike {\r\n ignored?: string | RegExp | Array<string | RegExp>;\r\n}\r\n\r\n/** Setup rspack configuration before compiler creation. */\r\nfunction setupRspackConfig(\r\n bundlerConfig: Record<string, unknown>,\r\n context: {\r\n root: string;\r\n outputRoot: string;\r\n outDir: string;\r\n htmlPaths: string[];\r\n outputMap: EntryOutputMap;\r\n entryNames: Set<string>;\r\n /** When true, Rspack HMR is disabled (only when addfox hotReload config is off). */\r\n hotReloadDisabled: boolean;\r\n }\r\n): void {\r\n const { root, outputRoot, outDir, htmlPaths, outputMap, entryNames, hotReloadDisabled } = context;\r\n const distPath = resolve(root, outputRoot, outDir);\r\n\r\n if (hotReloadDisabled) {\r\n disableRspackHmrInPlace(bundlerConfig);\r\n }\r\n\r\n // Add watch templates plugin\r\n if (htmlPaths.length > 0) {\r\n const rspackConfig = bundlerConfig as { plugins?: unknown[] };\r\n rspackConfig.plugins = rspackConfig.plugins ?? [];\r\n rspackConfig.plugins.push(createWatchTemplatesPlugin(htmlPaths));\r\n }\r\n\r\n // Setup watch options to ignore dist path\r\n const watchOpts = (bundlerConfig.watchOptions as WatchOptionsLike | undefined) ?? {};\r\n const existingIgnored = watchOpts.ignored;\r\n const ignoredList: (string | RegExp)[] = Array.isArray(existingIgnored)\r\n ? [...existingIgnored, distPath]\r\n : existingIgnored != null\r\n ? [existingIgnored, distPath]\r\n : [distPath];\r\n bundlerConfig.watchOptions = { ...watchOpts, ignored: ignoredList as string[] };\r\n\r\n // Setup output configuration\r\n if (bundlerConfig.output) {\r\n const output = bundlerConfig.output as Record<string, unknown>;\r\n output.path = distPath;\r\n\r\n const jsChunkName = buildJsChunkFilenameFn(outputMap, entryNames);\r\n const cssChunkName = buildCssChunkFilenameFn(outputMap, entryNames);\r\n\r\n output.filename = jsChunkName as unknown as string;\r\n output.chunkFilename = output.chunkFilename ?? jsChunkName;\r\n output.cssFilename = cssChunkName as unknown as string;\r\n output.cssChunkFilename = output.cssChunkFilename ?? cssChunkName;\r\n output.publicPath = \"/\";\r\n }\r\n\r\n // Setup optimization\r\n if (bundlerConfig.optimization) {\r\n const optimization = bundlerConfig.optimization as Record<string, unknown>;\r\n optimization.runtimeChunk = false;\r\n optimization.splitChunks = optimization.splitChunks ?? {};\r\n\r\n const split = optimization.splitChunks as Record<string, unknown>;\r\n // Only HTML entries participate in splitting so background/content vendor stays in their chunks\r\n split.chunks = typeof split.chunks === \"function\"\r\n ? split.chunks\r\n : (chunk: { name?: string }) => (chunk.name ? !NO_HTML_ENTRIES.has(chunk.name) : true);\r\n }\r\n}\r\n\r\nfunction ensureSourceConfig(config: RsbuildConfig): SourceConfig {\r\n const cfg = config as RsbuildConfig & { source?: SourceConfig };\r\n if (!cfg.source) {\r\n cfg.source = {};\r\n }\r\n return cfg.source;\r\n}\r\n\r\nfunction ensureHtmlConfig(config: RsbuildConfig): HtmlConfig {\r\n const cfg = config as RsbuildConfig & { html?: HtmlConfig };\r\n if (!cfg.html) {\r\n cfg.html = {};\r\n }\r\n return cfg.html;\r\n}\r\n\r\nfunction ensureToolsConfig(config: RsbuildConfig): ToolsConfig {\r\n const cfg = config as RsbuildConfig & { tools?: ToolsConfig };\r\n if (!cfg.tools) {\r\n cfg.tools = {};\r\n }\r\n return cfg.tools;\r\n}\r\n\r\n/** Modify Rsbuild configuration for extension entries. */\r\nfunction modifyRsbuildConfig(\r\n config: RsbuildConfig,\r\n context: {\r\n entry: Record<string, string | { import: string; html?: boolean }>;\r\n templateMap: Record<string, string>;\r\n scriptInjectMap: Record<string, ScriptInjectPosition>;\r\n outputMap: EntryOutputMap;\r\n entryByName: Map<string, EntryInfo>;\r\n htmlPaths: string[];\r\n resolvedConfig: AddfoxResolvedConfig;\r\n publicDir: string;\r\n distPath: string;\r\n }\r\n): void {\r\n const { entry, templateMap, scriptInjectMap, outputMap, entryByName, htmlPaths, resolvedConfig, publicDir, distPath } = context;\r\n\r\n // Setup source entry\r\n const source = ensureSourceConfig(config);\r\n source.entry = { ...(source.entry ?? {}), ...entry };\r\n\r\n // Setup HTML\r\n const html = ensureHtmlConfig(config);\r\n const prevTemplate = html.template;\r\n html.template = createTemplateHandler(templateMap, prevTemplate);\r\n html.inject = createInjectHandler(scriptInjectMap);\r\n html.outputStructure = html.outputStructure ?? \"nested\";\r\n\r\n // Setup HTML plugin\r\n const tools = ensureToolsConfig(config);\r\n const prevHtmlPlugin = tools.htmlPlugin;\r\n tools.htmlPlugin = createHtmlPluginHandler(outputMap, entryByName, prevHtmlPlugin);\r\n\r\n // Watch HTML templates\r\n setupWatchFiles(config, htmlPaths);\r\n\r\n // Setup output (use distPath for browser-specific output)\r\n setupOutputConfig(config, resolvedConfig, publicDir, distPath);\r\n}\r\n\r\n/**\r\n * Main entry plugin function.\r\n * @param resolvedConfig - Resolved Addfox configuration\r\n * @param entries - Discovered entries\r\n * @param distPath - Output directory path (browser-specific, e.g., .addfox/extension/extension-chromium)\r\n */\r\nexport type EntryPluginDevOptions = {\r\n /** When Firefox and hot reload is on, disable Rspack HMR (use web-ext reload instead). */\r\n browser?: BrowserTarget;\r\n};\r\n\r\nfunction shouldDisableRspackHmrForFirefox(\r\n browser: BrowserTarget | undefined,\r\n hotReload: AddfoxResolvedConfig[\"hotReload\"]\r\n): boolean {\r\n if (browser !== \"firefox\") return false;\r\n return hotReload !== false;\r\n}\r\n\r\nexport function entryPlugin(\r\n resolvedConfig: AddfoxResolvedConfig,\r\n entries: EntryInfo[],\r\n distPath: string,\r\n devOptions?: EntryPluginDevOptions\r\n) {\r\n const { outputRoot, root, appDir } = resolvedConfig;\r\n const publicDir = resolve(root, \"public\");\r\n\r\n // Build all lookup maps and configurations\r\n const entry = buildSourceEntry(entries);\r\n const entryNames = new Set(Object.keys(entry));\r\n const templateMap = createTemplateMap(entries);\r\n const scriptInjectMap = createScriptInjectMap(entries);\r\n const outputMap = buildEntryOutputMap(entries, appDir);\r\n const entryByName = new Map(entries.map((e) => [e.name, e]));\r\n const htmlPaths = entries.filter((e) => e.htmlPath).map((e) => e.htmlPath!);\r\n\r\n const modifyConfigContext = {\r\n entry,\r\n templateMap,\r\n scriptInjectMap,\r\n outputMap,\r\n entryByName,\r\n htmlPaths,\r\n resolvedConfig,\r\n publicDir,\r\n distPath,\r\n };\r\n\r\n return {\r\n name: \"rsbuild-plugin-extension-entry\",\r\n setup(api: RsbuildPluginAPI) {\r\n api.modifyRsbuildConfig((config) => {\r\n modifyRsbuildConfig(config, modifyConfigContext);\r\n });\r\n\r\n api.onBeforeCreateCompiler(async ({ bundlerConfigs }) => {\r\n const bundlerConfig = bundlerConfigs[0];\r\n if (!bundlerConfig) return;\r\n\r\n setupRspackConfig(bundlerConfig, {\r\n root,\r\n outputRoot,\r\n outDir: distPath,\r\n htmlPaths,\r\n outputMap,\r\n entryNames,\r\n hotReloadDisabled:\r\n isHotReloadDisabled(resolvedConfig.hotReload) ||\r\n shouldDisableRspackHmrForFirefox(devOptions?.browser, resolvedConfig.hotReload),\r\n });\r\n });\r\n },\r\n };\r\n}\r\n"],"names":["isHotReloadDisabled","value","NO_HTML_ENTRIES","Set","entryBuildsHtmlPage","entry","SHARED_VENDOR_CHUNK_NAME","SHARED_VENDOR_TEST","toWebPath","p","isHmrPlugin","obj","disableRspackHmrInPlace","config","devServer","plugins","Array","getStrippedTemplateContent","htmlPath","parsed","parseAddfoxEntryFromHtml","buildScriptFollowingPaths","appDir","relScript","relative","scriptExt","extname","scriptBase","undefined","buildStandardPaths","scriptStem","basename","isSingleScript","jsPath","cssPath","htmlFile","entryDir","dirname","isEntryDir","isSingleHtml","buildEntryOutputMap","entries","html","js","css","paths","buildJsChunkFilenameFn","outputMap","entryNames","pathData","name","nameStr","String","buildCssChunkFilenameFn","createTemplateMap","map","createScriptInjectMap","needsHtmlGeneration","buildSourceEntry","e","ensurePerformanceConfig","cfg","perf","setupChunkSplit","performance","chunkSplit","prevOverride","ensureDevConfig","setupWatchFiles","htmlPaths","dev","prevWatch","existingPaths","ensureOutputConfig","setupOutputConfig","resolvedConfig","publicDir","distPath","output","existingDistPath","existsSync","copyRules","createTemplateHandler","templateMap","prevTemplate","ctx","createInjectHandler","scriptInjectMap","hasInjectMap","Object","entryName","createHtmlPluginHandler","entryByName","prevHtmlPlugin","htmlConfig","content","createWatchTemplatesPlugin","compiler","compilation","setupRspackConfig","bundlerConfig","context","root","outputRoot","outDir","hotReloadDisabled","resolve","rspackConfig","watchOpts","existingIgnored","ignoredList","jsChunkName","cssChunkName","optimization","split","chunk","ensureSourceConfig","ensureHtmlConfig","ensureToolsConfig","modifyRsbuildConfig","source","tools","shouldDisableRspackHmrForFirefox","browser","hotReload","entryPlugin","devOptions","Map","modifyConfigContext","api","bundlerConfigs"],"mappings":";;;AASA,SAASA,oBAAoBC,KAAsB;IACjD,OAAOA,AAAU,UAAVA;AACT;AAEA,MAAMC,kBAAkB,IAAIC,IAAI;IAAC;IAAc;CAAU;AAGzD,SAASC,oBAAoBC,KAAgB;IAC3C,IAAIH,gBAAgB,GAAG,CAACG,MAAM,IAAI,GAAG,OAAO;IAC5C,OAAOA,AAAe,SAAfA,MAAM,IAAI,IAAaA,AAAkB,QAAlBA,MAAM,QAAQ;AAC9C;AAGO,MAAMC,2BAA2B;AAGxC,MAAMC,qBAAqB;AAE3B,MAAMC,YAAY,CAACC,IAAsBA,EAAE,OAAO,CAAC,OAAO;AAuE1D,SAASC,YAAYD,CAAU;IAC7B,IAAI,CAACA,KAAK,AAAa,YAAb,OAAOA,GAAgB,OAAO;IACxC,MAAME,MAAMF;IACZ,OACEE,IAAI,WAAW,EAAE,SAAS,gCAC1BA,AAAa,iCAAbA,IAAI,IAAI;AAEZ;AAGA,SAASC,wBAAwBC,MAA+B;IAC9D,MAAMC,YAAYD,OAAO,SAAS;IAClC,IAAIC,WACFA,UAAU,GAAG,GAAG;SAEhBD,OAAO,SAAS,GAAG;QAAE,KAAK;IAAM;IAGlC,MAAME,UAAUF,OAAO,OAAO;IAC9B,IAAIG,MAAM,OAAO,CAACD,UAChBF,OAAO,OAAO,GAAGE,QA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,IAAI,mBAAmB,CAAC,CAACpH;gBACvB0G,oBAAoB1G,QAAQmH;YAC9B;YAEAC,IAAI,sBAAsB,CAAC,OAAO,EAAEC,cAAc,EAAE;gBAClD,MAAM9B,gBAAgB8B,cAAc,CAAC,EAAE;gBACvC,IAAI,CAAC9B,eAAe;gBAEpBD,kBAAkBC,eAAe;oBAC/BE;oBACAC;oBACA,QAAQ1B;oBACRR;oBACAtB;oBACAC;oBACA,mBACEhD,oBAAoB2E,eAAe,SAAS,KAC5C+C,iCAAiCI,YAAY,SAASnD,eAAe,SAAS;gBAClF;YACF;QACF;IACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@addfox/rsbuild-plugin-extension-entry",
|
|
3
|
-
"version": "0.1.1-beta.
|
|
3
|
+
"version": "0.1.1-beta.4",
|
|
4
4
|
"description": "Rsbuild plugin: multi-entry, HTML and public copy (internal)",
|
|
5
|
+
"license": "MIT",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"main": "./dist/index.js",
|
|
7
8
|
"module": "./dist/index.js",
|
|
@@ -15,10 +16,11 @@
|
|
|
15
16
|
}
|
|
16
17
|
},
|
|
17
18
|
"files": [
|
|
18
|
-
"dist"
|
|
19
|
+
"dist",
|
|
20
|
+
"LICENSE"
|
|
19
21
|
],
|
|
20
22
|
"dependencies": {
|
|
21
|
-
"@addfox/core": "0.1.1-beta.
|
|
23
|
+
"@addfox/core": "0.1.1-beta.3"
|
|
22
24
|
},
|
|
23
25
|
"devDependencies": {
|
|
24
26
|
"@rspack/core": "^1.7.8",
|