question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React to Preact codemod

See original GitHub issue

Feature Request

I see that the Preact team has written useful codemods for Preact before: https://github.com/preactjs/migrate-preact-x

I think there should be an official codemod for converting from React to Preact. The codemod should support this:

  • JSX/Create React App setups
  • TypeScript

e.g., if I wanted to convert a TSX codebase to Preact, I would run preact codemod from-tsx

Motivation

reduce the react -> preact conversion friction, which has been preventing me from making the switch (converting seems like a task that can generally be automated)

Other Relevant Information

n/a

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rschristiancommented, Jan 26, 2021

I’d certainly enjoy a tool that allowed for a quick switch, but I think the idea of a merged or migrated config is just too much to really hope for.

Something that just quickly changed up the imports and swapped out the packages like you mentioned would be great, though it would have to come with the huge caveat of “this has a decent chance of not working right out of the box”.

0reactions
sumanthratnacommented, Jan 26, 2021

I see; thanks for the explanation. I agree that this seems unmaintainable so I’ll close this issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

vutran/preact-codemod: Shave some bytes by using ... - GitHub
Learning and experimenting with jscodeshift by transforming React to Preact. Eventually can convert a big React application. Contributing. ♥ preact-codemod and ...
Read more >
Switching to Preact (from React)
Switching to Preact can be as easy as installing and aliasing preact-compat in for react and react-dom . This lets you continue writing...
Read more >
react-codemod - npm
Converts calls to React.createElement into JSX elements. npx react-codemod create-element-to-jsx <path> ...
Read more >
Preact NPM - npm.io
Extensive React compatibility via a simple preact-compat alias; Everything you need: JSX, VDOM, React DevTools, HMR, SSR.. A highly optimized diff algorithm and ......
Read more >
Etsy Moves from React to Preact - Hacker News
Speaking from building both react and Preact sites serving millions of customers ... React is usually not too much effort as for most...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found