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

Integrate into tdewolff/minify #13

Closed
tdewolff opened this issue Feb 17, 2020 · 5 comments
Closed

Integrate into tdewolff/minify #13

tdewolff opened this issue Feb 17, 2020 · 5 comments

Comments

@tdewolff
Copy link

tdewolff commented Feb 17, 2020

Nice work on this project! Very cool results ;-)

If you're interested, do you think it would be possible to integrate this with https://github.com/tdewolff/minify (i.e. replace the JS minifier)? I have very limited time lately, and I've been promising an improved JS minifier for a while now. This project seems like a great replacement of the current JS minifier I have.

The minifiers work on a file-by-file basis (so no bundling, just minifying). Do you have an idea how I could minify a byte-slice using esbuild? What do you think?

@tdewolff tdewolff changed the title Integrate with tdewolff/minify Integrate into tdewolff/minify Feb 17, 2020
@evanw
Copy link
Owner

evanw commented Feb 17, 2020

Yes, it should be possible. Although esbuild is a bundler, it turns into a regular minifier if you pass --minify and not --bundle. So this is the way to minify a file with esbuild:

esbuild src/example.js --minify --outfile=dist/example.min.js

If you want to minify a lot of files at once, you can do something like this:

esbuild src/*.js --minify --outdir=dist

At this time, I'm not intending for the Go source code in this repo to be a library that other people can use. Go is more just an implementation detail of how I decided to build this tool. So while you can try to include this Go code in your project an call out to it directly, that workflow isn't supported and may break in the future. Calling out to the esbuild command is more stable and less likely to break. This may change in the future as this project matures, but right now esbuild is still working toward an MVP state and I don't want to be unable to make big internal changes to the structure of the project if needed.

@evanw
Copy link
Owner

evanw commented Feb 17, 2020

I'm going to close this since I also have very limited time at the moment, and am not interested in doing the work myself to integrate esbuild into tdewolff/minify. This work is probably better tracked by tdewolff/minify#18. That said, definitely feel free to keep asking questions here about how to minify using esbuild! I'm happy to continue answering questions.

@tdewolff
Copy link
Author

That's fine! Integration is actually fairly straightforward. I'll track this further in tdewolff/minify#18

@tdewolff
Copy link
Author

I've added a brief description of how to use the esbuild binary within minify here: https://github.com/tdewolff/minify#esbuild

Initial tests show that esbuild is quite fast! It is usually only 1.5x -- 2x slower than the basic (jsmin-like) implementation of the JS minifier in minify. With feature-parity they should be equally fast I expect. Nice work!

@dkotik
Copy link

dkotik commented Mar 11, 2020

I am very impressed as well. Tried to put esbuild into my production pipe, but there would be too much rewriting. Going to have to hack around it. Why custom FS instead of http.FileSystem?

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

No branches or pull requests

3 participants