@esm.sh/import-map 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/dist/index.mjs +0 -3
- package/package.json +1 -1
- package/types/index.d.ts +0 -3
package/README.md
CHANGED
|
@@ -75,9 +75,9 @@ const im = parseFromHtml(`<script type="importmap">
|
|
|
75
75
|
|
|
76
76
|
> Note: This function requires a browser environment.
|
|
77
77
|
|
|
78
|
-
### `
|
|
78
|
+
### `ImportMap.addImport(specifier: string, noSRI?: boolean)`
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
The `addImport` method fetches package metadata from [esm.sh](https://esm.sh) CDN and adds an entry (plus relevant deps) to the map.
|
|
81
81
|
|
|
82
82
|
Supported specifiers include:
|
|
83
83
|
|
|
@@ -99,9 +99,9 @@ const im = new ImportMap();
|
|
|
99
99
|
await im.addImport("react-dom@19/client");
|
|
100
100
|
```
|
|
101
101
|
|
|
102
|
-
### `
|
|
102
|
+
### `ImportMap.resolve(specifier: string, containingFile: string)`
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
The `resolve` method resolves a specifier using import-map matching rules:
|
|
105
105
|
|
|
106
106
|
```ts
|
|
107
107
|
const [url, ok] = im.resolve("react", "file:///app/main.ts");
|
|
@@ -109,9 +109,9 @@ const [url, ok] = im.resolve("react", "file:///app/main.ts");
|
|
|
109
109
|
|
|
110
110
|
Returns `[resolvedUrl, true]` when matched, otherwise `[originalSpecifier, false]`.
|
|
111
111
|
|
|
112
|
-
### `
|
|
112
|
+
### `ImportMap.raw`
|
|
113
113
|
|
|
114
|
-
`raw` getter returns a clean, key-ordered import-map object (`ImportMapRaw`):
|
|
114
|
+
The `raw` getter returns a clean, key-ordered import-map object (`ImportMapRaw`):
|
|
115
115
|
|
|
116
116
|
```ts
|
|
117
117
|
const raw = im.raw;
|
|
@@ -125,7 +125,7 @@ const raw = im.raw;
|
|
|
125
125
|
|
|
126
126
|
### `isSupportImportMap()`
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
function `isSupportImportMap()` returns whether the current browser supports import maps.
|
|
129
129
|
|
|
130
130
|
```ts
|
|
131
131
|
import { isSupportImportMap } from "@esm.sh/import-map";
|
package/dist/index.mjs
CHANGED
|
@@ -476,9 +476,6 @@ var ImportMap = class {
|
|
|
476
476
|
get baseURL() {
|
|
477
477
|
return this.#baseURL;
|
|
478
478
|
}
|
|
479
|
-
get isBlank() {
|
|
480
|
-
return Object.keys(this.imports).length === 0 && Object.keys(this.scopes).length === 0;
|
|
481
|
-
}
|
|
482
479
|
get raw() {
|
|
483
480
|
const json = {};
|
|
484
481
|
const config = sortStringMap(this.config);
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -42,9 +42,6 @@ export class ImportMap {
|
|
|
42
42
|
/** The base URL of the import map. */
|
|
43
43
|
get baseURL(): URL;
|
|
44
44
|
|
|
45
|
-
/** Check if the import map is blank. */
|
|
46
|
-
get isBlank(): boolean;
|
|
47
|
-
|
|
48
45
|
/** Return a clean, key-ordered raw import map object. */
|
|
49
46
|
get raw(): ImportMapRaw;
|
|
50
47
|
|