@eik/postcss-plugin 4.0.5 → 5.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.
Files changed (3) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/package.json +19 -16
  3. package/src/plugin.js +5 -28
package/CHANGELOG.md CHANGED
@@ -1,3 +1,22 @@
1
+ # [5.0.0](https://github.com/eik-lib/postcss-plugin/compare/v4.0.6...v5.0.0) (2025-05-08)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * update eik/common for shared map fetcher ([#485](https://github.com/eik-lib/postcss-plugin/issues/485)) ([ce6c67a](https://github.com/eik-lib/postcss-plugin/commit/ce6c67af24c17f4429f0695e949226c17db8f66f))
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+ * Drop support for Node 18.
12
+
13
+ ## [4.0.6](https://github.com/eik-lib/postcss-import-map/compare/v4.0.5...v4.0.6) (2024-08-16)
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * **deps:** update dependency @eik/common to v4.1.1 ([b1581de](https://github.com/eik-lib/postcss-import-map/commit/b1581deffee2e11fde92861b9270b6e88e3eb73d))
19
+
1
20
  ## [4.0.5](https://github.com/eik-lib/postcss-import-map/compare/v4.0.4...v4.0.5) (2024-08-15)
2
21
 
3
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eik/postcss-plugin",
3
- "version": "4.0.5",
3
+ "version": "5.0.0",
4
4
  "description": "PostCSS plugin that uses Eik defined import map files to transform bare import specifiers to absolute URLs in @import rules",
5
5
  "main": "src/plugin.js",
6
6
  "types": "./types/plugin.d.ts",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "repository": {
25
25
  "type": "git",
26
- "url": "git+https://github.com/eik-lib/postcss-import-map.git"
26
+ "url": "git+https://github.com/eik-lib/postcss-plugin.git"
27
27
  },
28
28
  "keywords": [
29
29
  "css",
@@ -35,30 +35,33 @@
35
35
  "author": "Finn.no",
36
36
  "license": "MIT",
37
37
  "bugs": {
38
- "url": "https://github.com/eik-lib/postcss-import-map/issues"
38
+ "url": "https://github.com/eik-lib/postcss-plugin/issues"
39
39
  },
40
- "homepage": "https://github.com/eik-lib/postcss-import-map#readme",
40
+ "homepage": "https://github.com/eik-lib/postcss-plugin#readme",
41
41
  "devDependencies": {
42
- "@eik/eslint-config": "1.0.2",
42
+ "@eik/eslint-config": "1.0.15",
43
43
  "@eik/prettier-config": "1.0.1",
44
- "@eik/semantic-release-config": "1.0.0",
44
+ "@eik/semantic-release-config": "1.0.2",
45
45
  "@eik/typescript-config": "1.0.0",
46
- "eslint": "9.9.0",
47
- "fastify": "4.28.1",
48
- "npm-run-all2": "5.0.0",
49
- "postcss": "8.4.41",
50
- "prettier": "3.3.3",
46
+ "eslint": "9.26.0",
47
+ "fastify": "5.3.2",
48
+ "npm-run-all2": "8.0.1",
49
+ "postcss": "8.5.3",
50
+ "prettier": "3.5.3",
51
51
  "rimraf": "6.0.1",
52
- "rollup": "4.20.0",
53
- "semantic-release": "24.0.0",
54
- "tap": "20.0.3",
55
- "typescript": "5.5.4"
52
+ "rollup": "4.40.2",
53
+ "semantic-release": "24.2.3",
54
+ "tap": "21.1.0",
55
+ "typescript": "5.8.3"
56
56
  },
57
57
  "dependencies": {
58
- "@eik/common": "4.1.0",
58
+ "@eik/common": "5.1.0",
59
59
  "css-url-parser": "1.1.4"
60
60
  },
61
61
  "peerDependencies": {
62
62
  "postcss": "^8.0.0"
63
+ },
64
+ "engines": {
65
+ "node": ">=20"
63
66
  }
64
67
  }
package/src/plugin.js CHANGED
@@ -12,32 +12,6 @@ const notUrl = (url) => url.substr(0, 4) !== "http";
12
12
  * @property {Record<string, string>} imports
13
13
  */
14
14
 
15
- /**
16
- * @param {string[]} urls
17
- * @returns {Promise<ImportMap[]>}
18
- */
19
- async function fetchImportMaps(urls = []) {
20
- try {
21
- const maps = urls.map((map) =>
22
- fetch(map).then((result) => {
23
- if (result.status === 404) {
24
- throw new Error("Import map could not be found on server");
25
- } else if (result.status >= 400 && result.status < 500) {
26
- throw new Error("Server rejected client request");
27
- } else if (result.status >= 500) {
28
- throw new Error("Server error");
29
- }
30
- return /** @type {Promise<ImportMap>} */ (result.json());
31
- }),
32
- );
33
- return await Promise.all(maps);
34
- } catch (err) {
35
- throw new Error(
36
- `Unable to load import map file from server: ${err.message}`,
37
- );
38
- }
39
- }
40
-
41
15
  /**
42
16
  * @param {ImportMap} map
43
17
  * @returns {Array<{ key: string; value: string; }>}
@@ -135,10 +109,13 @@ export default ({ path = process.cwd(), maps = [], urls = [] } = {}) => {
135
109
  // Run initially once, this is to ensure it runs before postcss-import
136
110
  async Once(root) {
137
111
  // Load eik config from eik.json or package.json
138
- const config = await helpers.getDefaults(path);
112
+ const config = helpers.getDefaults(path);
139
113
 
140
114
  // Fetch import maps from the server
141
- const fetched = await fetchImportMaps([...config.map, ...pUrls]);
115
+ const fetched = await helpers.fetchImportMaps([
116
+ ...config.map,
117
+ ...pUrls,
118
+ ]);
142
119
 
143
120
  const allImportMaps = [...fetched, ...pMaps];
144
121
  allImportMaps.forEach((item) => {