(url)
| 45 | }; |
| 46 | |
| 47 | async function loadScript(url) { |
| 48 | const { document } = globalThis; |
| 49 | const { head } = document; |
| 50 | const script = Object.assign(document.createElement("script"), { src: url }); |
| 51 | |
| 52 | function on(event, callback) { |
| 53 | script.addEventListener(event, callback, { once: true, passive: true }); |
| 54 | } |
| 55 | |
| 56 | try { |
| 57 | await new Promise((resolve, reject) => { |
| 58 | on("load", resolve); |
| 59 | |
| 60 | on("error", () => { |
| 61 | reject(new Error(`Failed to load script '${url}'.`)); |
| 62 | }); |
| 63 | |
| 64 | head.appendChild(script); |
| 65 | }); |
| 66 | } finally { |
| 67 | head.removeChild(script); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | async function loadEsmPrettier() { |
| 72 | const [prettier, ...builtinPlugins] = await Promise.all( |
no test coverage detected
searching dependent graphs…