Skip to content

Commit

Permalink
Merge pull request #14 from kanamone/fix-a-bug-where-import-map-value…
Browse files Browse the repository at this point in the history
…-is-relative-path

fix a bug where import map value is relative path
  • Loading branch information
himanoa authored Apr 24, 2024
2 parents 3bf25e8 + a62ddcf commit 1049200
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/cuddly-trains-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@kanamone/vite-plugin-dynamic-import-with-import-map": patch
---

Fix a bug where import map value is relative path
2 changes: 1 addition & 1 deletion src/transform-index-html-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe("transformIndexHtmlHandler", () => {
{
tag: "script",
attrs: { type: "importmap" },
children: JSON.stringify({ imports: { foo: "./foo.js" } }),
children: JSON.stringify({ imports: { foo: "/foo.js" } }),
},
],
});
Expand Down
2 changes: 1 addition & 1 deletion src/transform-index-html-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const transformIndexHtmlHandler: (
throw entries.err;
}
const importMap = entries.val.reduce<Record<string, string>>(
(acc, [name, path]) => ({ ...acc, [name]: `./${path}` }),
(acc, [name, path]) => ({ ...acc, [name]: `/${path}` }),
{},
);

Expand Down

0 comments on commit 1049200

Please sign in to comment.