-
Notifications
You must be signed in to change notification settings - Fork 201
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
ES2017 - import fails: Cannot read property "config" of undefined #202
Comments
Okay, I've debugged a little bit further. The following source code also compiles and deploys successfully:
I was capable to pinpoint the problem down to the ".default"-usage: If, in the compiled source code, the erroneous line (13) gets changed to the following:
it seems to work. Therefore, the problem is that At this point, I am unsure if this is a bug or a feature request - as most other modules seem to work with that kind of import structure, but |
@SargTeX In es6, there are different ways of importing. There are also different methods of exporting. When you export like this When you import like this config must not be the default export, that's why it didn't work. require must be catching both scenarios, that's why using require works.
update: |
Thanks for stepping in @jhu7235 ! You can also do |
…ebase-functions#202 in attempt to resolve functions.config() undefined issue
Version info
firebase-functions: 0.8.2
firebase-tools: 3.17.6
firebase-admin: 5.8.2
node -v: 6.9.5
npm -v: 5.0.3
Test case
I've tried to use simple
import
-statements, compile the file usingbabel-cli
and deploy the compiled code to firebase.For readability, I'll provide you with the uncompiled and compiled source code. I am very certain that this is not an issue with babel-cli, as e.g. the import statement from
firebase-admin
works and I also did not encounter any issues with other projects and a similar setup of babel.Nevertheless, I am new to firebase and it could be an issue on my side. If there are any more information you need/would like to have, please let me know.
index.src.js
.babelrc
index.js
Result:
"TypeError: Cannot read property 'config' of undefined"
Steps to reproduce
Either:
a) Use the above
index.js
for your functions and deploy it, orb) Use the above
.babelrc
and theindex.src.js
to generateindex.js
and deploy it.Were you able to successfully deploy your functions?
I received the error message:
Expected behavior
I would expect that the deployment succeeds without any error message. The deployed service would have 0 functions, but the deploy itself should succeed.
Actual behavior
Instead of suceeding, the deployment fails because
functions
is undefined instead ofcontaining the exports from the
firebase-functions
module. On the other hand, the same import-statement works fine with thefirebase-admin
module - and i did not encounter similar issues so far with other modules.The
firebase-debug.log
:The text was updated successfully, but these errors were encountered: