Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interoperability with WMR #40

Open
aduh95 opened this issue Mar 1, 2021 · 2 comments
Open

Interoperability with WMR #40

aduh95 opened this issue Mar 1, 2021 · 2 comments

Comments

@aduh95
Copy link

aduh95 commented Mar 1, 2021

It seems currently not possible to use this plugin with WMR:

yarn create wmr your-project-name
cd your-project-name
yarn add --dev @surma/rollup-plugin-off-main-thread
echo 'import OMT from "@surma/rollup-plugin-off-main-thread";' > wmr.config.mjs
echo 'export default async function (config) {' >> wmr.config.mjs
echo 'config.plugins.push(OMT());' >> wmr.config.mjs
echo '}' >> wmr.config.mjs
echo 'new Worker(new URL("./worker.js", import.meta.url), {type:"module"});' > public/pages/home/index.js
echo 'export default function Home() { return <div>Home</div>; }' >> public/pages/home/index.js
echo 'console.log("Worker working")' > public/pages/home/worker.js
yarn wmr build

This produces the following error:

`output.format` must either be "amd" or "esm", got "undefined"

I've tried to change the format in wmr.config.mjs but didn't get much luck.

I can work around this by changing this line

if (format === "esm" || format === "es") {
to

if (format === "esm" || format === "es" || format === undefined) {

Is interoperability with WMR something on the roadmap?

@surma
Copy link
Owner

surma commented Apr 26, 2021

@developit wdyt?

@developit
Copy link

I have a demo of this somewhere, I'll dig it up. Using it in WMR requires a bit of tweaking because it needs to use Module Workers directly in development mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants