diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-05-13 14:01:54 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-05-31 12:11:53 -0300 |
commit | 3b9f95a125d28b8cda3ebca1fe248e2026d2e56d (patch) | |
tree | 0affe1b32b05103ab0b7a572908bd6d041512415 /src/static/js | |
parent | 6863f9ec64af7f9cf079150f3a798d7fe75b9045 (diff) |
web-routes, client: import shims, more adaptive web routes
Diffstat (limited to 'src/static/js')
-rw-r--r-- | src/static/js/module-import-shims.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/static/js/module-import-shims.js b/src/static/js/module-import-shims.js new file mode 100644 index 00000000..e7e1e0cc --- /dev/null +++ b/src/static/js/module-import-shims.js @@ -0,0 +1,27 @@ +export const loadDependency = { + async fromWindow(modulePath) { + globalThis.window = {}; + + await import(modulePath); + + const exports = globalThis.window; + + delete globalThis.window; + + return exports; + }, + + async fromModuleExports(modulePath) { + globalThis.exports = {}; + globalThis.module = {exports: globalThis.exports}; + + await import(modulePath); + + const exports = globalThis.exports; + + delete globalThis.module; + delete globalThis.exports; + + return exports; + }, +}; |