Web workers

You can use Shimport in web workers via importScripts. This is the code inside worker.js — you can see the output by opening the console.

worker.js

importScripts('../shimport.js');
__shimport__.load('./app/main.js', location.href);

app/main.js

import { foo } from './foo.js';

console.log(foo);

import('./bar.js').then(({ bar }) => {
	console.log(bar);
});

app/foo.js

export const foo = `hello from ${location.origin}/web-worker/app/foo.js!`;

app/bar.js

export const bar = `hello from ${location.origin}/web-worker/app/bar.js!`;