-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
279 additions
and
239 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import prettierConfig from "eslint-config-prettier"; | ||
import prettierPlugin from "eslint-plugin-prettier"; | ||
import globals from "globals"; | ||
import js from "@eslint/js"; | ||
|
||
export default [ | ||
js.configs.recommended, | ||
prettierConfig, | ||
{ | ||
plugins: { | ||
prettier: prettierPlugin, | ||
}, | ||
languageOptions: { | ||
globals: { | ||
...globals.node, | ||
...globals.browser, | ||
global: true, | ||
}, | ||
}, | ||
}, | ||
{ | ||
ignores: [ | ||
"tap-snapshots/*", | ||
"node_modules/*", | ||
"modules/*", | ||
"utils/*", | ||
"dist/*", | ||
"tmp/*", | ||
], | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { html, css } from 'lit-element'; | ||
import { html } from "lit-element"; | ||
|
||
export default function view(items) { | ||
return html`<p>Hello ${items[0]}!</p>`; | ||
return html`<p>Hello ${items[0]}!</p>`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,51 @@ | ||
/* eslint-disable no-restricted-syntax */ | ||
|
||
import * as importMapPlugin from 'esbuild-plugin-import-map'; | ||
import { helpers } from '@eik/common'; | ||
import { request } from 'undici'; | ||
import * as importMapPlugin from "esbuild-plugin-import-map"; | ||
import { helpers } from "@eik/common"; | ||
import { request } from "undici"; | ||
|
||
const fetchImportMaps = async (urls = []) => { | ||
try { | ||
const maps = urls.map(async (map) => { | ||
const { | ||
statusCode, | ||
body, | ||
} = await request(map, { maxRedirections: 2 }); | ||
|
||
if (statusCode === 404) { | ||
throw new Error('Import map could not be found on server'); | ||
} else if (statusCode >= 400 && statusCode < 500) { | ||
throw new Error('Server rejected client request'); | ||
} else if (statusCode >= 500) { | ||
throw new Error('Server error'); | ||
} | ||
return body.json(); | ||
}); | ||
return await Promise.all(maps); | ||
} catch (err) { | ||
throw new Error( | ||
`Unable to load import map file from server: ${err.message}`, | ||
); | ||
} | ||
try { | ||
const maps = urls.map(async (map) => { | ||
const { statusCode, body } = await request(map, { maxRedirections: 2 }); | ||
|
||
if (statusCode === 404) { | ||
throw new Error("Import map could not be found on server"); | ||
} else if (statusCode >= 400 && statusCode < 500) { | ||
throw new Error("Server rejected client request"); | ||
} else if (statusCode >= 500) { | ||
throw new Error("Server error"); | ||
} | ||
return body.json(); | ||
}); | ||
return await Promise.all(maps); | ||
} catch (err) { | ||
throw new Error( | ||
`Unable to load import map file from server: ${err.message}` | ||
); | ||
} | ||
}; | ||
|
||
export async function load({ | ||
path = process.cwd(), | ||
maps = [], | ||
urls = [], | ||
path = process.cwd(), | ||
maps = [], | ||
urls = [], | ||
} = {}) { | ||
const pMaps = Array.isArray(maps) ? maps : [maps]; | ||
const pUrls = Array.isArray(urls) ? urls : [urls]; | ||
const pMaps = Array.isArray(maps) ? maps : [maps]; | ||
const pUrls = Array.isArray(urls) ? urls : [urls]; | ||
|
||
const config = await helpers.getDefaults(path); | ||
const config = await helpers.getDefaults(path); | ||
|
||
const fetched = await fetchImportMaps([...config.map, ...pUrls]); | ||
const mappings = pMaps.concat(fetched); | ||
const fetched = await fetchImportMaps([...config.map, ...pUrls]); | ||
const mappings = pMaps.concat(fetched); | ||
|
||
await importMapPlugin.load(mappings); | ||
await importMapPlugin.load(mappings); | ||
} | ||
|
||
export function clear() { | ||
importMapPlugin.clear(); | ||
importMapPlugin.clear(); | ||
} | ||
|
||
export function plugin() { | ||
const obj = importMapPlugin.plugin(); | ||
obj.name = '@eik/esbuild-plugin'; | ||
return obj; | ||
const obj = importMapPlugin.plugin(); | ||
obj.name = "@eik/esbuild-plugin"; | ||
return obj; | ||
} |
Oops, something went wrong.