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

Deploy should be able to handle asynchronous operations in modules #775

Open
AmitMY opened this Issue May 20, 2018 · 4 comments

Comments

Projects
None yet
4 participants
@AmitMY

AmitMY commented May 20, 2018

Version info

3.18.4

Platform Information

Windows

Steps to reproduce

  • Start a new "project" with functions
  • npm i simple-oauth2@2.0.1
  • In index, add import * as oauth2 from 'simple-oauth2';
  • firebase deploy --only functions

Expected behavior

Should succeed.

Actual behavior

Does not succeed. The simple-oauth2 library includes async functions, which firebase does manage to handle at least for my code. It should be able to handle async operations in modules as well.

Function load error: Code in file lib/index.js can't be loaded.
Is there a syntax error in your code?
Detailed stack trace: /user_code/node_modules/simple-oauth2/lib/client/auth-code.js:45
async function getToken(params) {
^^^^^^^^

SyntaxError: Unexpected token function
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object. (/user_code/node_modules/simple-oauth2/index.js:4:24)

Should also mention, the tsconfig that was generated is:

{
  "compilerOptions": {
    "lib": ["es6"],
    "module": "commonjs",
    "noImplicitReturns": true,
    "outDir": "lib",
    "sourceMap": true,
    "target": "es6"
  },
  "compileOnSave": true,
  "include": [
    "src"
  ]
}
@mbleigh

This comment has been minimized.

Contributor

mbleigh commented May 20, 2018

@AmitMY

This comment has been minimized.

AmitMY commented May 20, 2018

@mbleigh Thanks for the quick & to the point reply.
Is there any workaround that can be done right now, except for asking each library to include an es5 module, or am I stuck with old versions? (This library is used in the functions-samples, but a bit of an older version, that does work with the current firebase deploy)

@merlinnot

This comment has been minimized.

merlinnot commented May 20, 2018

@mbleigh may I ask if you are working on a Node 10 support too? I had an impression that you are not releasing Node 8 because you are waiting for Node 10.

@edWAR6

This comment has been minimized.

edWAR6 commented Sep 23, 2018

I used 1.6 and it worked.
"simple-oauth2": "^1.6.0"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment