babel-plugin-react-transform icon indicating copy to clipboard operation
babel-plugin-react-transform copied to clipboard

`addImport()` is deprecated in Babel 7

Open joshparolin opened this issue 7 years ago • 2 comments

When trying to upgrade Babel 7, I experienced an error around the deprecation of addImport. Instead, the migration guide recommends using addDefault (reference: https://new.babeljs.io/docs/en/next/v7-migration-api.html#babel-core).

Error:

This API has been removed. If you're looking for this functionality in Babel 7, you should import the '@babel/helper-module-imports' module and use the functions exposed  from that module, such as 'addNamed' or 'addDefault'.

Case 1: https://github.com/gaearon/babel-plugin-react-transform/blob/ccd6dc1d949df694ba571d309ebc507f8d74a27d/src/index.js#L284

Case 2: https://github.com/gaearon/babel-plugin-react-transform/blob/ccd6dc1d949df694ba571d309ebc507f8d74a27d/src/index.js#L291

I attempted to fork, but wound up spinning my wheels for too long. Any insight on how to best migrate would be much appreciated.

joshparolin avatar May 18 '18 04:05 joshparolin

@joshparolin @kozlikov

You may install https://www.npmjs.com/package/metro-babel7-plugin-react-transform and copy its lib/index.js to your node_modules/babel-plugin-react-transform/lib/index.js via postinstall script.

nodkz avatar Jun 06 '18 13:06 nodkz

Switching over to react-hot-loader as prescribed is the best option (was for us at least :+1: )

camsjams avatar Jan 08 '19 18:01 camsjams