2 years ago
#46187

Aditya
Parcel - Unexpected token name «_28», expected punc «,»
I am using Color JavaScript Library in my Code, And I Am Using Parcel JS for bundling my Code.
When I Am Running Parcel JS For Development Using This Command -
parcel public/index.html
Everything Works Fine.
But When I Build My Code For Production Using This Command -
parcel build public/index.html --public-url ./ --target browser
I Get This Error -
> neusprite@0.0.1 build
> parcel build public/index.html --public-url ./ --target browser
🚨 /home/aditya/Documents/Codes/NeuSprite/node_modules/color/index.js: Unexpected token name «_28», expected punc «,»
at Z.get (/home/aditya/Documents/Codes/NeuSprite/node_modules/terser/dist/bundle.min.js:1:525)
at Object.errorToJson (/home/aditya/Documents/Codes/NeuSprite/node_modules/@parcel/utils/src/errorUtils.js:9:20)
at Pipeline.process (/home/aditya/Documents/Codes/NeuSprite/node_modules/parcel-bundler/src/Pipeline.js:29:26)
at async Object.run (/home/aditya/Documents/Codes/NeuSprite/node_modules/parcel-bundler/src/worker.js:15:12)
at async Child.handleRequest (/home/aditya/Documents/Codes/NeuSprite/node_modules/@parcel/workers/src/child.js:60:26)
One thing to note is that when i use this following option --no-minify
like this parcel build public/index.html --public-url ./ --target browser --no-minify
it Just Works Fine.
On StackoverFlow I Found this Answer
UglifyJs does not support ES6. The error is very likely the method shorthand syntax.
But On The Parcel JS Documentation They Have Mentioned that they Use Terser
Parcel uses terser to minify JavaScript, cssnano for CSS, htmlnano for HTML, and svgo for SVG. If needed, you can configure these tools using a .terserrc, .cssnanorc, .htmlnanorc, or svgo.config.json config file. See the docs for JavaScript, CSS, HTML, and SVG for more details.
And Terser Clearly Mentions It is Suitable For ES6+ On Their GitHub Page.
A JavaScript parser and mangler/compressor toolkit for ES6+.
Then Why I Am I getting This Error?
javascript
ecmascript-6
bundling-and-minification
parceljs
0 Answers
Your Answer