loading external modules from FileSystem access API

This commit is contained in:
Dmitry Vasilev
2022-10-26 11:37:17 +08:00
parent 0fa7c03e87
commit a78ba0fa78
5 changed files with 56 additions and 38 deletions

9
src/effects.js vendored
View File

@@ -10,7 +10,14 @@ const load_external_imports = async state => {
}
const urls = state.loading_external_imports_state.external_imports
const results = await Promise.allSettled(
urls.map(u => import(u))
urls.map(u => import(
/^\w+:\/\//.test(u)
? // starts with protocol, import as is
u
: //local path, load using File System Access API, see service_worker.js
// Append fake host that will be intercepted in service worker
'https://leporello.import/' + u
))
)
const modules = Object.fromEntries(
results.map((r, i) => (