-
Notifications
You must be signed in to change notification settings - Fork 417
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
invoke local --watch is not working #349
Comments
I used to use --watch with |
@crysislinux Thanks for reporting 👍 It seems that Webpack 4 changed something with its watch mode. This comment #279 (comment) also points to that because for @stormit-vn it looks like the issue with watch happens with serverless-offline too. This should be investigated, to see what exactly changed on Webpack's side, so that we can implement a proper fix. |
Just to be completely sure. Can you try with serverless-webpack 5.0.0 and Webpack 3, to see if it is really a change in Webpack 4 that triggers the problem? If yes, we should put "Webpack 4" into the issue subject. |
Further question: Did you set the new Webpack mode option to "development" for local invocations in your webpack.config? This enables debug functionality for the built output.
|
@HyperBrain Thanks for the quick response. I tried with the following combinations
It seems that But it do work with And yes, I have this in webpack.config.js
|
Ok. Then it looks like a general issue restricted to |
The problem might be due to the require cache. A solution would be to make sure that the invocation fetches a fresh module from disk. |
The code of the second answer here would make it possible to remove the old cached module and let the next invocation start freshly. https://stackoverflow.com/questions/9210542/node-js-require-cache-possible-to-invalidate |
@crysislinux Can you check with #351 if that works for you? I did some local tests and it seems that the handler is now loaded again correctly after a watch compile. |
@HyperBrain I am really sorry that I provide some misunderstanding information. I tried again and found that the bug happens only when package:
individually: true #enable this I tried your fix, it magically fix this problem anyway 😃 |
This is a Bug Report
Description
What went wrong?
start with
sls invoke local --function some-function --watch
when change the code, it recompiles the code, but it still seems invoke the old compiled result
What did you expect should have happened?
It should run the latest compiled result just as what the documentation says.
What was the config you used?
No errors, the output is like this
the second time it should output 5 instead of 6 because the code has changed.
Similar or dependent issue(s):
Additional Data
The text was updated successfully, but these errors were encountered: