Resolving a @parcel/optimizer-swc error message

By admin
Parcel is a fantastic

zero
CARDINAL

-configuration build tool for front-end development. It’s super fast and requires a minimal amount of setup. It works very well without requiring you to do very much — at least until it starts reporting somewhat opaque error messages.

I recently tried to build a parcel package for a project and encountered this.


@parcel
PRODUCT

/optimizer-swc: the name `$b5ace501ac48e74d$export$2e2bcd8739ae039` is defined multiple times

What the heck is $b5ace501ac48e74d$export$2e2bcd8739ae039 ? What file causing this error? Why does it work when I use the parcel command by itself, but not when I run parcel build ? I didn’t know, but I sure spent the better part of

a work day
DATE

trying to decipher what this error message means and how to resolve it.

The fix was quite easy, but it took awhile to track down: check your files for duplicate default exports. Because of some copy-paste fumbles, and old code, I ended up with a couple of files that had export default class

Hooligan
PERSON

or somesuch and a repeated export default at the end of the file. When the parcel optimizer runs during the build process, it reports the error. It does not appear otherwise.

I hope this post saves you some confustion and debugging time.