[4] Webpack turns “this” to undefined in class definitions

Do you want to request a feature or report a 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) {


    method(a = undefined.b) {

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

Author: Fantashit

2 thoughts on “[4] Webpack turns “this” to undefined in class definitions

  1. @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”.

Comments are closed.