To ease the migration of const { xx } = require('xx'} codes, I wrote a new script based on this repository to migrate module.exports = to two types of export:
a large export {} for identifier exports
individual export const for variable initializations
The code was tested against my own repo, I don't know much of jscodeshift, so not sure whether there are any other edge cases to handle.
To ease the migration of
const { xx } = require('xx'}
codes, I wrote a new script based on this repository to migratemodule.exports =
to two types of export:export {}
for identifier exportsexport const
for variable initializationsThe code was tested against my own repo, I don't know much of
jscodeshift
, so not sure whether there are any other edge cases to handle.BTW, for any other who wants to use this script directly, just run it against
jscodeshift
as usual:npx jscodeshift -t migrate.js