oliviertassinari / serviceworker-webpack-plugin

Simplifies creation of a service worker to serve your webpack bundles. :recycle:
https://oliviertassinari.github.io/serviceworker-webpack-plugin/
MIT License
458 stars 76 forks source link

Use an injected loader for better performance #92

Closed apapirovski closed 5 years ago

apapirovski commented 5 years ago

What is accomplished by your PR?

Instead of using the nmf.afterResolve hook, use an injected loader for much faster performance on large projects. From 15s to 0.5s on a project with 10k+ files.

Is there something controversial in your PR?

Modifying the original config although this seems to be relatively common judging by a quick audit of the ecosystem.

Checklist

New Feature / Bug Fix

woutervanvliet commented 5 years ago

Do you have any documentation about this method?

apapirovski commented 5 years ago

@woutervanvliet what type of documentation are you looking for?

In terms of usage in the ecosystem, there are a number of plugins that do this or something similar:

https://github.com/vuejs/vue-loader/blob/64af07915ac47ebb6bad3223fd2bd15dee908196/lib/plugin.js https://github.com/Esri/arcgis-webpack-plugin https://github.com/faceyspacey/extract-css-chunks-webpack-plugin/blob/ae0f5b10e81326c7b7ec9f53337dd4a46a463cc2/src/index.js

The reason it's faster is that the current solution has to run the hook for each imported file which on large projects becomes prohibitively expensive.

woutervanvliet commented 5 years ago

@apapirovski That's pretty much what I was looking for. Just something from elsewhere that shows that others are using this method as well.

apapirovski commented 5 years ago

@woutervanvliet @oliviertassinari anything else I can do here to help get this landed?