@eik/esbuild-plugin 1.1.1 → 1.1.2
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 +10 -14
- package/src/plugin.js +14 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eik/esbuild-plugin",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
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",
|
|
@@ -36,22 +36,18 @@
|
|
|
36
36
|
"homepage": "https://github.com/eik-lib/esbuild-plugin#readme",
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@semantic-release/changelog": "6.0.1",
|
|
39
|
-
"@semantic-release/commit-analyzer": "9.0.2",
|
|
40
39
|
"@semantic-release/git": "10.0.1",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"fastify": "3.13.0",
|
|
49
|
-
"semantic-release": "18.0.1",
|
|
50
|
-
"tap": "15.0.5"
|
|
40
|
+
"esbuild": "0.14.13",
|
|
41
|
+
"eslint": "8.7.0",
|
|
42
|
+
"eslint-config-airbnb-base": "15.0.0",
|
|
43
|
+
"eslint-plugin-import": "2.25.4",
|
|
44
|
+
"fastify": "3.27.0",
|
|
45
|
+
"semantic-release": "19.0.2",
|
|
46
|
+
"tap": "15.1.6"
|
|
51
47
|
},
|
|
52
48
|
"dependencies": {
|
|
53
|
-
"@eik/common": "
|
|
49
|
+
"@eik/common": "3.0.0",
|
|
54
50
|
"esbuild-plugin-import-map": "2.1.0",
|
|
55
|
-
"
|
|
51
|
+
"undici": "4.12.2"
|
|
56
52
|
}
|
|
57
53
|
}
|
package/src/plugin.js
CHANGED
|
@@ -1,28 +1,33 @@
|
|
|
1
1
|
/* eslint-disable no-restricted-syntax */
|
|
2
2
|
|
|
3
3
|
import * as importMapPlugin from 'esbuild-plugin-import-map';
|
|
4
|
-
import fetch from 'node-fetch';
|
|
5
4
|
import { helpers } from '@eik/common';
|
|
5
|
+
import { request } from 'undici';
|
|
6
6
|
|
|
7
|
-
async
|
|
7
|
+
const fetchImportMaps = async (urls = []) => {
|
|
8
8
|
try {
|
|
9
|
-
const maps = urls.map(
|
|
10
|
-
|
|
9
|
+
const maps = urls.map(async (map) => {
|
|
10
|
+
const {
|
|
11
|
+
statusCode,
|
|
12
|
+
body,
|
|
13
|
+
} = await request(map, { maxRedirections: 2 });
|
|
14
|
+
|
|
15
|
+
if (statusCode === 404) {
|
|
11
16
|
throw new Error('Import map could not be found on server');
|
|
12
|
-
} else if (
|
|
17
|
+
} else if (statusCode >= 400 && statusCode < 500) {
|
|
13
18
|
throw new Error('Server rejected client request');
|
|
14
|
-
} else if (
|
|
19
|
+
} else if (statusCode >= 500) {
|
|
15
20
|
throw new Error('Server error');
|
|
16
21
|
}
|
|
17
|
-
return
|
|
18
|
-
})
|
|
22
|
+
return body.json();
|
|
23
|
+
});
|
|
19
24
|
return await Promise.all(maps);
|
|
20
25
|
} catch (err) {
|
|
21
26
|
throw new Error(
|
|
22
27
|
`Unable to load import map file from server: ${err.message}`,
|
|
23
28
|
);
|
|
24
29
|
}
|
|
25
|
-
}
|
|
30
|
+
};
|
|
26
31
|
|
|
27
32
|
export async function load({
|
|
28
33
|
path = process.cwd(),
|