developit/workerize-loader

sourcemap is not propagated for worker file

rjgotten opened this issue · 1 comments

If the source for the worker is treated by other loaders first, e.g. by Babel, then the sourcemap flowing out of those loaders is not propagated correctly by the rpc-worker-loader.

A minimal required and working change is trivial.
Instead of

function rpcWorkerLoader(content) {
  return content + workerScript;
}

do

function rpcWorkerLoader(content, sourcemap) {
  const cb = this.async();
  cb(null, content + workerScript, sourcemap);
}

Though technically, the new lines added by workerScript should be nulled away in the source map. (Webpack has source map helpers for this, iirc.)

Released in 1.3.0.