NativeScript / worker-loader

36 stars 20 forks source link

Improve loaders to use the vendor chunk and reduce their size #12

Closed PeterStaev closed 6 years ago

PeterStaev commented 6 years ago

Fixes #5.

Instead of child compiling workers (which does not reuse the common chunk and increases worker size) this change makes webpack compile the workers in the main bundle. This way it reuses requires from the vendor chunk. After the compile the plugin extracts each worker module in a separate chunk file and also creates a similar to the starter.js file for every worker. In order the vendor chunk to be reused inside the workers, any UI related imports need to be excluded for the worker. That's why the starter file for the worker raises a global.__worker flag which is then used in the vendor file to conditionally import the UI modules.

ns-bot commented 6 years ago

Can one of the admins verify this patch?