darionco / rollup-plugin-web-worker-loader

Rollup plugin to load Workers. Supports inlining, dependencies, source maps, NodeJS and browsers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rollup watch broken

Waxolunist opened this issue · comments

When using the plugin the watch mode is broken. My webworker is written with ts.

My config looks like this:

resolve(),
  workerLoader({inline: false, sourcemap: false}),
  typescript({
    sourceMap: true,
    exclude: ['node_modules', '**/*.test.ts'],
  }),

The watch mode executes the build, but the files generated are the same as before.
The workaround currently used is this:

npm run clean && rollup -c && chokidar 'src/**/*.*' -c 'rollup -c'

But the builds are only half as fast as with rollup watchmode enabled.

My repository is this:
https://github.com/Waxolunist/paint2

To reproduce start the watchmode and the devserver:

`npm bin`/rollup -cw
npm run serve

When changing a file (e.g. changing the html in paint-app.ts) the changes are not written to the bundle directory.
Commenting out the workerLoader plugin in rollup.config.js changes are picked up immediately, so I assume the workerLoader plugin is something doing to the cache.

This one had me scratching my head for a while, I found that there's an incompatibility between the way this plugin works and @rollup/plugin-typescript I think they are doing something that caches files outside of rollup's cache, so when this plugin runs a second instance of rollup to bundle the worker files something breaks internally.

The immediate solution is to replace @rollup/plugin-typescript for rollup-plugin-typescript2 (should be a drop-in replacement).

In the long term I'll try to get in contact with the @rollup/plugin-typescript authors to try to figure out a long term solution.

Thanks for the report! also, kudos on the painter app!

closing for now, feel free to re-open if the issues persist.

EDIT: Also I would recommend adding chunkFileNames: '[name].js' to config.output to avoid generating a bunch of new files when the watch build is triggered again.

Thanks for the heads up and the tip with the chunkfilenames.