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.

@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

https://github.com/atom-minimap/minimap/pull/736

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
DwinaTechcommented, Nov 8, 2021

If you are still have the issue and you are using styled-component then this is the fix I got it works. Add babel-plugin-styled-components to babelrc plugins and package.js dependencies.

{
  "plugins": [
    "babel-plugin-styled-components"
  ]
}
1reaction
mischniccommented, Dec 29, 2020

Is there an ES way to access the exports of the current file?

You don’t need to list them. ns in my example is exactly the same as exports: https://codesandbox.io/s/trusting-dhawan-0zwq5?file=/src/index.js

Read more comments on GitHub >

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

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