Replies: 19 comments
-
Thank you for the demo project, I'll take a look |
Beta Was this translation helpful? Give feedback.
-
Well, I didn't dig a lot about what and why: I am not familiar with webpack. |
Beta Was this translation helpful? Give feedback.
-
Wow, that was quick, thanks! However, I do not yet fully grasp the concept of having dedicated "ES" packages and would very much like to use the standard ones. Also, for some reasons a lot of my tests break when I use the ES-Versions of lodash and deepdash. Therefore I will try and figure out what the issue is and hopefully come back with a pull request here (or close the issue should it turn out deepdash is not to blame after all). |
Beta Was this translation helpful? Give feedback.
-
According to my experience with rollup - an error I see in your case looks like webpack is trying to use deepdash as ES module, that 'default' keyword you know. Or maybe you should not try to 'import' modules in your src, but 'require' them instead. Try to investigate in these two directions, please. BTW using new es module format has a huge benefit - tree shaking works perfectly when you use bundlers which support this feature - final bundle size may be reduced significantly. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Closing this issue for now (just for better npms stats) - let me know if you will find something. |
Beta Was this translation helpful? Give feedback.
-
@YuriGor the great community on stackoverflow was able to help me out, specificlally this answer. TL;DR: As it turns out, webpack is defaultly using the "browser" version from your package.json, and therefore for deepdash it uses the "deepdash.min.js", which does not export deepdash from the module that it is supposed to be (which totally makes sense since it is supposed to be a browser-version, I get that). Anyways, for now this works for me since I just import deepdash with: import deepdash from 'deepdash/deepdash'; I did however think "man, wouldn't it be cool if deepdash was able to handle the 'standard approach' with webpack as well"? So I went ahead and added a line of code to the deepdash.min.js locally (just to test the approach): module.exports = deepdash; And tada... it works fine with import deepdash from 'deepdash'; as well. Now of course we can not just add the line I added for fun to the minfied version, since I am pretty sure it is not "browser safe". I would be happy to create a pull request to solve this, but I do not have an approach here. Do you have any idea how to go about this? Given that you are willing to tackle that at all since you told me to just use the ES version before, I know ;) |
Beta Was this translation helpful? Give feedback.
-
Thank you for investigation, i need to dig into package.json format, maybe it's better to just remove "browser" or just get the right idea how to use it correctly. Hope to do this on this weekend |
Beta Was this translation helpful? Give feedback.
-
Hey, there is no more "browser" field in package.json, hope now webpack will be happy. |
Beta Was this translation helpful? Give feedback.
-
Doesnt work for me. import filterDeep from 'deepdash-es/filterDeep'; My entire nuxt app crashes with Unexpected identifier |
Beta Was this translation helpful? Give feedback.
-
Show full error please |
Beta Was this translation helpful? Give feedback.
-
Problem is i dont get any useful error at all |
Beta Was this translation helpful? Give feedback.
-
Did you try not 'es' version? |
Beta Was this translation helpful? Give feedback.
-
Trying now! |
Beta Was this translation helpful? Give feedback.
-
import pickDeep from 'deepdash/pickDeep'; worked with nuxt it seems! thanks! |
Beta Was this translation helpful? Give feedback.
-
Support is not free here, you know.. |
Beta Was this translation helpful? Give feedback.
-
Pjuh, i had one left!:) |
Beta Was this translation helpful? Give feedback.
-
Welcome to Super Star Support Plan, now you can call me at midnight (but first you will need my phone number, paid separately) |
Beta Was this translation helpful? Give feedback.
-
No problem, i can find the number myself :D hahaha |
Beta Was this translation helpful? Give feedback.
-
I created a simple demo project and included the dist bundle within it to show my problem. I am using deepdash very much as described in the docs, like this:
(reference)
However, webpack seems to have some kind of problem with this, since it creates this line in the bundle:
(reference)
which then leads to the following error in the browser:
Now I have to put a disclaimer here: I am not entirely sure this is either a deepdash or webpack problem, so I am happy to report it over at webpack if you feel deepdash is doing everything correctly. I am also not sure that I am not just a bit stupid and screw up something myself - in that case, sorry!
I hope the minimal project I set up helps debugging a bit. If I can do anything to help debug, I am happy to do so.
P.S.: This works absolutely fine in node.js where I run all my tests with mocha and such, but webpack just won't take it.
Beta Was this translation helpful? Give feedback.
All reactions