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

Parcel 2: gzip optimizer #3731

Closed
devongovett opened this issue Nov 3, 2019 · 3 comments · Fixed by #6776
Closed

Parcel 2: gzip optimizer #3731

devongovett opened this issue Nov 3, 2019 · 3 comments · Fixed by #6776

Comments

@devongovett
Copy link
Member

Create the @parcel/optimizer-gzip package. This should include an Optimizer plugin that compresses bundles with gzip. It should use the builtin zlib module of Node to compress the bundle.

Because not all users will expect this optimization to be enabled by default, it should not be included in the default config. To use it, users can extend their project's .parcelrc like this:

{
  "extends": "@parcel/config-default",
  "optimizers": {
    "*.{js,css,html,svg}": ["...", "@parcel/optimizer-gzip"]
  }
}
@hsablonniere
Copy link

hsablonniere commented Oct 12, 2020

Hello @devongovett,

From what I understood, a Parcel Optimizer takes a single bundle and has an opportunity to optimize its contents.
I get how this model works for minification but I'm wondering how it works with compression or maybe we just have different use cases.

My use case would be to precompress (gzip/brotli) all compressible bundles so my static server can serve them directly.
As an example, this means I expect Parcel to output my-styles.654321abcd.css, my-styles.654321abcd.css.gz and my-styles.654321abcd.css.br (same hash).

  • Seems like an optimizer is not what I'm looking for
  • Should this be done in a Bundler?
    • Seems like the place to add bundles
    • I haven't really tried but I'm guessing the hashes will be different
  • I see how I could do this in a reporter but it feels ugly 😆

WDYT?

@mischnic
Copy link
Member

has an opportunity to optimize its contents.

transform the bundle content. For example you also have to manually check for bundle.target.minify in the terser optimizer.


And the problem you've described is exactly why this isn't implemented yet: for this feature, optimizers really need to create multiple output bundles for one input bundle.

The only "workaround" with the current API is a reporter...

@hsablonniere
Copy link

for this feature, optimizers really need to create multiple output bundles for one input bundle.

@mischnic 😄 OK, now I get it. Thanks for you quick reply. I guess this is not something trivial to modify. Good luck to the team and let me know if I can help (test, review, contribute...).

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

Successfully merging a pull request may close this issue.

3 participants