@eik/rollup-plugin 4.0.7 → 4.0.11

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/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ ## [4.0.11](https://github.com/eik-lib/rollup-plugin/compare/v4.0.10...v4.0.11) (2022-01-13)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Fix node-fetch 3.x regression in CJS build ([#70](https://github.com/eik-lib/rollup-plugin/issues/70)) ([16b71c9](https://github.com/eik-lib/rollup-plugin/commit/16b71c97c08c6840ffd6df3b9d1520037dfe3257))
7
+
8
+ ## [4.0.10](https://github.com/eik-lib/rollup-plugin/compare/v4.0.9...v4.0.10) (2022-01-11)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update dependency node-fetch to v3 ([#57](https://github.com/eik-lib/rollup-plugin/issues/57)) ([fd40897](https://github.com/eik-lib/rollup-plugin/commit/fd408975ebcb8c146cf61337974d4314c2019895))
14
+
15
+ ## [4.0.9](https://github.com/eik-lib/rollup-plugin/compare/v4.0.8...v4.0.9) (2021-10-31)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **deps:** update dependency node-fetch to v2.6.6 ([d3c2c74](https://github.com/eik-lib/rollup-plugin/commit/d3c2c74e5737c82033f2999d494f17b79555b52f))
21
+
22
+ ## [4.0.8](https://github.com/eik-lib/rollup-plugin/compare/v4.0.7...v4.0.8) (2021-09-22)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **deps:** update dependency node-fetch to v2.6.5 ([16e4dd9](https://github.com/eik-lib/rollup-plugin/commit/16e4dd9ce160acacda91d70a248230428e1361c0))
28
+
1
29
  ## [4.0.7](https://github.com/eik-lib/rollup-plugin/compare/v4.0.6...v4.0.7) (2021-09-21)
2
30
 
3
31
 
package/dist/plugin.cjs CHANGED
@@ -2,33 +2,34 @@
2
2
 
3
3
  var rollupPluginImportMap = require('rollup-plugin-import-map');
4
4
  var common = require('@eik/common');
5
- var fetch = require('node-fetch');
6
-
7
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
-
9
- var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch);
5
+ var undici = require('undici');
10
6
 
11
7
  /* eslint-disable no-restricted-syntax */
12
8
 
13
- async function fetchImportMaps(urls = []) {
9
+ const fetchImportMaps = async (urls = []) => {
14
10
  try {
15
- const maps = urls.map((map) => fetch__default['default'](map).then((result) => {
16
- if (result.status === 404) {
11
+ const maps = urls.map(async (map) => {
12
+ const {
13
+ statusCode,
14
+ body,
15
+ } = await undici.request(map, { maxRedirections: 2 });
16
+
17
+ if (statusCode === 404) {
17
18
  throw new Error('Import map could not be found on server');
18
- } else if (result.status >= 400 && result.status < 500) {
19
+ } else if (statusCode >= 400 && statusCode < 500) {
19
20
  throw new Error('Server rejected client request');
20
- } else if (result.status >= 500) {
21
+ } else if (statusCode >= 500) {
21
22
  throw new Error('Server error');
22
23
  }
23
- return result.json();
24
- }));
24
+ return body.json();
25
+ });
25
26
  return await Promise.all(maps);
26
27
  } catch (err) {
27
28
  throw new Error(
28
29
  `Unable to load import map file from server: ${err.message}`,
29
30
  );
30
31
  }
31
- }
32
+ };
32
33
 
33
34
  function esmImportToUrl({
34
35
  path = process.cwd(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eik/rollup-plugin",
3
- "version": "4.0.7",
3
+ "version": "4.0.11",
4
4
  "description": "Rollup 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": "./dist/plugin.cjs",
@@ -19,8 +19,8 @@
19
19
  },
20
20
  "scripts": {
21
21
  "prepare": "npm run -s build",
22
- "test": "tap --no-esm test/*.js --no-coverage",
23
- "test:snapshot": "TAP_SNAPSHOT=1 tap --no-esm test/*.js --no-coverage",
22
+ "test": "tap --no-coverage",
23
+ "test:snapshot": "TAP_SNAPSHOT=1 tap --no-coverage",
24
24
  "lint": "eslint . --ext=js",
25
25
  "lint:fix": "eslint . --fix --ext=js",
26
26
  "start": "node --experimental-modules ./example/server.mjs",
@@ -45,23 +45,19 @@
45
45
  },
46
46
  "homepage": "https://github.com/eik-lib/rollup-plugin#readme",
47
47
  "devDependencies": {
48
- "@semantic-release/changelog": "5.0.1",
49
- "@semantic-release/commit-analyzer": "8.0.1",
50
- "@semantic-release/git": "9.0.1",
51
- "@semantic-release/github": "7.2.3",
52
- "@semantic-release/npm": "7.1.3",
53
- "@semantic-release/release-notes-generator": "9.0.3",
54
- "eslint": "7.32.0",
55
- "eslint-config-airbnb-base": "14.2.1",
56
- "eslint-plugin-import": "2.24.0",
57
- "fastify": "3.14.1",
58
- "rollup": "2.39.0",
59
- "semantic-release": "17.4.7",
60
- "tap": "14.11.0"
48
+ "@semantic-release/changelog": "6.0.1",
49
+ "@semantic-release/git": "10.0.1",
50
+ "eslint": "8.6.0",
51
+ "eslint-config-airbnb-base": "15.0.0",
52
+ "eslint-plugin-import": "2.25.4",
53
+ "fastify": "3.25.3",
54
+ "rollup": "2.63.0",
55
+ "semantic-release": "18.0.1",
56
+ "tap": "15.1.6"
61
57
  },
62
58
  "dependencies": {
63
59
  "@eik/common": "3.0.0",
64
- "node-fetch": "2.6.4",
60
+ "undici": "4.12.1",
65
61
  "rollup-plugin-import-map": "2.2.2"
66
62
  }
67
63
  }
package/src/plugin.js CHANGED
@@ -2,27 +2,32 @@
2
2
 
3
3
  import { rollupImportMapPlugin as importMapPlugin } from 'rollup-plugin-import-map';
4
4
  import { helpers } from '@eik/common';
5
- import fetch from 'node-fetch';
5
+ import { request } from 'undici';
6
6
 
7
- async function fetchImportMaps(urls = []) {
7
+ const fetchImportMaps = async (urls = []) => {
8
8
  try {
9
- const maps = urls.map((map) => fetch(map).then((result) => {
10
- if (result.status === 404) {
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 (result.status >= 400 && result.status < 500) {
17
+ } else if (statusCode >= 400 && statusCode < 500) {
13
18
  throw new Error('Server rejected client request');
14
- } else if (result.status >= 500) {
19
+ } else if (statusCode >= 500) {
15
20
  throw new Error('Server error');
16
21
  }
17
- return result.json();
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 default function esmImportToUrl({
28
33
  path = process.cwd(),