Currently, I'm using a module that utilizes various functions like Not, And, type, and typeIs to construct a query string based on the content type it is searching for. However, there seems to be an issue with one of these functions, particularly the typeIs function in the production environment. Here is how it is implemented:
public typeIs<TNewType>(newTypeAssertion: new (...args: any[]) => TNewType) {
this.stringValue = `TypeIs:${newTypeAssertion.name}` // This line is causing the problem
this.segmentType = 'typeIs'
return this.finialize<TNewType>()
}
The problem arises when the code is minified, as all function names are compressed by default. To address this issue, I configured the minimizer to retain function names. Here is the configuration:
minimizer: [
new TerserPlugin({
cache: true,
parallel: true,
terserOptions: {
keep_fnames: true
}
})
]
While this solution worked well in Chrome, it did not have the same effect on Edge. The highlighted word "Typeis:" in the screenshot below illustrates the part of the query string that is incorrect. It should have been Typeis:User for proper functionality.
In order to resolve this discrepancy, I adjusted my minimizer settings as shown below:
minimizer: [
new TerserPlugin({
cache: true,
parallel: true,
terserOptions: {
keep_fnames: true,
compress: false // Enabling this setting is essential for compatibility with Edge.
}
})
]
The updated configuration now displays correctly on Edge without any compression artifacts. While I aim to reduce my bundle size through code compression, I have experimented with different compression options without success in isolating the issue. My main question remains: why does the name property output differently in Edge compared to Chrome when compressed?