workflow(sfc-playground): improve module rewrite

This commit is contained in:
Evan You
2021-03-28 21:55:22 -04:00
parent 3ac661b896
commit aa8bf1b7a3
2 changed files with 179 additions and 71 deletions

View File

@@ -11,6 +11,20 @@
<script type="module">
let scriptEl
window.__modules__ = {}
window.__export__ = (mod, key, get) => {
Object.defineProperty(mod, key, {
enumerable: true,
configurable: true,
get
})
}
window.__dynamic_import__ = key => {
return Promise.resolve(window.__modules__[key])
}
function handle_message(ev) {
let { action, cmd_id } = ev.data;
const send_message = (payload) => parent.postMessage( { ...payload }, ev.origin);