-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Webpack] Uncaught TypeError: deepmerge is not a function #97
Comments
Yup, sounds like #87. I believe this is a Webpack bug. As of 2.x, deepmerge exposes two entry points in the package.json: a UMD build via I don't use Webpack. I'm still waiting for somebody to make a repository with a small reproduction that we can take to the Webpack devs. If you can make a repo that demonstrates the issue with recent Webpack, I can help get it looked at by the Webpack team. |
All the repo needs: a file that imports deepmerge in a way that makes the error happen, a Webpack config, and |
I could probably take care of this, maybe even this evening.
That being said I don’t think it’s webpack.. I looked at the module/main entries in deepmerge’s package json and they don’t seem to have changed in this major release. Apologise if I’m mistaken.
|
There is one difference: 1.5.2 had a |
@TehShrike I've created a reproduction here. Instructions on how to run it are in the readme. I'm using node 8 currently and it's easily reproducible with just the couple of lines in the |
That's excellent. If you're okay with perry-mitchell/repo-deepmerge-webpack#1 and merge it, I'll make an issue over at Webpack. |
I'm still not sure why you think it's completely webpack that has faulted here, as webpack hasn't changed but deepmerge has. 2.0 realised a breaking change for all webpack users, so imo the responsibility falls to deepmerge to fix it (if it is at all in line with the project's goals to remain compatible). Waiting on a potential change from webpack seems unlikely at worst, and a long way off at best. |
If you open the Take a look at the ESM What about it is wrong? It exports the function via I'm not motivated to drop the ESM bundle because of a bug in Webpack. |
I opened an issue with Webpack: webpack/webpack#6584 |
Well to be honest I would still point the finger at how deepmerge is packaged - I use hundreds of other modules with webpack without issue. I know it's not specifically a fault with deepmerge, but the presence of the extra bundled That being said - I hope that you find a solution. I'll be watching what happens 😊. Good luck with the webpack issue. I'll have to switch to another merge library in the meantime, as this is a serious blocker for me. |
If you're controlling the code that is importing deepmerge, you can always |
Have you considered the option to remove this line? |
But that would mean that the bad bundlers would win! |
@TehShrike I'm sorry but I believe you're the one being wrong. There is virtually no chance your proposition will ever get approved by the Webpack team, since there is virtually no chance this will end up being the behaviour of node's loader. Of course, this is still under discussion ( |
Thanks for that link @QuentinRoy, I hadn't read that yet! If it is accurate, then the forward-facing way to expose ESM and CJS modules to node.js would be for deepmerge to:
If this is the best path forward, this seems reasonable. Note: this will not necessarily work around the Webpack bug! This would only make it more likely that you could |
Webpack uses a different module resolution depending on what extension your source file has. |
Yeah, that's the crux of the Webpack bug I think. I tried to suggest changing that in this comment:
I didn't know that Webpack was inferring anything from file extensions already, that's interesting. I'm open to any pull requests that implement the three steps I gave a couple posts up - if nobody else implements that, I'll probably get around to it eventually. At the very least, I'd like to get that done by the time ESM imports land in node.js unflagged. |
I asked a person who knows better than me, and it sounds like that particular path forward isn't guaranteed to be The Right Way, but seems reasonable for now. |
This issue is still happening for me. The exact stack trace is Uncaught (in promise) TypeError: (0 , _deepmergeTs.deepmerge) is not a function I didn't change any dependencies and today it just began happening. Any ideas as to why this is? |
Given that this is happening without webpack, with normal TS, that indicates this is not in fact a webpack bug. |
Hi,
I've been using deepmerge in many of my libraries, mostly private but a few of my public ones as well. The most popular library of mine to use it,
webdav
, was recently updated to use deepmerge 2 - the import of deepmerge broke:This has only occurred for me in the 2.* releases. I use commonjs to import
deepmerge
. The library is basic Javascript compatible with NodeJS 4 and upwards. I've tested that this breaks in a couple of webpack configurations.EDIT: I've created a reproduction.
The text was updated successfully, but these errors were encountered: