-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
1.18.0 breaks referencing variables in Javascript Files #3965
Comments
@indieisaconcept thanks for reporting! thats a pretty creative edge case! have you been able to reproduce it with a simpler config? just wondering if it's a bigger issue than we think. a PR with the fix would be great! 😊 |
We're seeing this too. Libraries like |
@eahefnawy I don't expect it to be an issue if your not doing any additional processing from within a *.js variables file - so a basic config should be fine. I'll confirm though. As this is a simple fix, I'll submit a PR shortly. |
Thanks for getting back @indieisaconcept and thanks for working on and submitting the PR 👍 🎉 We'll review it ASAP so that the fix lands in |
The version 1.18.0 broke my deployment too, though I did not dig for the issue. As a reference for help-seeking googling developers, I'm posting this unhelpful error message from my lambda logs, which was caused by the version update:
which has nothing to do with my
|
Hey @maikokuppe thanks for commenting 👍 We just merged the fix from @indieisaconcept this morning. So it should be fixed in |
Thanks of trying it out @maikokuppe 👍
That sounds like a good idea. We'll release a patch release soon (1.18.1) and 1.19.0 will be released next week. Maybe you can try those versions and open up a new issue if the problem still persists. |
This is a Bug Report
Description
This might be considered an edge case based upon how I make use of a JavaScript configuration file but thought I would share this issue nonetheless as it tripped me up when I went to do a deploy this evening after updating my deps.
Consider the following contrived example.
config.js
serverless.yml
cmd to reproduce
> NODE_ENV=staging serverless package
Running the above cmd results in the following error.
Invalid variable syntax when referencing file "./config.js". Check if your javascript is returning the correct data.
I've reviewed the PR's which made up 1.18 and have pin-pointed #3888 as being the change which introduced this new behaviour.
Prior to 1.18 when a JS file was resolved it was immediately invoked and so it's context was maintained. However in #3888 it is assigned to a local variable and so no-longer has it's original execution context. ( see lib/classes/Variables#L255 )
This can be fixed by amending L255 to :
valueToPopulate = returnValueFunction.call(jsFile);
I'd be happy to submit a PR for this if you think it's worth fixing. I've since worked around it but as per above I thought I'd share the info.
Additional Data
The text was updated successfully, but these errors were encountered: