Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make webpack's done hook wait until analyzer writes report / stat file. #247

Merged

Conversation

@mareolan
Copy link
Contributor

@mareolan mareolan commented Feb 2, 2019

Fixes #232 by prolonging webpack's "done" hook until analyzer finishes writing report / stat files.

@jsf-clabot
Copy link

@jsf-clabot jsf-clabot commented Feb 2, 2019

CLA assistant check
All committers have signed the CLA.

@liangchunn
Copy link

@liangchunn liangchunn commented Feb 9, 2019

Nice work! This fixes the issue in my reproducible repo mentioned in #232.

actions.forEach(action => action());
setImmediate(async () => {
try {
for (let i = 0, len = actions.length; i < len; ++i) await actions[i]();

I don't think we need to pre-optimise the loop here. AFAIK V8's optimising compiler does this for us automatically.

Copy link
Contributor Author

@mareolan mareolan Feb 9, 2019

You mean write it as for (let i = 0; i < actions.length; ... instead?

Yes, IMO for(let i = 0; i < actions.length; i++) more readable than for(let i = 0, len = actions.length; i < len; ++i ), plus it wouldn't make a huge difference in terms of perf.

Copy link
Contributor Author

@mareolan mareolan Feb 9, 2019

Sure, no problem.

@valscion
Copy link
Member

@valscion valscion commented Feb 11, 2019

This is looking good to me, thanks! Have you checked which version of webpack has the tapAsync API available, i.e. is it available in webpack 3 or only in 4 and up?

@mareolan
Copy link
Contributor Author

@mareolan mareolan commented Feb 11, 2019

tapAsync is available only for webpack >= 4.0.0. I tried the repro also with latest 3.12.0 and since there's no compiler.hooks, it uses the alternative code flow and webpack won't wait for bundle analyzer. So basically, this fix fixes it only for webpack >= 4.0.0.

src/BundleAnalyzerPlugin.js Outdated Show resolved Hide resolved
src/BundleAnalyzerPlugin.js Outdated Show resolved Hide resolved
src/BundleAnalyzerPlugin.js Outdated Show resolved Hide resolved
src/BundleAnalyzerPlugin.js Outdated Show resolved Hide resolved
th0r
th0r approved these changes Feb 11, 2019
@valscion valscion merged commit 1c8aba3 into webpack-contrib:master Feb 12, 2019
2 checks passed
@valscion valscion mentioned this pull request Feb 12, 2019
@th0r
Copy link
Collaborator

@th0r th0r commented Feb 12, 2019

@mareolan thanks a lot!

@valscion
Copy link
Member

@valscion valscion commented Feb 12, 2019

This is now released in v3.0.4. Thank you for your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants