Closed rejhgadellaa closed 1 year ago
No name was provided for external module 'preact/compat' in output.globals – guessing 'compat'
This is just a warning that the UMD build is making a guess on what preact/compat
is called as a global, that's all. It's guessing that it'll be accessible as global.compat
(it won't be, FWIW, it'll be global.preactCompat
. Use this: --globals preact/compat=preactCompat
)
This warning is provided because it can be really tricky to guess what something is provided as, different use cases call for different names. The classic example is forks & namespaced packages: should @rschristian/react
resolve to react
(such as for a personal fork) or should it be rschristianReact
(as if it were a completely separate package to react
)?
We make a guess and throw a warning so users can be aware that it is just a guess. The --globals
flag is there for users to specify exactly what it should be.
I have preact defined as a peerDependency, so it should keep that external, but it looks like microbundle has problems with sub-packages like preact/compat?
What problems? preact/compat
won't be inlined with what you've described above, if that's your concern.
I'm importing specific functions from preact/compat, btw, not the entire thing, so for example:
Keep in mind preact/compat
has side effects, so any import is in fact importing the entire thing. That's unfortunately how it works, it's not pure.
Going to close this out, but feel free to reply if you're still having issues and we can take a look.
I'm getting the following warning when I try to bundle a library that imports from
preact/compat
:I have
preact
defined as a peerDependency, so it should keep that external, but it looks like microbundle has problems with sub-packages likepreact/compat
?Is this expected?
The only solution I have right now is to set
--external none
, but then everything gets bundled (including peer dependencies).I'm importing specific functions from
preact/compat
, btw, not the entire thing, so for example:Related: #223