Using webpack alias to newer version of Terser
See original GitHub issue🐛 Bug report
Current Behavior
Terser error during build if I user ?.
for possible null properties.
Unexpected token: punc (.) [webpack://./node_modules/ts-loader/index.js??ruleSet[1].rules[4]!./src/Components/ImageUploader/ImageUploader.tsx:36,33][static/js/client.5ece3c3b.js:23169,34]
If I remove the ?.
it works fine.
Expected behavior
As I know this variable is not null compiler should work.
Reproducible example
https://dev.azure.com/interdevme/_git/HarmonyWithNature?path=/src/WebSite/ClientApp
You can run npm i
and npm run build
here
Suggested solution(s)
I updated razzle
package and manually installed npm i terser
in client app to try to add an alias as I have in other webpack apps. This is the start of my razzle.config.js
file:
module.exports = {
plugins: [
'typescript',
new MiniCssExtractPlugin(),
],
buildType: 'iso-serverless',
target: 'web',
modify: (config, { target, dev }, webpack) => {
config.resolve = {
extensions: ['.ts', '.tsx'],
alias: {
terser: path.resolve('./node_modules/terser'),
},
};
Additional context
I’d like to add to the app a new version of Terser so the ?.
possible null error will be gone.
Your environment
Software | Version(s) |
---|---|
Razzle | 4.2.16 |
razzle-plugin-typescript | ^4.0.5 |
razzle-dev-utils | ^4.2.16 |
Node | |
Browser | |
npm/Yarn | |
Operating System | Windows 10 |
TypeScript | 4.3.5 |
React | 17.0.2 |
Issue Analytics
- State:
- Created 2 years ago
- Comments:8
Top Results From Across the Web
TerserWebpackPlugin | webpack
This plugin uses terser to minify/minimize your JavaScript. Getting Started. Webpack v5 comes with the latest terser-webpack-plugin out of the box. If you...
Read more >terser-webpack-plugin - npm
Terser plugin for webpack. Latest version: 5.3.6, last published: 4 months ago. Start using terser-webpack-plugin in your project by running ...
Read more >update terser to latest version (5) #46 - GitHub
Using it with latest webpack will create duplicate packages, because we will do release terser-webpack-plugin with 5 version today; No new features and...
Read more >How to use Terser with webpack - Stack Overflow
When I remove Terser, the app compiles but obviously without JS minification so I am doing something wrong with the syntax in webpack.config.js ......
Read more >Top 5 terser-webpack-plugin Code Examples - Snyk
Learn more about how to use terser-webpack-plugin, ... context = context || path.resolve(__dirname, 'fixtures', fixture); const compiler = webpack({ mode: ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah, so new works? great 😃
just skip terser in dev