cowsay-blog / hexo-webpack

Yet another Hexo plugin to enable awesome Webpack package system in your Hexo site.
MIT License
1 stars 2 forks source link

hexo-webpack adds 5 second delay to building site #3

Open 9999years opened 5 years ago

9999years commented 5 years ago

Hey, I love this plugin but it seems to add a weird delay. Log output:

20:11:05.256 DEBUG Generator: asset
20:11:10.383 INFO  [hexo-webpack] Webpack output: "scripts/catalog-stats.bundle.js"
...
20:11:10.387 INFO  [hexo-webpack] Webpack output: "scripts/iter.bundle.js"
20:11:10.387 DEBUG Generator: webpack
20:11:10.399 INFO  [hexo-webpack] Trim: "scripts/foo.js"

Between the Generator: asset line and the first output from hexo-webpack is a 5-second delay, which adds a lot of time to my development feedback loop (5 seconds to see a new page every time I hit save). I'd love to contribute to hexo-webpack (although I may not be able to before September due to corporate restrictions), but I'm not sure where the delay might be. Is 'starting up' webpack causing a delay? I don't think it's caused by parsing my webpack.config.js; I tried adding debug console.log statements and it was pretty much instant.

Thanks!!!

momocow commented 5 years ago

The version published on the NPM is on the branch v0.1.0.

Seems the delay is introduced during this promise chain index.js#L20-L43.

There are 5 steps during these promises.

  1. Install a simple Webpack plugin to hook into each module compilation finished.
  2. Webpack compilation output to memory FS
  3. Parse output files to an array of { path: '', data: ''} mappings (path is for hexo to register the route)
  4. Flatten the mappings (but now I am not really sure why this is required 😂)
  5. Record all output routes for further tracking and remove files that are not parts of the website
9999years commented 5 years ago

Hmm, somewhere around there, but I’m not sure if that's exactly it. I added some simple logging statements to the promises:

05:24:08.867 INFO  [hexo-webpack] webpack install plugin
05:24:08.868 INFO  [hexo-webpack] webpack install plugin finished  # 0.001 seconds
05:24:08.868 INFO  [hexo-webpack] webpack compile
05:24:09.951 INFO  [hexo-webpack] webpack compile finished  # ≈1 second
05:24:09.954 DEBUG Generator: asset  # ≈5 seconds !!!!!
05:24:15.001 INFO  [hexo-webpack] toRoutes 
05:24:15.057 INFO  [hexo-webpack] toRoutes finished  # 0.05 seconds
05:24:15.058 INFO  [hexo-webpack] flatten
05:24:15.058 INFO  [hexo-webpack] flatten finished  # ≈0 seconds
05:24:15.058 INFO  [hexo-webpack] recording route  # ≈0 seconds

Each of the steps took a really short time (and, except for the last one, only ran once), but there's still that weird delay after “Generator: asset”. What prints that? Is that just where a bunch of promises are waited on?