gajus / prepack-webpack-plugin

A webpack plugin for prepack.
Other
1.04k stars 46 forks source link

Not working with worker loader #28

Open teod opened 7 years ago

teod commented 7 years ago

Prepack fails when trying to parse worker-loader generated bundle

 65% building modules 1234/1335 modules 101 active ...s/babel-runtime/core-js/array/from.jsnot an object
TypeError
    at ../node_modules/babel-loader/lib/index.js!./path/to/worker/file.js(8569baa88463d70f55c2.worker.js:184:34)
    at call (native)
    at __webpack_require__ (8569baa88463d70f55c2.worker.js:20:12)
    at 8569baa88463d70f55c2.worker.js:63:18
    at 8569baa88463d70f55c2.worker.js:1:10
/Users/teo/Work/smartup-ui/node_modules/prepack/lib/prepack-standalone.js:68
    throw _errors.fatalError;
    ^

Error: A fatal error occurred while prepacking.
    at new FatalError (/Users/teo/Work/smartup-ui/node_modules/prepack/lib/errors.js:48:14)
    at Object.<anonymous> (/Users/teo/Work/smartup-ui/node_modules/prepack/lib/errors.js:55:39)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/teo/Work/smartup-ui/node_modules/prepack/lib/realm.js:21:15)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/teo/Work/smartup-ui/node_modules/prepack/lib/methods/call.js:19:14)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
luigiplr commented 6 years ago

Try using a negative lookahead in the test regex. It should then exclude the files generated by worker-loader.

new PrepackWebpackPlugin({
  test: /^(?!.*\.worker).*\.js$/i
})