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

Have HtmlCriticalWebpack contribute critical's changes back to the compilation #27

Open
thescientist13 opened this issue Jun 27, 2018 · 1 comment

Comments

@thescientist13
Copy link
Collaborator

thescientist13 commented Jun 27, 2018

Summary

Currently, this plugin wraps critical so that it can be called as part of a webpack build lifecycle. By design though, critical only reads and writes to the filesystem. In this way, HtmlCriticalWebpackPlugin acts more in a capacity of that of a post-build step / action.

Per the discussion in #21, and that this plugin assumes the presence of HtmlWebpackPlugin, it might be a nice touch if this plugin could get the result of calling critical, and apply that change to the compilation directly instead, but without any filesystem I / O.

Benefits

  1. Keeps the build process entirely in the realm of webpack. This is especially important to avoid any potential race conditions with the webpack build (in memory vs. I/O)
  2. In memory might be more performant
  3. No need to "post-process" the build
  4. Maintain consistent behaviors / expectation of how a webpack plugin might be expected to work in general

Initial Thoughts

critical's API expects an entry point file and so (without having looked at it) I'm not sure how that would work with how webpack manages the compilation (bundled assets) in memory; be it AST, string, Buffer, something else?. Same thing for the output file I imagine.

I think it might come down to being able to tap into critical's API enough to be able to get all its business logic, but without the I/O. 🤔

@thescientist13 thescientist13 changed the title Have HtmlCriticalWebpack contribute critical changes back to the compilation Have HtmlCriticalWebpack contribute critical's changes back to the compilation Jun 27, 2018
@anthonygore
Copy link
Owner

This would definitely be an improvement if it can be achieved.

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

No branches or pull requests

2 participants