@parcel/optimizer-terser: Unexpected token: operator (*=)
See original GitHub issue🐛 bug report
Parcel optimizer parser breaks when it tries to parse the code. Here is the link for the reproduction: https://github.com/atom-minimap/minimap/tree/parcel
❯ npm install
> npm run build
> cross-env NODE_ENV=production parcel build --target main lib/main.js
× Build failed.
@parcel/optimizer-terser: Unexpected token: operator (*=)
C:\Users\aminy\@minimap\minimap\lib\mixins\plugin-management.js:22:0
21 |
> 22 | // Initialize the properties for plugin management.
> | ^ Unexpected token: operator (*=)
23 |
24 | /**
It's likely that Terser doesn't support this syntax yet.
npm ERR! code 1
npm ERR! path C:\Users\aminy\@minimap\minimap
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c cross-env NODE_ENV=production parcel build --target main lib/main.js
🎛 Configuration (.babelrc, package.json, cli command)
"targets": {
"main": {
"context": "node",
"engines": {
"node": ">=12.x"
},
"includeNodeModules": {
"atom": false,
"electron": false
},
"outputFormat": "commonjs",
"isLibrary": true
}
},
🤔 Expected Behavior
Parse and optimize the code
😯 Current Behavior
Fails to parse and optimize
💁 Possible Solution
🔦 Context
Running npm run dev works without issues
💻 Code Sample
https://github.com/atom-minimap/minimap/tree/parcel
🌍 Your Environment
| Software | Version(s) |
|---|---|
| Parcel | ^2.0.0-nightly.490 |
| Node | 15.5.0 |
| npm/Yarn | 6.14.8 |
| Operating System | Win 10 |
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (10 by maintainers)
Top Results From Across the Web
How to fix 'Unexpected token operator' error from UglifyJs?
Install angular cli 1.5 and change your tsconfig.json target to "es6", perhaps this is a feature only supported by es6?
Read more >Parcel unexpected token
For instance, if you try to parse a malformed JSON with the JSON.parse() ... parcel / optimizer-terser: Unexpected token: operator (* =) C:\U...
Read more >How I Fixed: UglifyJs Unexpected token: name (DropIn)
I've been trying – in vain – to build the front end for CodeReviewVideos. The issue I have been hitting upon is as...
Read more >Unexpected token: operator (>) from UglifyJs - Vue Forum
So for me modifying my webpack.config.js from to use new UglifyJsPlugin() rather than new webpack.optimize.UglifyJsPlugin() fixed the issue.
Read more >@parcel/optimizer-terser - npm
Latest version: 2.8.2, last published: 2 days ago. Start using @parcel/optimizer-terser in your project by running `npm i ...
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 Free
Top 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

If you are still have the issue and you are using
styled-componentthen this is the fix I got it works. Addbabel-plugin-styled-componentsto babelrc plugins and package.js dependencies.You don’t need to list them.
nsin my example is exactly the same asexports: https://codesandbox.io/s/trusting-dhawan-0zwq5?file=/src/index.js