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: make dynamic imports resolve relative to extension host #37

Merged
merged 1 commit into from
Jul 24, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/index.ts
Expand Up @@ -84,6 +84,13 @@ export default function webExtension(
emitQueue = [];
},

renderDynamicImport() {
return {
left: "import((chrome != null ? chrome : browser).runtime.getURL(",
right: "))",
};
},

resolveId(id) {
const module = getVirtualModule(id);

Expand Down
2 changes: 1 addition & 1 deletion test/fixture/fixtureUtils.ts
Expand Up @@ -58,7 +58,7 @@ export {
export function getExpectedLogFromDynamicChunk(message: string): string {
return `import { _ as __vitePreload } from "../../../../../../preload-helper.js";
(async () => {
const log = await __vitePreload(() => import("../../../../../../log.js"), true ? [] : void 0);
const log = await __vitePreload(() => import((chrome != null ? chrome : browser).runtime.getURL("../../../../../../log.js")), true ? [] : void 0);
log("${message}");
})();
`;
Expand Down
@@ -1,9 +1,3 @@
import {
getExpectedContentLoaderHtml,
getExpectedLogDynamicChunk,
getExpectedLogFromDynamicChunk,
getPreloadHelper,
} from "../../../fixtureUtils";
import { getExpectedCode } from "../shared/contentWithDynamicImport";

const resourceDir =
Expand Down
@@ -1,9 +1,3 @@
import {
getExpectedContentLoaderHtml,
getExpectedLogDynamicChunk,
getExpectedLogFromDynamicChunk,
getPreloadHelper,
} from "../../../fixtureUtils";
import { getExpectedCode } from "../shared/contentWithDynamicImport";

const resourceDir =
Expand Down