From 4545cb9e5694cd1515e0456d6a37233bad16c516 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Sat, 21 May 2022 09:42:57 +0200 Subject: [PATCH] feat: Avoid transpiling transforms --- .changeset/smart-lamps-type.md | 8 ++++++++ bin/types-react-codemod.cjs | 2 ++ transforms/context-any.js | 2 +- transforms/deprecated-react-child.js | 2 +- transforms/deprecated-react-text.js | 2 +- transforms/deprecated-react-type.js | 2 +- transforms/deprecated-sfc-element.js | 2 +- transforms/deprecated-sfc.js | 2 +- transforms/deprecated-stateless-component.js | 2 +- transforms/deprecated-void-function-component.js | 2 +- transforms/implicit-children.js | 2 +- transforms/preset-18.js | 2 +- transforms/preset-19.js | 2 +- transforms/useCallback-implicit-any.js | 2 +- 14 files changed, 22 insertions(+), 12 deletions(-) create mode 100644 .changeset/smart-lamps-type.md diff --git a/.changeset/smart-lamps-type.md b/.changeset/smart-lamps-type.md new file mode 100644 index 00000000..62350cea --- /dev/null +++ b/.changeset/smart-lamps-type.md @@ -0,0 +1,8 @@ +--- +"types-react-codemod": minor +--- + +Avoid transpiling transforms + +Previously jscodeshift would transpile the transforms before using them. +This was largely unnecessary and resulted in bugs to to usage of undeclared Babel dependencies. diff --git a/bin/types-react-codemod.cjs b/bin/types-react-codemod.cjs index 6b7486a7..4fe6dd26 100755 --- a/bin/types-react-codemod.cjs +++ b/bin/types-react-codemod.cjs @@ -64,6 +64,8 @@ async function main() { const args = [ "--extensions=tsx,ts", `"--ignore-pattern=${argv.ignorePattern}"`, + // The transforms are published as JS compatible with the supported Node.js versions. + "--no-babel", `--transform ${path.join(transformsRoot, `${codemod}.js`)}`, ]; diff --git a/transforms/context-any.js b/transforms/context-any.js index 6b243ce6..2f46e541 100644 --- a/transforms/context-any.js +++ b/transforms/context-any.js @@ -108,4 +108,4 @@ const contextAnyTransform = (file, api) => { return file.source; }; -export default contextAnyTransform; +module.exports = contextAnyTransform; diff --git a/transforms/deprecated-react-child.js b/transforms/deprecated-react-child.js index 054fe392..fe21cc90 100644 --- a/transforms/deprecated-react-child.js +++ b/transforms/deprecated-react-child.js @@ -44,4 +44,4 @@ const deprecatedReactChildTransform = (file, api) => { return file.source; }; -export default deprecatedReactChildTransform; +module.exports = deprecatedReactChildTransform; diff --git a/transforms/deprecated-react-text.js b/transforms/deprecated-react-text.js index 2e6cab24..57dae31b 100644 --- a/transforms/deprecated-react-text.js +++ b/transforms/deprecated-react-text.js @@ -37,4 +37,4 @@ const deprecatedReactTextTransform = (file, api) => { return file.source; }; -export default deprecatedReactTextTransform; +module.exports = deprecatedReactTextTransform; diff --git a/transforms/deprecated-react-type.js b/transforms/deprecated-react-type.js index e6c6c0a6..38b7b0b1 100644 --- a/transforms/deprecated-react-type.js +++ b/transforms/deprecated-react-type.js @@ -22,4 +22,4 @@ const deprecatedReactTypeTransform = (file, api) => { return file.source; }; -export default deprecatedReactTypeTransform; +module.exports = deprecatedReactTypeTransform; diff --git a/transforms/deprecated-sfc-element.js b/transforms/deprecated-sfc-element.js index 07ba0163..376a1347 100644 --- a/transforms/deprecated-sfc-element.js +++ b/transforms/deprecated-sfc-element.js @@ -22,4 +22,4 @@ const deprecatedSFCElementTransform = (file, api) => { return file.source; }; -export default deprecatedSFCElementTransform; +module.exports = deprecatedSFCElementTransform; diff --git a/transforms/deprecated-sfc.js b/transforms/deprecated-sfc.js index 8b393907..b1942bcc 100644 --- a/transforms/deprecated-sfc.js +++ b/transforms/deprecated-sfc.js @@ -22,4 +22,4 @@ const deprecatedSFCTransform = (file, api) => { return file.source; }; -export default deprecatedSFCTransform; +module.exports = deprecatedSFCTransform; diff --git a/transforms/deprecated-stateless-component.js b/transforms/deprecated-stateless-component.js index 2114c429..ac1b59ba 100644 --- a/transforms/deprecated-stateless-component.js +++ b/transforms/deprecated-stateless-component.js @@ -22,4 +22,4 @@ const deprecatedStatelessComponentTransform = (file, api) => { return file.source; }; -export default deprecatedStatelessComponentTransform; +module.exports = deprecatedStatelessComponentTransform; diff --git a/transforms/deprecated-void-function-component.js b/transforms/deprecated-void-function-component.js index 86776272..c1519470 100644 --- a/transforms/deprecated-void-function-component.js +++ b/transforms/deprecated-void-function-component.js @@ -24,4 +24,4 @@ const deprecatedVoidFunctionComponentTransform = (file, api) => { return file.source; }; -export default deprecatedVoidFunctionComponentTransform; +module.exports = deprecatedVoidFunctionComponentTransform; diff --git a/transforms/implicit-children.js b/transforms/implicit-children.js index 2d8d09a0..14838827 100644 --- a/transforms/implicit-children.js +++ b/transforms/implicit-children.js @@ -71,4 +71,4 @@ const implicitChildrenTransform = (file, api) => { return file.source; }; -export default implicitChildrenTransform; +module.exports = implicitChildrenTransform; diff --git a/transforms/preset-18.js b/transforms/preset-18.js index d6a924ef..80503b6d 100644 --- a/transforms/preset-18.js +++ b/transforms/preset-18.js @@ -71,4 +71,4 @@ const transform = (file, api, options) => { } }; -export default transform; +module.exports = transform; diff --git a/transforms/preset-19.js b/transforms/preset-19.js index fd26ed43..5dd9d96a 100644 --- a/transforms/preset-19.js +++ b/transforms/preset-19.js @@ -47,4 +47,4 @@ const transform = (file, api, options) => { } }; -export default transform; +module.exports = transform; diff --git a/transforms/useCallback-implicit-any.js b/transforms/useCallback-implicit-any.js index 6efed19c..5392f141 100644 --- a/transforms/useCallback-implicit-any.js +++ b/transforms/useCallback-implicit-any.js @@ -99,4 +99,4 @@ const useCallbackImplicitAnyTransform = (file, api) => { return file.source; }; -export default useCallbackImplicitAnyTransform; +module.exports = useCallbackImplicitAnyTransform;