@eik/esbuild-plugin 1.1.54 → 2.0.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eik/esbuild-plugin",
3
- "version": "1.1.54",
3
+ "version": "2.0.0",
4
4
  "description": "esbuild plugin for loading import maps from a Eik server and applying the mapping to ECMAScript modules in preparation for upload to the same server.",
5
5
  "type": "module",
6
6
  "main": "./src/plugin.js",
@@ -40,12 +40,12 @@
40
40
  },
41
41
  "homepage": "https://github.com/eik-lib/esbuild-plugin#readme",
42
42
  "devDependencies": {
43
- "@eik/eslint-config": "1.0.12",
43
+ "@eik/eslint-config": "1.0.13",
44
44
  "@eik/prettier-config": "1.0.1",
45
45
  "@eik/semantic-release-config": "1.0.2",
46
46
  "@eik/typescript-config": "1.0.0",
47
47
  "@types/esbuild-plugin-import-map": "0.0.3",
48
- "esbuild": "0.24.2",
48
+ "esbuild": "0.25.3",
49
49
  "eslint": "9.16.0",
50
50
  "fastify": "4.28.1",
51
51
  "npm-run-all2": "5.0.2",
@@ -56,7 +56,10 @@
56
56
  "typescript": "5.7.2"
57
57
  },
58
58
  "dependencies": {
59
- "@eik/common": "5.0.4",
59
+ "@eik/common": "5.1.0",
60
60
  "esbuild-plugin-import-map": "2.1.0"
61
+ },
62
+ "engines": {
63
+ "node": ">=20"
61
64
  }
62
65
  }
package/src/plugin.js CHANGED
@@ -6,33 +6,6 @@ import { helpers } from "@eik/common";
6
6
  * @property {Record<string, string>} imports
7
7
  */
8
8
 
9
- /**
10
- * @param {string[]} urls
11
- * @returns {Promise<ImportMap[]>}
12
- */
13
- const fetchImportMaps = async (urls = []) => {
14
- try {
15
- const maps = urls.map(async (map) => {
16
- const response = await fetch(map);
17
-
18
- if (response.status === 404) {
19
- throw new Error("Import map could not be found on server");
20
- } else if (response.status >= 400 && response.status < 500) {
21
- throw new Error("Server rejected client request");
22
- } else if (response.status >= 500) {
23
- throw new Error("Server error");
24
- }
25
-
26
- return /** @type {Promise<ImportMap>} */ (response.json());
27
- });
28
- return await Promise.all(maps);
29
- } catch (err) {
30
- throw new Error(
31
- `Unable to load import map file from server: ${err.message}`,
32
- );
33
- }
34
- };
35
-
36
9
  /**
37
10
  * @typedef {object} LoadOptions
38
11
  * @property {string} [path=process.cwd()]
@@ -65,9 +38,9 @@ export async function load({
65
38
  const pMaps = Array.isArray(maps) ? maps : [maps];
66
39
  const pUrls = Array.isArray(urls) ? urls : [urls];
67
40
 
68
- const config = await helpers.getDefaults(path);
41
+ const config = helpers.getDefaults(path);
69
42
 
70
- const fetched = await fetchImportMaps([...config.map, ...pUrls]);
43
+ const fetched = await helpers.fetchImportMaps([...config.map, ...pUrls]);
71
44
  const mappings = fetched.concat(pMaps);
72
45
 
73
46
  await importMapPlugin.load(mappings);
package/types/plugin.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @typedef {object} ImportMap
3
+ * @property {Record<string, string>} imports
4
+ */
1
5
  /**
2
6
  * @typedef {object} LoadOptions
3
7
  * @property {string} [path=process.cwd()]
@@ -49,6 +53,9 @@ export function clear(): void;
49
53
  * ```
50
54
  */
51
55
  export function plugin(): Plugin;
56
+ export type ImportMap = {
57
+ imports: Record<string, string>;
58
+ };
52
59
  export type LoadOptions = {
53
60
  path?: string;
54
61
  /**
@@ -64,6 +71,3 @@ export type Plugin = {
64
71
  name: string;
65
72
  setup: (build: any) => void;
66
73
  };
67
- export type ImportMap = {
68
- imports: Record<string, string>;
69
- };