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

Exposing or codemodding changed packages #90

Open
43081j opened this issue Aug 7, 2024 · 1 comment
Open

Exposing or codemodding changed packages #90

43081j opened this issue Aug 7, 2024 · 1 comment

Comments

@43081j
Copy link
Contributor

43081j commented Aug 7, 2024

currently we have a few codemods which replace imports.

for example:

const didReplacement = replaceImport(
j,
root,
{ moduleName: 'deep-equal', importName: 'default', cjsNamespace: true },
{ moduleName: 'dequal', importName: 'dequal', cjsNamespace: false },
);

if something (such as the es-t cli) consumes these codemods, it doesn't currently have a way to know what you replaced the import with. we don't expose the fact that we replaced deep-equal with dequal.

in our case, it means the CLI doesn't know which new package to add to package.json.

i think we have two options here:

  1. the codemod owns the job of modifying package.json (by checking the filename or something), and the CLI just calls the codemod on package.json contents
  2. all codemods that affect packages (imports) expose some kind of "result" which defines these (e.g. [{type: 'remove', name: 'deep-equal'}, {type: 'add', name: 'dequal'}])
@thepassle
Copy link
Collaborator

I think it should be number 2 👍 The codemod should provide this information for tooling that uses the codemods

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