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

--globals option #69

Open
zindel opened this issue Mar 10, 2018 · 8 comments
Open

--globals option #69

zindel opened this issue Mar 10, 2018 · 8 comments

Comments

@zindel
Copy link
Member

zindel commented Mar 10, 2018

Some modules account for certain global variables to exist at runtime. The most known examples are global and process. This option would permit to specify the JavaScript file to populate all the global variables bundle may need. It will be included at very top of the bundle.

By default the value included would be:

global = window;
process = { env: {NODE_ENV: "<mode>"}};

Thoughts?

@thangngoc89
Copy link

@zindel the process.env.Node_env is a special case. Bundler like webpack and browsify usually replace them inline for dead code elimination

@zindel
Copy link
Member Author

zindel commented Mar 12, 2018

@thangngoc89 we're replacing process.env.NODE_ENV as well. Some modules account on existence of the process and/or process.env though. Maybe, we can omit the NODE_ENV part...

@thangngoc89
Copy link

@zindel then I think this is a reasonable approach

@boyswan
Copy link

boyswan commented Sep 5, 2018

Is there currently any way to set environment variables through fpack?

@bloodyowl
Copy link

would automatically replacing process.env.X by the available environment variable at build time be considerable?

@zindel
Copy link
Member Author

zindel commented Sep 6, 2018

@boyswan not at the moment. What is the use-case for them (except for NODE_ENV)?

@bloodyowl I am reluctant to add this functionality in this specific form since it breaks the predictability of the build. I.e. now we only consider the files & command line options as inputs. Adding environment variables will create the third "hidden" input source. Actually, the same question as above: what is the use-case for them?

@TrySound
Copy link
Member

TrySound commented Sep 6, 2018

I use --mock flag to set configs with necessary options. Globals are always bad for isolation. process.env.NODE_ENV should be enough.

@bloodyowl
Copy link

@zindel the use case is often to pass flags (such as NODE_ENV) and environment information (such as API_URL) without having to write a special command for each environment.

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

5 participants