You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've added the following to my config/environment.js:
console.log('environment',environment)
When I run ember serve, I see
environment undefined
Could not start watchman
Visit https://ember-cli.com/user-guide/#watchman for more info.
environment development
That is, config/environment.js gets called multiple times (at least once to boot the server and once per middleware), but environment only gets defaulted to 'development' after the first invocation.
Output from ember version --verbose && npm --version && yarn --version:
The argument passed in to your config/environment.js function is ultimately supplied by the caller of project.config(environmentStringHere). If anyone is calling project.config() (without an arg) then you will have your function's first argument be undefined.
I did some digging, looks like commandArgs is no longer consumed in lookup-command (unused variable) And maybe that is why the resolver is not getting it? (plus missing arg in config call)
Another observation I made is that if I execute: ember build --environment=fizzbuzz, when logging the environment variable in config/environment.js, I'll see:
The environment argument passed to config/environment.js is whatever is passed to project.config. I suspect it is undefined because it is being called as project.config() instead of as project.config(someValue).
In the past this was due to ember-resolver calling project.config() in its init (so it could see if the module unification feature flag was enabled), but as of a change on master here we should be checking for process.env.EMBER_CLI_MODULE_UNIFICATION and can likely remove the config lookup...
Activity
[-][2.18.2] environment undefined first time through[/-][+]environment undefined first time through[/+]rwjblue commentedon Apr 19, 2018
The argument passed in to your
config/environment.jsfunction is ultimately supplied by the caller ofproject.config(environmentStringHere). If anyone is callingproject.config()(without an arg) then you will have your function's first argument beundefined.jamesarosen commentedon Apr 19, 2018
Bingo! https://github.com/ember-cli/ember-resolver/blob/d37c06bd37eb08363dcd1cc5e6ab4329190552b1/index.js#L11
So is that "supported" behavior? If so, is the meaning of that call something like "project configuration that is not environment-dependent"?
givanse commentedon May 22, 2018
There is a report of
environmentbeingundefinedhere.And I saw the same behavior in a brand new app. (I incorrectly reported it here first In config/environment.js the value of environment is undefined)
logs environment as
undefinedgivanse commentedon May 22, 2018
I did some digging, looks like
commandArgsis no longer consumed in lookup-command (unused variable) And maybe that is why the resolver is not getting it? (plus missing arg in config call)Another observation I made is that if I execute:
ember build --environment=fizzbuzz, when logging the environment variable inconfig/environment.js, I'll see:rwjblue commentedon May 22, 2018
The environment argument passed to config/environment.js is whatever is passed to
project.config. I suspect it is undefined because it is being called asproject.config()instead of asproject.config(someValue).In the past this was due to
ember-resolvercallingproject.config()in itsinit(so it could see if the module unification feature flag was enabled), but as of a change on master here we should be checking forprocess.env.EMBER_CLI_MODULE_UNIFICATIONand can likely remove the config lookup...