running webpack upgrade to babel7 webpack3

1.9k Views Asked by At

please help me understand why bable/runtime/helpers cannot resolve interopRequireDefault. I have just upgraded babel, tried to explicitly move my dependencies to babel 7.0.0. As far as I understand if the browser is not detected as supporting latest babel uses from the supplied "plugins" in my babelrc file.

err is: Module build failed: TypeError: Cannot read property 'bindings' of null

my babel-loader is definitely calling on files and initiating a compilation. Do I need to specify some other config or traverse process?

devDependencies

"devDependencies": {
"@babel/cli": "^7.0.0-beta.34",
"@babel/plugin-syntax-dynamic-import": "7.0.0-beta.34",
"@babel/plugin-syntax-export-default-from": "7.0.0-beta.34",
"@babel/plugin-syntax-export-namespace-from": "7.0.0-beta.34",
"@babel/plugin-transform-runtime": "^7.0.0-beta.34",
"@babel/plugin-transform-strict-mode": "7.0.0-beta.34",
"@babel/preset-react": "^7.0.0-beta.34",

babelrc

  "presets": [
    "latest",
    "react",
  ],
  "plugins": [
    "@babel/plugin-syntax-export-default-from",
    "@babel/plugin-syntax-export-namespace-from",
    "@babel/plugin-transform-runtime",
    "@babel/plugin-syntax-object-rest-spread",
    "@babel/plugin-syntax-dynamic-import",
    "@babel/plugin-transform-strict-mode",
  ],

err

at Scope.moveBindingTo (/node_modules/babel-core/node_modules/babel-traverse/lib/scope/index.js:939:12)
at BlockScoping.updateScopeInfo (/node_modules/babel-preset-es2015/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:364:17)
at BlockScoping.run (node_modules/babel-preset-es2015/node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:330:12)
at PluginPass.BlockStatementSwitchStatementProgram (node_modules/babel-plugin-transform-es2015-block-scoping/lib/index.js:70:24)
1

There are 1 best solutions below

0
On BEST ANSWER

You are using babel-preset-latest, which has been deprecated in favour of babel-preset-env (for Babel 7 it's @babel/preset-env on npm). The latest preset has been deprecated for a little while and Babel 7 dropped it entirely. The preset you are using is for Babel 6 and is incompatible with Babel 7.

You need to migrate to @babel/preset-env.

npm install --save-dev @babel/preset-env

The env preset can be configured to only transform features that are not supported by the browsers you target, but without any configuration it behaves exactly like the latest preset, so you can replace that in your .babelrc. Also, the react preset in your config should be @babel/preset-react.

"presets": [
  "@babel/preset-env",
  "@babel/preset-react"
],