-
Notifications
You must be signed in to change notification settings - Fork 363
Description
Hi,
I'm having trouble using my microbundle-built package in a standard create-react-app project.
I've created @sandtreader/rafiki using microbundle, and it builds and publishes to npm fine (thanks!).
However when I come to use it in an internal create-react-app, it installs fine but then fails with lots of webpack errors on build / start:
ERROR in ./node_modules/@sandtreader/rafiki/dist/rafiki.modern.js 14:0-37
Module not found: Error: Can't resolve '@mui/material/Button' in '/local/prc/world.management/bridge3/node_modules/@sandtreader/rafiki/dist'
Did you mean 'index.js'?
BREAKING CHANGE: The request '@mui/material/Button' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
Now (as through a glass, darkly) I take this to mean that webpack is using the '.modern.js' file but that the imports don't have extensions on them. Here is the import from the published .modern.js:
import v from"@mui/material/Button"
There are quite a few issues around CRA reporting this - it seems to come from a recent webpack update - but their response seems to be it's the package provider's problem - in this case, me :-)
facebook/create-react-app#11865
webpack/webpack#11467 (comment)
I have no idea if they are right or not, but if so, could microbundle fully specify the import?
Thanks!