-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support embedded import map expansion (#111)
This supports the embedded import map expansion feature from Deno 1.40: https://deno.com/blog/v1.40#simpler-imports-in-denojson
- Loading branch information
1 parent
6c8f898
commit 04feffe
Showing
6 changed files
with
101 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import { | ||
expandEmbeddedImportMap, | ||
NpmSpecifier, | ||
parseJsrSpecifier, | ||
parseNpmSpecifier, | ||
} from "./shared.ts"; | ||
import { assertEquals, assertThrows } from "../test_deps.ts"; | ||
import { JsrSpecifier } from "./shared.ts"; | ||
import { ImportMap } from "../deps.ts"; | ||
|
||
interface NpmSpecifierTestCase extends NpmSpecifier { | ||
specifier: string; | ||
|
@@ -190,3 +192,30 @@ Deno.test("parseJsrSpecifier", async (t) => { | |
}); | ||
} | ||
}); | ||
|
||
Deno.test("expandEmbeddedImportMap", () => { | ||
const importMap: ImportMap = { | ||
imports: { | ||
"@std/path": "jsr:@std/[email protected]", | ||
"preact": "npm:preact@^10.0.0", | ||
"preact2": "npm:/preact2@^10.0.0", | ||
|
||
"preact-render-to-string": "jsr:preact-render-to-string", | ||
"preact-render-to-string/": "jsr:preact-render-to-string2/", | ||
}, | ||
}; | ||
expandEmbeddedImportMap(importMap); | ||
assertEquals(importMap, { | ||
imports: { | ||
"@std/path": "jsr:@std/[email protected]", | ||
"@std/path/": "jsr:/@std/[email protected]/", | ||
"preact": "npm:preact@^10.0.0", | ||
"preact/": "npm:/preact@^10.0.0/", | ||
"preact2": "npm:/preact2@^10.0.0", | ||
"preact2/": "npm:/preact2@^10.0.0/", | ||
|
||
"preact-render-to-string": "jsr:preact-render-to-string", | ||
"preact-render-to-string/": "jsr:preact-render-to-string2/", | ||
}, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"lock": "./jsr/deno.lock", | ||
"imports": { | ||
"@std/path": "jsr:@std/path@^0.213" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "@std/path/join"; |