-
-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: link with input HTML map when no importmap.json is present (#2577)
- Loading branch information
1 parent
2755a7b
commit 7e81591
Showing
6 changed files
with
67 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ In some cases there may be ambiguity. For instance, you may want to link the NPM | |
If no modules are given, all "imports" in the initial map are relinked. | ||
|
||
### Options | ||
* `-m, --map` _<file>_ File containing initial import map (default: importmap.json) | ||
* `-m, --map` _<file>_ File containing initial import map (defaults to importmap.json, or the input HTML if linking) | ||
* `-o, --output` _<file>_ File to inject the final import map into (default: --map / importmap.json) | ||
* `-e, --env` <[environments](#environments)> Comma-separated environment condition overrides | ||
* `-r, --resolution` <[resolutions](#resolutions)> Comma-separated dependency resolution overrides | ||
|
@@ -65,7 +65,7 @@ jspm link ./src/cli.js | |
Link an HTML file and update its import map including preload and integrity tags | ||
|
||
``` | ||
jspm link --map index.html --integrity --preload dynamic | ||
jspm link --map index.html --integrity --preload | ||
``` | ||
## install | ||
|
||
|
@@ -79,7 +79,7 @@ Installs packages into an import map, along with all of the dependencies that ar | |
If no packages are provided, all "imports" in the initial map are reinstalled. | ||
|
||
### Options | ||
* `-m, --map` _<file>_ File containing initial import map (default: importmap.json) | ||
* `-m, --map` _<file>_ File containing initial import map (defaults to importmap.json, or the input HTML if linking) | ||
* `-o, --output` _<file>_ File to inject the final import map into (default: --map / importmap.json) | ||
* `-e, --env` <[environments](#environments)> Comma-separated environment condition overrides | ||
* `-r, --resolution` <[resolutions](#resolutions)> Comma-separated dependency resolution overrides | ||
|
@@ -129,7 +129,7 @@ jspm uninstall [flags] [...packages] | |
Uninstalls packages from an import map. The given packages must be valid package specifiers, such as `npm:[email protected]`, `denoland:oak` or `lit`, and must be present in the initial import map. | ||
|
||
### Options | ||
* `-m, --map` _<file>_ File containing initial import map (default: importmap.json) | ||
* `-m, --map` _<file>_ File containing initial import map (defaults to importmap.json, or the input HTML if linking) | ||
* `-o, --output` _<file>_ File to inject the final import map into (default: --map / importmap.json) | ||
* `-e, --env` <[environments](#environments)> Comma-separated environment condition overrides | ||
* `-r, --resolution` <[resolutions](#resolutions)> Comma-separated dependency resolution overrides | ||
|
@@ -161,7 +161,7 @@ jspm update [flags] [...packages] | |
Updates packages in an import map to the latest versions that are compatible with the local `package.json`. The given packages must be valid package specifiers, such as `npm:[email protected]`, `denoland:oak` or `lit`, and must be present in the initial import map. | ||
|
||
### Options | ||
* `-m, --map` _<file>_ File containing initial import map (default: importmap.json) | ||
* `-m, --map` _<file>_ File containing initial import map (defaults to importmap.json, or the input HTML if linking) | ||
* `-o, --output` _<file>_ File to inject the final import map into (default: --map / importmap.json) | ||
* `-e, --env` <[environments](#environments)> Comma-separated environment condition overrides | ||
* `-r, --resolution` <[resolutions](#resolutions)> Comma-separated dependency resolution overrides | ||
|
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 |
---|---|---|
|
@@ -15,3 +15,4 @@ <h1>Test</h1> | |
} | ||
} | ||
</script> | ||
<script type="module" src="app.js"></script> |
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 |
---|---|---|
|
@@ -139,6 +139,18 @@ const scenarios: Scenario[] = [ | |
assert(!map.imports?.["react-dom"]); | ||
}, | ||
}, | ||
|
||
// Support the HTML as being the import map when there is no importmap.json: | ||
{ | ||
files: new Map([...htmlFile, ['app.js', 'import "react"']]), | ||
commands: ["jspm link index.html -o index.html --integrity"], | ||
validationFn: async (files: Map<string, string>) => { | ||
const source = files.get('index.html'); | ||
assert(source.includes('"integrity"')); | ||
assert(source.includes('"./app.js": "sha384-f+bWmpnsmFol2CAkqy/ALGgZsi/mIaBIIhbvFLVuQzt0LNz96zLSDcz1fnF2K22q"')); | ||
assert(source.includes('"https://ga.jspm.io/npm:[email protected]/dev.index.js": "sha384-eSJrEMXot96AKVLYz8C1nY3CpLMuBMHIAiYhs7vfM09SQo+5X+1w6t3Ldpnw+VWU"')) | ||
}, | ||
}, | ||
]; | ||
|
||
await runScenarios(scenarios); |