Skip to content

Commit

Permalink
Support for relative urls in external maps. Resolves #17 (#18)
Browse files Browse the repository at this point in the history
* Support for relative urls in external maps. Resolves #17

* Use pretty-quick
  • Loading branch information
joeldenning authored Oct 16, 2024
1 parent b97db77 commit 86f5d1c
Show file tree
Hide file tree
Showing 9 changed files with 360 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm run format && pnpm run lint
pnpm exec pretty-quick --staged && pnpm run lint
1 change: 1 addition & 0 deletions fixtures/parent/dot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("parent/dot");
3 changes: 3 additions & 0 deletions fixtures/parent/dot2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "dot";

console.log("parent/dot2");
19 changes: 19 additions & 0 deletions fixtures/relative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script type="injector-importmap" src="./relative.importmap"></script>
</head>
<body>
<script src="../lib/import-map-injector.js"></script>
<script>
window.importMapInjector.initPromise.then(() => {
import("dot");
import("dotdot");
import("slash");
});
</script>
</body>
</html>
12 changes: 12 additions & 0 deletions fixtures/relative.importmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"imports": {
"dot": "./basic.js",
"dotdot": "../fixtures/basic2.js",
"slash": "/fixtures/parent/dot2.js"
},
"scopes": {
"./parent/": {
"dot": "./parent/dot.js"
}
}
}
16 changes: 0 additions & 16 deletions fixtures/server.js

This file was deleted.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"check-format": "prettier --check .",
"watch": "rollup -cw",
"test": "echo \"No tests\"",
"test-serve": "node fixtures/server.js",
"test-serve": "http-server --mimetypes '{ \"application/importmap+json\": [\"importmap\"] }'",
"build": "concurrently pnpm:build:*",
"prepublishOnly": "pnpm run build",
"build:types": "tsc",
Expand All @@ -44,8 +44,10 @@
"eslint": "^8.47.0",
"eslint-config-ts-important-stuff": "^1.1.0",
"express": "^4.18.2",
"http-server": "^14.1.1",
"husky": "^8.0.3",
"prettier": "^3.0.2",
"pretty-quick": "^4.0.0",
"rollup": "^3.28.0",
"typescript": "^5.1.6"
},
Expand Down
Loading

0 comments on commit 86f5d1c

Please sign in to comment.