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

deno bundle minification #6900

Closed
ghost opened this issue Jul 27, 2020 · 20 comments
Closed

deno bundle minification #6900

ghost opened this issue Jul 27, 2020 · 20 comments
Labels
cli related to cli/ dir feat new feature (which has been agreed to/accepted) help wanted community help requested swc related to swc (bundling/transpiling)

Comments

@ghost
Copy link

ghost commented Jul 27, 2020

Similar to how Deno uses a TypeScript compiler when running code, users should have the option when bundling to minify their compiled files for better performance. The argument after bundle could be -m or -minify. We could see if the minifier would be uglify, which from what I've heard is normally used with npm.

Any thoughts?

@kitsonk
Copy link
Contributor

kitsonk commented Jul 27, 2020

This would be a long term goal.

We couldn't use uglify as it doesn't work with modern JavaScript, uglify-es is no longer maintained, terser is the successor to uglify. Even then we wouldn't use it. We would look to swc though its minification likely needs improvement.

@ghost
Copy link
Author

ghost commented Jul 27, 2020

Well, I suppose that this would be the tool to be used! It seems more fitting upon inspection, anyhow. I believe as long as its minification process does not come with a critical error that would ruin the code itself, it can grow alongside Deno, couldn't it?

@kitsonk
Copy link
Contributor

kitsonk commented Jul 27, 2020

We already use swc in Deno. Again this is still a long term goal, as there are a load of other things we need to do (including ones related to bundling, see: #4549) before this became a priority, some of which would block this (source maps for example).

@ghost ghost closed this as completed Jul 27, 2020
@kitsonk kitsonk added cli related to cli/ dir feat new feature (which has been agreed to/accepted) labels Nov 5, 2020
@kitsonk
Copy link
Contributor

kitsonk commented Nov 5, 2020

This potentially could be considered now that we have moved over bundling to swc.

@kitsonk kitsonk reopened this Nov 5, 2020
@kitsonk kitsonk changed the title deno bundle <file> -m (minifier) deno bundle minification Nov 5, 2020
@kitsonk
Copy link
Contributor

kitsonk commented Nov 5, 2020

minification is on the swc roadmap but not implemented yet

@bartlomieju bartlomieju added the upstream Changes in upstream are required to solve these issues label Nov 18, 2020
@ebebbington
Copy link
Contributor

Would be great to see minification for deno bundle! I use deno bundle for my client side TS code, so it'd be great to minify it as well

@kitsonk kitsonk added the swc related to swc (bundling/transpiling) label Nov 26, 2020
@pierredewilde
Copy link

In the meantime, you may use esbuild, an extremely fast JavaScript minifier written in Go, to minify your Deno bundles:

$ deno bundle https://deno.land/[email protected]/http/file_server.ts | esbuild --minify > file_server.min.js
$ deno run --allow-net --allow-read file_server.min.js

Other JavaScript minifiers (eg terser) may have issues like Unexpected character '#' - See terser/terser#702

@ghost
Copy link
Author

ghost commented Dec 2, 2020

Sounds like a shortcut or alias can be made from that! @pierredewilde

@probins probins mentioned this issue Jan 4, 2021
4 tasks
@ghost ghost closed this as completed Feb 23, 2021
@kitsonk kitsonk reopened this Feb 23, 2021
@IllusionPerdu
Copy link

For information they're some work in swc for minify swc-project/swc#1302

@David-Else

This comment has been minimized.

@MichaelCurrin

This comment has been minimized.

@David-Else

This comment has been minimized.

@MichaelCurrin

This comment has been minimized.

@kitsonk
Copy link
Contributor

kitsonk commented Apr 22, 2021

Please keep the information on topic. If you want to discuss esbuild under Deno, we have a discussion forum.

@kurai-espoir
Copy link

Any update on this?

@josh-hemphill
Copy link
Contributor

josh-hemphill commented Nov 19, 2021

If deno uses swc, and swc allows for config files to set things like minification, Is it possible to just expose that for configuring the compile command. (might also be a good idea to include that in the new deno.json config file like there is for tsconfig)
https://swc.rs/docs/configuration/minification

@kitsonk kitsonk removed the upstream Changes in upstream are required to solve these issues label Nov 19, 2021
@kitsonk kitsonk added the help wanted community help requested label Nov 19, 2021
@kitsonk
Copy link
Contributor

kitsonk commented Nov 19, 2021

Not really, as the way Deno interfaces with swc is not via a configuration file, but instead by directly interfacing to the Rust APIs, and the configuration is quite opinionated.

That being said, it could be something that the wider community could contribute by adding a --minify flag to deno bundle and deno compile and would require familiarity with the Rust API of swc. We would want to ensure that the source maps are right and proper for deno bundle.

@KnorpelSenf
Copy link
Contributor

If this gets implemented, would you also add a minify?: boolean option to Deno.emit?

@kamilogorek
Copy link
Contributor

In #16149 @kitsonk explained why it's not going to happen.
I'd close this issue in favor of #15463

@lucacasonato
Copy link
Member

deno bundle was removed in Deno 2.

@lucacasonato lucacasonato closed this as not planned Won't fix, can't repro, duplicate, stale Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli related to cli/ dir feat new feature (which has been agreed to/accepted) help wanted community help requested swc related to swc (bundling/transpiling)
Projects
None yet
Development

No branches or pull requests