sentry-javascript
sentry-javascript copied to clipboard
Investigate why terser/webpack defaults causes SDK code to break
full context in this discord thread: https://discord.com/channels/621778831602221064/1217467422932729918/1220020216336093225
Terser inlining causing issues?
terser itself doesn't have these minify levels so I'm guessing webpack adds these
From Tim on discord
Terser itself doesn't appear to have minify levels, all the different options are configured individually: https://github.com/terser/terser?tab=readme-ov-file#compress-options
What level option is being referred to in the webpack config? https://webpack.js.org/plugins/terser-webpack-plugin/
webpack config: https://gist.github.com/tristanbes/7e2eb2f00637e908ba0fc6f703ae52ea
Ah ok so it's the inline levels!
options: { compress: { inline: 1 } }
I've added tests for both webpack 4 and 5 and backported them to the v7 branch to see if there are any failures.
We don't see any issues with the default terser config https://github.com/getsentry/sentry-javascript/pull/11257
The webpack config looks like this:
import * as path from 'path';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import TerserPlugin from 'terser-webpack-plugin';
import webpack from 'webpack';
webpack({
entry: path.join(__dirname, 'entry.js'),
output: {
path: path.join(__dirname, 'build'),
filename: 'app.js',
},
optimization: {
minimize: true,
minimizer: [new TerserPlugin()],
},
plugins: [new HtmlWebpackPlugin(), new webpack.EnvironmentPlugin(['E2E_TEST_DSN'])],
mode: 'production',
})
I wonder if this may be related to https://github.com/getsentry/sentry-javascript/issues/10566 - ember uses terser under the hood 🤔 there the problem seemed to be related to tree shaking & minifying, somehow.
Maybe my test cases should at least access more of the SDK API?
I think this is hopefully fixed, let's close this for now.