Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add / to PublicPath and browser.runtime.getURL #1171

Merged
merged 6 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/wxt-demo/src/entrypoints/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ export default defineBackground({

console.log(useAppConfig());

// @ts-expect-error: should only accept entrypoints or public assets
browser.runtime.getURL('/');
browser.runtime.getURL('/background.js');
browser.runtime.getURL('/icons/128.png');
browser.runtime.getURL('/example.html#hash');
browser.runtime.getURL('/example.html?query=param');
// @ts-expect-error: should only accept entrypoints or public assets
browser.runtime.getURL('/unknown');
// @ts-expect-error: should only allow hashes/query params on HTML files
browser.runtime.getURL('/icon-128.png?query=param');

Expand Down
1 change: 1 addition & 0 deletions packages/wxt/e2e/tests/typescript-project.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe('TypeScript Project', () => {

declare module "wxt/browser" {
export type PublicPath =
| "/"
| "/options.html"
| "/popup.html"
| "/sandbox.html"
Expand Down
1 change: 1 addition & 0 deletions packages/wxt/src/core/generate-wxt-dir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ async function getPathsDeclarationEntry(
isHtmlEntrypoint(entry) ? '.html' : '.js',
),
)
.concat([''])
.concat(await getPublicFiles());

await wxt.hooks.callHook('prepare:publicPaths', wxt, paths);
Expand Down