When serverless-offline is running and I make code changes, the console output always displays Webpack rebuilt, even if the code contains errors and the rebuild failed.
Then, instead of a sensible error about my badly formed code, I get a "Cannot find module" error when invoking the function.
I just wasted close to an hour thinking something was wrong with my Webpack module resolution config... I didn't realize what the real problem was until I ran $ sls webpack which gave me a nicely formatted error about my badly formed code.
Is there a way to expose these error messages when serverless-offline triggers a Webpack rebuild?
Hi @adambiggs, thanks for raising this issue.
I don't know much about sls webpack, I think I know were the error is swallowed.
I might take a look. Anyone with intel on the matter please share :)
A quick solution would be to include bail: true in your webpack.config.js file. This will cause serverless-offline to crash with the error. Not sure if there is a more graceful solution.
Thanks @mikestaub that's definitely an improvement.
Incurred in the same problem, if it can helps anyone, installing the friendly-errors-webpack-plugin resolve the issue!
Most helpful comment
Incurred in the same problem, if it can helps anyone, installing the
friendly-errors-webpack-pluginresolve the issue!