-
Notifications
You must be signed in to change notification settings - Fork 95
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
Error.prepareStackTrace may not be called with webpack #61
Comments
I'll provide my own solution :) For anyone using webpack, it's actually the minimizer that's the cause of the problem: by default, the compressor has the The workaround is to configure the minimizer to not use that option: const TerserPlugin = require('terser-webpack-plugin');
// ...
const webPackConfig = {
// ...
optimization: {
minimizer: [
new TerserPlugin({
cache: true,
parallel: true,
terserOptions: {
compress: {
reduce_vars: false
}
}
})
]
}
} With this code, the |
Attempt to address TooTallNate#50 (comment) and TooTallNate#61
While trying to understand why when bindings was used with webpack it returned this kind of error:
I noticed that webpack, when configured to build for production, appears to be very agressive and simply removes this line from bindings.js:
As a consequence,
Error.prepareStackTrace
that is defined above never gets called (that's because that theError.prepareStackTrace
is supposed to be called when the stack property is accessed), and this explains why there is a crash since fileName isundefined
when this line is called:I created a small project that shows the problem: https://github.com/warpdesign/bindings-webpack
Simply checkout the repository, call
npm install && npm run build
and then open thebuild/main.js
file.Notice how the
.stack
property access is missing:The text was updated successfully, but these errors were encountered: