" at _loadUserApp (/var/runtime/UserFunction.js:100:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
" at Object. (/var/runtime/index.js:43:30)",
" at Module._compile (internal/modules/cjs/loader.js:1015:30)",
" at Object.Module._extensions…js (internal/modules/cjs/loader.js:1035:10)",
" at Module.load (internal/modules/cjs/loader.js:879:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:724:14)",
" at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)",
" at internal/main/run_main_module.js:17:47"]
}
Any idea how I can go around this issue while still be able to using the object spread operator?
Array spread operator seems fine tho, it’s just object spread operator than seems to be causing issues.
My main site https://kollab.netlify.app has had the use of spread + rest replaced by Object.assign but it makes the code much harder to read; being able to switch back to spread + rest is would be highly appreciated
In the meantime I’ll be sure to check out the link you posted.
Thanks!
Edit: all of duplicated posts showed up after 1/2 hr so I deleted the earlier ones
Edit 2: after looking thru the link I’m not entirely sure how I can apply their fixes tho, they’re talking about configuring serverless framework which is a third party framework mainly for helping to deploy to AWS.
Is Netlify using serverless framework to deploy to AWS as well where I can throw in some config files as mentioned in the github issue to adjust how the lambda functions are built + deployed?
Hey @collabiersid,
Sorry to be not very clear with that link! What I was hoping it would show is that AWS lambdas use a version of Node that supports the spread operator and rest syntax by default… so I think what people are discussing in that thread is how to remove/update babel accordingly.
Ah yea I get what you mean now, and yea the node I’ve specified as the environment (v12) supports spread and rest by default.
Your example looks correct, so you’re right in the sense that somehow I’ve modified the build process in some ways I’m unaware of. But what would affect the build process for functions tho?
The tester function I deployed had 0 dependencies (just that particular function, not the whole project), and it seems the culprit is Babel trying to transform the code even tho it’s not necessary and then failing at it.
Do you know how I might’ve caused babel to be used to transform the function code, or how I can disable transformation in netlify’s build process?
Hey @collabiersid,
I know you said that Babel is not a direct dependency of your function- are you using it in your root package.json? If so, then it will interfere with your function code.
Something you could try would be zipping the function so it doesn’t get any of your projects’ other dependencies. You could do that as part of your build command, kind of like what’s shown here:
So the scripts section of your package.json would be:
...
"build": "npm run build:zipped; npm run whatever-other-command"
"build:zipped": "zip -r your-functions-dir.zip your-functions-dir"
...
An update here in case others face a similar problem
So what happened in my case was:
I have the netlify-plugin-inline-functions-env plugin installed, and this plugin uses babel to do its transformation before lambda functions are packaged.
without plugins they’d just be bundled by zip-it-and-ship-it
I also have a babel.config.json in the project root which uses Quasar framework’s babel preset and transforms the code for browser environment.
The above interferes with the netlify-plugin-inline-functions-env transformation process which causes my lambda functions to be transpiled for browsers instead.
To ensure that lambda functions are NOT transpiled for browser environment, I created another .babelrc babel config within the functions folder, so this config file will take override any overlapping config rules i.e. target environment set to { "node": "current" } within ./functions/.babelrc
Lastly, thanks Jen for trying to troubleshoot this for me and also pointing me in the right direction, it’s not easy given that (I now realize) not all relevant information has been presented.