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'
'./dist/esm/lucide-react.js' does not exist, did you mean './di
st/esm/lucide-react.mjs'?'
'./dist/esm/lucide-react.js' does not exist, did you mean './di
st/esm/lucide-react.mjs'?'
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
bret_pat
bret_pat•16mo ago
I had this problem just now. Did you figure out the solution?
Arcane
Arcane•16mo ago
@bret_pat has reached level 1. GG!
bret_pat
bret_pat•16mo ago
Ended up using a different package and it's effectively the same
lab
lab•16mo ago
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
bret_pat
bret_pat•16mo ago
@louisgv Well, is there a way to make it work with Plasmo without the library needing to change?
lab
lab•16mo ago
You can prob use an older version of Plasmo that use parcel 2.8.3 <- the node resolver back then was more forgiving
bret_pat
bret_pat•16mo ago
Do you know what version of Plasmo supported the older resolver?
Arcane
Arcane•16mo ago
@bret_pat has reached level 2. GG!
lab
lab•16mo ago
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.
bret_pat
bret_pat•16mo ago
Gave it a go for a while but didn't work out. THanks for the help @louisgv !
YAGPDB.xyz
YAGPDB.xyz•16mo ago
Gave +1 Rep to @louisgv
davidgonmar
davidgonmarOP•15mo ago
@bret_patsorry if I am late but using an "alias" in package.json pointing to the correct entry works for me
No description
bret_pat
bret_pat•15mo ago
Brilliant. Thanks so much for this since it’ll solve a lot of my problems in the future
lab
lab•15mo ago
Oh nice! I forgot we have that alias feature lol
davidgonmar
davidgonmarOP•15mo ago
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
Want results from more Discord servers?
Add your server