question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
fivethreeocommented, Mar 7, 2022

Ah, so new works? great 😃

0reactions
fivethreeocommented, Mar 7, 2022

just skip terser in dev

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found