I'm attempting to use Object.assign()
in an ES6 web app compiled by Babel with webpack, but I'm getting an error:
Uncaught TypeError: Object.assign is not a function
I'm already using babel-loader
to transpile ES6 to ES5, so all my other ES6 code is working. Yet, Object.assign()
only works after I also import "babel-core/polyfill"
in my codebase. I see that I can also fix this by importing babel-runtime, but I'd like to understand why Object.assign()
requires more than what babel-loader
performs — shouldn't babel-loader
preprocess everything, including Object.assign()
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…