Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

package react-codemod with ncc #263

Open
threepointone opened this issue Jun 28, 2020 · 1 comment
Open

package react-codemod with ncc #263

threepointone opened this issue Jun 28, 2020 · 1 comment

Comments

@threepointone
Copy link
Contributor

This would avoid issues like #249

@danieldelcore
Copy link

Hey @threepointone, I wanted to share CodeshiftCommunity, which could help side-step some of these issues.

It allows you to publish codemods as packages to NPM, the CLI will pull it down and run it in an isolated context.

$ npx @codeshift/cli -p react#error-boundaries path/to/src

Meaning:

  • You always run the latest codemods
  • You don't have to maintain your own CLI implementation
  • You can bundle your own dependencies with the mods

Codeshift allows developers to publish codemods as their own NPM packages or as part of an existing NPM package. We provide a standardized CLI tool that can download and run the latest codemods from any location. This approach has the added benefit of allowing codemods to be published with dependencies, which is not currently possible with most JSCodeshift CLI implementations.

To integrate with this repo, you just need to add a codeshift.config.js.

module.exports = {
  maintainers: ['threepointone'],
  targets: ['react'],
  presets: {
    'React-DOM-to-react-dom-factories': require.resolve('./transforms/React-DOM-to-react-dom-factories.js'),
    'React-PropTypes-to-prop-types': require.resolve('./transforms/React-PropTypes-to-prop-types.js'),
    'ReactNative-View-propTypes': require.resolve('./transforms/ReactNative-View-propTypes.js'),
    'create-element-to-jsx': require.resolve('./transforms/create-element-to-jsx.js'),
    'error-boundaries': require.resolve('./transforms/error-boundaries.js'),
    ...
  },
};

Obviously, no pressure here, thought it might help in the future 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants