Webpack build is broken
See original GitHub issueWe are now seeing
d is not a function
in our babel/webpack-built app.
The error happens in
loggers.js
, but that could be triggered by an issue with the spread operator.
_Originally posted by @jlowcs in https://github.com/transloadit/uppy/issues/3328#issuecomment-990141390_
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top Results From Across the Web
Webpack suddenly broke - Stack Overflow
Webpack suddenly broke ... Any idea what could broke and why? How to fix it? ... It is a same error I get...
Read more >[BUG] Webpack 5 Broken Bundle · Issue #12014 - GitHub
I would build bundle by command npm run build . After that I get complete bundle. But when I change some value I...
Read more >“It works on my machine”. When Webpack is broken ... - Medium
The initial step of creating a Webpack build process took a while. One of the reasons is that RPM package builders must run...
Read more >After upgrading to v5.12.1 from v5.11, webpack build breaks
11, webpack build breaks. Howdy! I started getting an error in my CI/CD pipeline last night after upgrading my project to v5.
Read more >How I solved and debugged my Webpack issue through trial ...
This is a massive issue, since we cannot just rewrite it every time something is not working! Create-react-app in the best source to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Alright, we actually decided to turn
loose
off on our app, and it did the trick. Thanks for your help @aduh95!Context
For more context, in the case of our app, we are transpiling (
loose: true
) uppy’s code with babel, since uppy contains ES2015+ code. We are also minimizing it.Diagnostic
Source of the exception
Investigating using the dev tools, I can confirm that the issue is indeed coming from the following line from the bundle:
The minimized transpiled code for that line looks like this:
Later, the code does:
But,
l(this, k)[k]
is apparently aSet
, therefored
is aSet
, and therefore not a function.Ouch, that code is hard to read
For better readability, I tried compiling without minification:
Basically, babel replaces the spread operators with the use of
[].concat()
, which makes sense. Butconcat
doesn’t spread iterables (whichSet
is).Explanation of the issue
That all comes from the fact that
[].concat(new Set(), new Set(), new Set())
returns an array ofSet
, not an array of values from thoseSet
.That’s why the
Array.from()
solution was suggested, as this seems to work much better:What about the legacy bundle?
I actually thing the issue is also present in the legacy bundle, since it is also using
Set
and the same[].concat()
approach:Possible solutions
Array.from
(and figure out why it was not working for netdown)Set
with simple arrays