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

Elm does not generate optimized code if --no-minify flag is set #3966

Open
jouderianjr opened this issue Jan 7, 2020 · 6 comments
Open

Elm does not generate optimized code if --no-minify flag is set #3966

jouderianjr opened this issue Jan 7, 2020 · 6 comments

Comments

@jouderianjr
Copy link

🐛 bug report

I'm not sure if this is exactly a bug, but I would consider one.

Running this command parcel build {myFile} --out-file bundle.js --target node --bundle-node-modules --no-source-maps --no-minify generates a not optimized bundle because of this this piece of code

As this part of documentation says, the elm optimization doesn't mean minification.

I will be glad to open a pr to change this if you agree that would be the correct behavior

🤔 Expected Behavior

The optimization should be linked to the production flag, not to the minification one.

😯 Current Behavior

parcel build --no-minification generates a not optimized bundle.

💁 Possible Solution

Uses this.options.production instead this.options.minify

💻 Code Sample

parcel build {myFile} --out-file bundle.js --target node --bundle-node-modules --no-source-maps --no-minify

🌍 Your Environment

Software Version(s)
Parcel 1.12.3
Node 12.13
npm/Yarn 6.12
Operating System MacOS 10.14.3
@DeMoorJasper
Copy link
Member

From the docs, I kind of understand the opposite, it mentions Step one is to compile with the --optimize flag. This does things like shortening record field names..

Shortening record field names sounds like a form of minification to me, therefore I think this isn't a bug but intended behaviour. It's not a fully fledged minifier but it's still doing some minification/optimisation

@jouderianjr
Copy link
Author

Hey, thank you for the quick answer, I do agree that is not a bug.

I see that the optimize does also some sort of minification but in my point of view is not the main task.

So, there are some points that the optimization does:

  • Remove dead code
  • "Disable" Debug module, it means debug functions will be removed
  • Disable debugger view. Elm has by default a debugger view in development mode that is disabled in an optimized build.

My main point here is that the elm optimization would be more close to being a production code or not than being minified or not code.

I did a pr for a CLI project that uses parcel and elm, and for some reason, graphql library is crashing when it is minified, so we wanted to not minify the code but still have a production elm build.

Thanks again for the help

@DeMoorJasper
Copy link
Member

@jouderianjr I get it, kinda sucks that minification breaks your code.

Not entirely sure if we could get this fix in as Parcel 1 is in maintenance mode.

@jouderianjr
Copy link
Author

Sorry, I'm not aware of the current pipeline. so, Parcel 2 is not production-ready right? Even we couldn't add this to Parcel 1, could we change this for Parcel 2? I mean, of course, if the members agreed with this change.

As I said, I will be glad to open a pr for that

@DeMoorJasper
Copy link
Member

@jouderianjr parcel 2 has no elm support at the moment

Sent with GitHawk

@jouderianjr
Copy link
Author

@DeMoorJasper so, Parcel 1 being in maintenance mode means the project will not accept this type of Pull requests?

Thanks for the clarification :D

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

3 participants