Do you want to request a feature or report a bug?
Bug
What is the current behavior?
See #6357 (comment) and babel/babel#7264
Webpack turns the method in this code:
import React from 'react'
class A {
constructor() {
this.b = 1
}
method(a = this.b) {
console.log(a)
}
}
into
method(a = undefined.b) {
console.log(a)
}
probably confusing the top-level with class-level. Curiously without the import (any import) it seems to be fine.
Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
MacOS High Sierra, Node 9.4.0, Webpack 4 beta.0
I’ve opened a PR with a fix. Everything should be back to normal once it would be merged.
@ooflorent Has this fixed been released in current webpack version. My webpack version is 4.29.0 and the same thing happening to me. I have imported one of my project’s dependency i.e. jquery plugin and within that file in class definition they passed “this” alias for window but webpack turned that into “undefined”.