@eik/postcss-import-map
Advanced tools
+7
-0
@@ -0,1 +1,8 @@ | ||
| ## [1.2.3](https://github.com/eik-lib/postcss-import-map/compare/v1.2.2...v1.2.3) (2020-11-13) | ||
| ### Bug Fixes | ||
| * prettier ([2960cc7](https://github.com/eik-lib/postcss-import-map/commit/2960cc771b0c63606a1ea9b95d134eeef978ae02)) | ||
| ## [1.2.2](https://github.com/eik-lib/postcss-import-map/compare/v1.2.1...v1.2.2) (2020-09-18) | ||
@@ -2,0 +9,0 @@ |
+19
-14
@@ -23,3 +23,4 @@ 'use strict'; | ||
| const notBare = (str) => str.startsWith('/') || str.startsWith('./') || str.startsWith('../'); | ||
| const notBare = (str) => | ||
| str.startsWith('/') || str.startsWith('./') || str.startsWith('../'); | ||
@@ -30,3 +31,4 @@ async function readEikJSONMaps(eikJSONPath) { | ||
| const eikJSON = JSON.parse(contents); | ||
| if (typeof eikJSON['import-map'] === 'string') return [eikJSON['import-map']]; | ||
| if (typeof eikJSON['import-map'] === 'string') | ||
| return [eikJSON['import-map']]; | ||
| return eikJSON['import-map'] || []; | ||
@@ -40,12 +42,14 @@ } catch (err) { | ||
| try { | ||
| const maps = urls.map((map) => fetch__default['default'](map).then((result) => { | ||
| if (result.status === 404) { | ||
| throw new Error('Import map could not be found on server'); | ||
| } else if (result.status >= 400 && result.status < 500) { | ||
| throw new Error('Server rejected client request'); | ||
| } else if (result.status >= 500) { | ||
| throw new Error('Server error'); | ||
| } | ||
| return result.json(); | ||
| })); | ||
| const maps = urls.map((map) => | ||
| fetch__default['default'](map).then((result) => { | ||
| if (result.status === 404) { | ||
| throw new Error('Import map could not be found on server'); | ||
| } else if (result.status >= 400 && result.status < 500) { | ||
| throw new Error('Server rejected client request'); | ||
| } else if (result.status >= 500) { | ||
| throw new Error('Server error'); | ||
| } | ||
| return result.json(); | ||
| }) | ||
| ); | ||
| const results = await Promise.all(maps); | ||
@@ -90,3 +94,4 @@ const dependencies = results.map((result) => result.imports); | ||
| if (notUrl(value)) throw Error('Target for import specifier must be an absolute URL.'); | ||
| if (notUrl(value)) | ||
| throw Error('Target for import specifier must be an absolute URL.'); | ||
@@ -100,3 +105,3 @@ mapping.set(key, value); | ||
| ({ path, urls, imports } = {}) => { | ||
| // Work with options here | ||
| // Work with options here | ||
| return async (root) => { | ||
@@ -103,0 +108,0 @@ await populateImportMap({ path, urls, imports }); |
+13
-8
| { | ||
| "name": "@eik/postcss-import-map", | ||
| "version": "1.2.2", | ||
| "version": "1.2.3", | ||
| "description": "PostCSS plugin that uses Eik defined import map files to transform bare import specifiers to absolute URLs in @import rules", | ||
@@ -46,9 +46,10 @@ "main": "dist/plugin.js", | ||
| "@semantic-release/release-notes-generator": "9.0.1", | ||
| "eslint": "7.9.0", | ||
| "eslint-config-airbnb-base": "14.2.0", | ||
| "eslint-plugin-import": "2.22.0", | ||
| "fastify": "2.15.1", | ||
| "postcss": "7.0.32", | ||
| "rollup": "2.26.11", | ||
| "semantic-release": "17.1.1", | ||
| "eslint": "7.13.0", | ||
| "eslint-config-airbnb-base": "14.2.1", | ||
| "eslint-plugin-import": "2.22.1", | ||
| "eslint-config-prettier": "^6.12.0", | ||
| "fastify": "3.7.0", | ||
| "postcss": "8.1.6", | ||
| "rollup": "2.33.1", | ||
| "semantic-release": "17.2.2", | ||
| "tap": "14.10.8" | ||
@@ -59,3 +60,7 @@ }, | ||
| "node-fetch": "^2.6.0" | ||
| }, | ||
| "prettier": { | ||
| "singleQuote": true, | ||
| "tabWidth": 4 | ||
| } | ||
| } |
+19
-14
@@ -11,3 +11,4 @@ /* eslint-disable no-restricted-syntax, no-shadow */ | ||
| const notBare = (str) => str.startsWith('/') || str.startsWith('./') || str.startsWith('../'); | ||
| const notBare = (str) => | ||
| str.startsWith('/') || str.startsWith('./') || str.startsWith('../'); | ||
@@ -18,3 +19,4 @@ async function readEikJSONMaps(eikJSONPath) { | ||
| const eikJSON = JSON.parse(contents); | ||
| if (typeof eikJSON['import-map'] === 'string') return [eikJSON['import-map']]; | ||
| if (typeof eikJSON['import-map'] === 'string') | ||
| return [eikJSON['import-map']]; | ||
| return eikJSON['import-map'] || []; | ||
@@ -28,12 +30,14 @@ } catch (err) { | ||
| try { | ||
| const maps = urls.map((map) => fetch(map).then((result) => { | ||
| if (result.status === 404) { | ||
| throw new Error('Import map could not be found on server'); | ||
| } else if (result.status >= 400 && result.status < 500) { | ||
| throw new Error('Server rejected client request'); | ||
| } else if (result.status >= 500) { | ||
| throw new Error('Server error'); | ||
| } | ||
| return result.json(); | ||
| })); | ||
| const maps = urls.map((map) => | ||
| fetch(map).then((result) => { | ||
| if (result.status === 404) { | ||
| throw new Error('Import map could not be found on server'); | ||
| } else if (result.status >= 400 && result.status < 500) { | ||
| throw new Error('Server rejected client request'); | ||
| } else if (result.status >= 500) { | ||
| throw new Error('Server error'); | ||
| } | ||
| return result.json(); | ||
| }) | ||
| ); | ||
| const results = await Promise.all(maps); | ||
@@ -78,3 +82,4 @@ const dependencies = results.map((result) => result.imports); | ||
| if (notUrl(value)) throw Error('Target for import specifier must be an absolute URL.'); | ||
| if (notUrl(value)) | ||
| throw Error('Target for import specifier must be an absolute URL.'); | ||
@@ -88,3 +93,3 @@ mapping.set(key, value); | ||
| ({ path, urls, imports } = {}) => { | ||
| // Work with options here | ||
| // Work with options here | ||
| return async (root) => { | ||
@@ -91,0 +96,0 @@ await populateImportMap({ path, urls, imports }); |
15744
3.36%214
4.9%15
7.14%