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

Conditional compilation doesn't seem to work #119

Open
SebastienDaniel opened this issue Feb 29, 2016 · 7 comments
Open

Conditional compilation doesn't seem to work #119

SebastienDaniel opened this issue Feb 29, 2016 · 7 comments

Comments

@SebastienDaniel
Copy link

I've written up the situation on Stackoverflow:
http://stackoverflow.com/questions/35703092/browserify-minifyify-conditional-compilation

Essentially, minifyify works really well with all other uglifyjs options, but for reasons that I can't determine, conditional compilation won't work (--compress, --dead_code --define DEBUG=false)

Any help is welcome :)

@ben-ng
Copy link
Owner

ben-ng commented Mar 3, 2016

So sorry I missed this!

Thanks for the excellent writeup. Have you tried using the programmatic browserify/minifyify API? It would be good to be certain that the problem is happening in minifyify, and not in the browserify command line parsing machinery. Like you said, minifyify just passes those options on to uglify.

@SebastienDaniel
Copy link
Author

I'm a command-line junky, never tried the programmatic API.
I'll whip something up within a couple of days and post the results.

Just to be sure, you're essentially saying that I should structure the build-process programmatically, but without variation? How would that be different from the cmd line? (in terms of process)

thx!

@ben-ng
Copy link
Owner

ben-ng commented Mar 3, 2016

When I write and test minifyify, I do it through the programmatic browserify interface because it's less indirection. The browserify command line syntax gets nasty when the options are nested objects, and I'm a pretty careless person, so I avoid these failure points. As a result, I prefer when a bug is reproduced with the programmatic interface, so I can be sure that the fault is in minifyify, and not some typo in the command. This isn't a recommendation to ditch the command line, just a suggestion that could help us troubleshoot your problem faster.

@SebastienDaniel
Copy link
Author

This problem seems to actually be coming from uglifyjs.

I've been unable to use conditional compilation programmatically, but have succeeded with every other option.

The only way conditional compilation has worked using the API is by providing an additional file which contains the globals used for conditional compilation tests.
I'll go poke around the uglify repo.

@SebastienDaniel
Copy link
Author

turns out that the API prop isn't "define", it's "global_defs".
Also turns out that it needs to be part of the compress object, not a global option.

So the problem was my code... but also a lack of documentation from uglifyjs. I'll be fixing that.

thx!

@SebastienDaniel
Copy link
Author

However, it would seem that minifyify isn't handling that use-case properly via the command line.
Programmatically it works.

@ben-ng
Copy link
Owner

ben-ng commented Mar 4, 2016

cool, glad you figured that out. minifyify doesn't do any options parsing, that's done by browserify. if you think that the options are being parsed wrongly you should open an issue there.

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

2 participants