@eik/esbuild-plugin 1.0.2 → 1.1.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.
Files changed (2) hide show
  1. package/package.json +11 -10
  2. package/src/plugin.js +4 -19
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eik/esbuild-plugin",
3
- "version": "1.0.2",
3
+ "version": "1.1.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",
@@ -9,7 +9,7 @@
9
9
  ],
10
10
  "scripts": {
11
11
  "test": "tap --no-coverage",
12
- "test:snapshot": "TAP_SNAPSHOT=1 tap --no-esm test/*.js --no-coverage",
12
+ "test:snapshot": "TAP_SNAPSHOT=1 tap test/*.js --no-coverage",
13
13
  "lint": "eslint . --ext=js",
14
14
  "lint:fix": "eslint . --fix --ext=js"
15
15
  },
@@ -35,22 +35,23 @@
35
35
  },
36
36
  "homepage": "https://github.com/eik-lib/esbuild-plugin#readme",
37
37
  "devDependencies": {
38
- "@semantic-release/changelog": "5.0.1",
39
- "@semantic-release/commit-analyzer": "8.0.1",
40
- "@semantic-release/git": "9.0.1",
41
- "@semantic-release/github": "7.2.3",
42
- "@semantic-release/npm": "7.1.3",
43
- "@semantic-release/release-notes-generator": "9.0.3",
38
+ "@semantic-release/changelog": "6.0.1",
39
+ "@semantic-release/commit-analyzer": "9.0.2",
40
+ "@semantic-release/git": "10.0.1",
41
+ "@semantic-release/github": "8.0.2",
42
+ "@semantic-release/npm": "8.0.3",
43
+ "@semantic-release/release-notes-generator": "10.0.3",
44
44
  "esbuild": "0.9.0",
45
45
  "eslint": "7.32.0",
46
46
  "eslint-config-airbnb-base": "14.2.1",
47
47
  "eslint-plugin-import": "2.24.0",
48
48
  "fastify": "3.13.0",
49
- "semantic-release": "17.4.7",
49
+ "semantic-release": "18.0.1",
50
50
  "tap": "15.0.5"
51
51
  },
52
52
  "dependencies": {
53
+ "@eik/common": "^3.0.0",
53
54
  "esbuild-plugin-import-map": "2.1.0",
54
- "node-fetch": "2.6.3"
55
+ "node-fetch": "2.6.6"
55
56
  }
56
57
  }
package/src/plugin.js CHANGED
@@ -1,20 +1,8 @@
1
1
  /* eslint-disable no-restricted-syntax */
2
2
 
3
3
  import * as importMapPlugin from 'esbuild-plugin-import-map';
4
- import { join } from 'path';
5
4
  import fetch from 'node-fetch';
6
- import fs from 'fs';
7
-
8
- async function readEikJSONMaps(eikJSONPath) {
9
- try {
10
- const contents = await fs.promises.readFile(eikJSONPath);
11
- const eikJSON = JSON.parse(contents);
12
- if (typeof eikJSON['import-map'] === 'string') return [eikJSON['import-map']];
13
- return eikJSON['import-map'] || [];
14
- } catch (err) {
15
- return [];
16
- }
17
- }
5
+ import { helpers } from '@eik/common';
18
6
 
19
7
  async function fetchImportMaps(urls = []) {
20
8
  try {
@@ -37,19 +25,16 @@ async function fetchImportMaps(urls = []) {
37
25
  }
38
26
 
39
27
  export async function load({
40
- path = join(process.cwd(), 'eik.json'),
28
+ path = process.cwd(),
41
29
  maps = [],
42
30
  urls = [],
43
31
  } = {}) {
44
32
  const pMaps = Array.isArray(maps) ? maps : [maps];
45
33
  const pUrls = Array.isArray(urls) ? urls : [urls];
46
34
 
47
- const importMapUrls = await readEikJSONMaps(path);
48
- for (const map of importMapUrls) {
49
- pUrls.push(map);
50
- }
35
+ const config = await helpers.getDefaults(path);
51
36
 
52
- const fetched = await fetchImportMaps(pUrls);
37
+ const fetched = await fetchImportMaps([...config.map, ...pUrls]);
53
38
  const mappings = pMaps.concat(fetched);
54
39
 
55
40
  await importMapPlugin.load(mappings);