Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpack 2 "exports is not defined"

I just updated to Webpack 2 and am receiving a runtime error exports is not defined in the browser. I changed my .babelrc from this:

{
  "plugins": [
    "syntax-flow",
    "transform-flow-strip-types",
    "add-module-exports"
  ],
  "presets": [
    "latest",
    "stage-2"
  ]
}

to this:

{
  "plugins": [
    "syntax-flow",
    "transform-flow-strip-types",
    "add-module-exports"
  ],
  "presets": [
    ["latest", {
        "es2015": {
            "modules": false
        }
    }],
    "stage-2"
  ]
}

To deactivate module import / export transpilation and leverage webpack 2's tree-shaking feature. Am I missing something? The build compiles correctly, but in the browser it just blows up.

like image 418
PlantTheIdea Avatar asked Feb 04 '17 12:02

PlantTheIdea


1 Answers

TL;DR) Get rid of add-module-exports

To understand more about what's going on: https://ntucker.true.io/ntucker/webpack-2-uncaught-referenceerror-exports-is-not-defined/

like image 78
Nathaniel Tucker Avatar answered Sep 28 '22 18:09

Nathaniel Tucker