You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Apply codemods to source code after adding component #761
Initially, I thought about creating another transform package, but it expects the function to accept code as input and return the transformed code. That API does not fit well with how most codemod tools work in practice.
It also seems that most well-known codemod tools are CLI-only and do not expose a traditional programmatic API: codemod/codemod#1961 (comment)
I currently see two possible solutions:
Introduce post-add and post-update hooks. This feels tricky because it is hard to reliably track what changed and when.
Rely on the same engine as the codemod tool and add a small harness to access their registry of published codemods.
There might be a third option to set up a virtual filesystem and run codemods against that, but I do not think it is worth the effort.
I feel like most of this is best accomplished through transform plugins. Is there any reason a transform plugin couldn't rely on the code mode engine? Or have a more generic codemod transform that allows you to specify specific code mods?
I certainly wouldn't want jsrepo to depend on a codemod engine.
In the absence of that though introducing hooks could be a fine solution to quite a bit of people's problems. It's been a plan to introduce them for some time just haven't actually got around to it due to there not really being a need from anyone just yet.
Activity
ieedan commentedon Feb 9, 2026
I feel like most of this is best accomplished through transform plugins. Is there any reason a transform plugin couldn't rely on the code mode engine? Or have a more generic codemod transform that allows you to specify specific code mods?
I certainly wouldn't want jsrepo to depend on a codemod engine.
In the absence of that though introducing hooks could be a fine solution to quite a bit of people's problems. It's been a plan to introduce them for some time just haven't actually got around to it due to there not really being a need from anyone just yet.
ieedan commentedon Feb 11, 2026
Hooks proposal in #762 lmk if it will address this properly
ieedan commentedon Feb 17, 2026
I think we can close this with #762