Skip to content
This repository has been archived by the owner on Jul 7, 2020. It is now read-only.

Unable to create production build without debugging #150

Open
alistairjcbrown opened this issue Jun 12, 2016 · 3 comments
Open

Unable to create production build without debugging #150

alistairjcbrown opened this issue Jun 12, 2016 · 3 comments

Comments

@alistairjcbrown
Copy link
Contributor

alistairjcbrown commented Jun 12, 2016

Setting process.env.NODE_ENV to 'production' in an applications webpack config, as referenced in the debug file (amongst others), should create an optimised build without debug messages being shown.

However, during the fluxthis build process, the webpack config uses the define plugin, and replaces the process.env.NODE_ENV with 'development' if not defined.

The resulting fluxthis build (which is what is downloaded from npm) therefore contains the code:

var IN_PRODUCTION = ("development") === 'production';

This means that for applications which make use of fluxthis, there is no way to create a production build with debugging turned off.

@jhorwit2
Copy link
Contributor

Thanks for submitting this.

Just to let you know, if you are requiring our files via the built code (not require('fluxthis/src/SomeFile')) then it is built with the production env variable set as you can see here

I'm going to double check with @mako-taco but from what I remember we wanted debugging to exist in production as it's lightweight and extremely useful as sometimes you need to debug production if you can't replicate locally.

@alistairjcbrown
Copy link
Contributor Author

@jhorwit2 Thanks for the reply - I see there's a minified bundle too. Good to know.

we wanted debugging to exist in production

Does that mean that the minified bundle still contains debugging, even though it's built with the production env variable set?

Ideally I'd hope for a setup similar to how react deals with warnings - importing the library contains warnings, setting process.env.NODE_ENV to "production" (say, via the webpack define plugin), then switches these warnings off.
This relies on having transpiled (not bundled) code which can be included and bundled at the application level, rather than at the dependency level as it is now. I'll investigate this and aim to get a PR up next week to see what you guys think.

@jhorwit2
Copy link
Contributor

So, you shouldn't be seeing any warnings with production environment set. The only warnings we show by default are the unused registered actions, which the flag removes. I just checked our prod env and don't see them like we do in dev/test.

It does contain the debugging so you have the ability to turn it on via setting the global variable FLUX_DEBUG. The debug code itself is a pretty small file w/ no outside dependencies. Are you asking that we remove that in production builds? I'd be open to consider basically mocking the file in prod builds so it's empty (like how react proptypes does nothing in prod)

Our original intentions were that you would be able to debug prod easily with the magic settings; however, I can't think of a time in the last year or so that we have used it.

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

No branches or pull requests

2 participants