fix(types): include CSS entrypoints in PublicPath generation (#2150)

Co-authored-by: Aaron <aaronklinker1@gmail.com>
This commit is contained in:
Tam Dang
2026-02-22 10:00:58 -05:00
committed by Aaron
parent b4be5feaa6
commit 078fd5990e
2 changed files with 36 additions and 1 deletions
@@ -63,6 +63,29 @@ describe('TypeScript Project', () => {
`);
});
it('should include CSS entrypoints in browser.runtime.getURL paths', async () => {
const project = new TestProject();
project.addFile('entrypoints/unlisted.html', '<html></html>');
project.addFile(
'entrypoints/plain.css',
`body {
color: red;
}`,
);
project.addFile(
'entrypoints/overlay.content.css',
`body {
color: blue;
}`,
);
await project.prepare();
const output = await project.serializeFile('.wxt/types/paths.d.ts');
expect(output).toContain('| "/plain.css"');
expect(output).toContain('| "/content-scripts/overlay.css"');
});
it('should augment the types for browser.i18n.getMessage', async () => {
const project = new TestProject();
project.addFile('entrypoints/unlisted.html', '<html></html>');
+13 -1
View File
@@ -70,7 +70,7 @@ async function getPathsDeclarationEntry(
getEntrypointBundlePath(
entry,
wxt.config.outDir,
isHtmlEntrypoint(entry) ? '.html' : '.js',
getEntrypointPublicExt(entry),
),
)
.concat(await getPublicFiles());
@@ -107,6 +107,18 @@ declare module "wxt/browser" {
};
}
function getEntrypointPublicExt(entry: Entrypoint): '.html' | '.js' | '.css' {
if (isHtmlEntrypoint(entry)) return '.html';
switch (entry.type) {
case 'content-script-style':
case 'unlisted-style':
return '.css';
default:
return '.js';
}
}
async function getI18nDeclarationEntry(): Promise<WxtDirFileEntry> {
const defaultLocale = wxt.config.manifest.default_locale;
const template = `// Generated by wxt