← Back to context

Comment by recursive

4 hours ago

It's a technique I created (someone else must have done it first??) for a sandbox demonstrating a web UI framework I made. https://mutraction.dev/sandbox

To see it work, click "Download self contained .html" from the menu.

Here's the source file that handles this part: https://github.com/tomtheisen/mutraction/blob/master/mutract...

The idea is to use <script type="inline-module" name="foo">...</script> to define modules. That's something I just made up. For each such script, provision a blob URL. The main blocker is usually the same origin policy. Crucially, these blob URLs count as the same origin. So then you need to rewrite the imports from the named modules to the blob URLs. I used some regex rather than a proper parser, but it was more than good enough for me.

It seems quite doable to make some proper bundling tools around this concept.