minifyify icon indicating copy to clipboard operation
minifyify copied to clipboard

Conditional compilation doesn't seem to work

Open SebastienDaniel opened this issue 9 years ago • 7 comments

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 :)

SebastienDaniel avatar Feb 29 '16 21:02 SebastienDaniel

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.

ben-ng avatar Mar 03 '16 20:03 ben-ng

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!

SebastienDaniel avatar Mar 03 '16 20:03 SebastienDaniel

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.

ben-ng avatar Mar 03 '16 22:03 ben-ng

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 avatar Mar 03 '16 23:03 SebastienDaniel

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 avatar Mar 04 '16 12:03 SebastienDaniel

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

SebastienDaniel avatar Mar 04 '16 12:03 SebastienDaniel

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.

ben-ng avatar Mar 04 '16 23:03 ben-ng