Cannot import package that exposes .mjs files instead of .js files
Hey! I wanted to use lucide-react on my project and used a regular import. However, this error is shown:
Failed to resolve 'lucide-react' from './contents/button.tsx'
Apparently it does not detect .mjs files and just looks for .js files. Any workarounds? I have used this library just fine in other non-plasmo projects. Anything I should know? Thanks:)15 Replies
I had this problem just now. Did you figure out the solution?
@bret_pat has reached level 1. GG!
Ended up using a different package and it's effectively the same
Hmm... they export ESM but do they have proper ESM package.json declaration?...
A lot of package wanted to switch to ESM but they kept their package.json CJS
@louisgv Well, is there a way to make it work with Plasmo without the library needing to change?
You can prob use an older version of Plasmo that use parcel 2.8.3 <- the node resolver back then was more forgiving
Do you know what version of Plasmo supported the older resolver?
@bret_pat has reached level 2. GG!
Not on top of my head, check the release page: https://github.com/PlasmoHQ/plasmo/releases
GitHub
Releases · PlasmoHQ/plasmo
🧩 The Browser Extension Framework. Contribute to PlasmoHQ/plasmo development by creating an account on GitHub.
Gave it a go for a while but didn't work out.
THanks for the help @louisgv !
Gave +1 Rep to @louisgv
@bret_patsorry if I am late but using an "alias" in package.json pointing to the correct entry works for me
Brilliant. Thanks so much for this since it’ll solve a lot of my problems in the future
Oh nice! I forgot we have that alias feature lol
I don't even remember where I found I could use that haha, but yeah, you can 'override' the default way of importing packages with it