codemodsquad / asyncify

Don't keep your promises 😉
MIT License
13 stars 6 forks source link

No index.js, fails to compile #27

Closed eryon closed 3 years ago

eryon commented 3 years ago

Following the straight-forward instructions in the README:

git clone https://github.com/codemodsquad/asyncify
npx jscodeshift -t asyncify/index.js path/to/your/project/**/*.js

It seems there is a step missing. There is no index.js in the root of the project, and running yarn build fails with

> babel src --out-dir es --extensions ".ts" --source-maps inline && cross-env BABEL_ENV=es5 babel src --out-dir . --extensions ".ts"

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /<snip>/asyncify/node_modules/@babel/preset-env/node_modules/@babel/helper-compilation-targets/package.json

Is there a missing step? I looked at the circleci job and there don't seem to be any special env vars or other configurations in place, but there also aren't any artifacts published.

jedwards1211 commented 3 years ago

whoops, yeah I was building and running it locally, but it does get published. Let me look if there's a convenient way to reference a file from a dependency for jscodeshift...

Regarding the error, that happened running old versions of Babel on Node > 12.16 I think, but has been fixed in the latest version of Babel, so I can upgrade the build deps.

eryon commented 3 years ago

@jedwards1211 ah ha, thanks. You're probably right about the Babel error as I'm using Node 12.20.

jedwards1211 commented 3 years ago

I guess I should just add a bin script to this package that calls jscodeshift -t index.js because it seems like there isn't really a good way to install a package globally and easily get a path to a file in it...

jedwards1211 commented 3 years ago

:tada: This issue has been resolved in version 2.1.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

jedwards1211 commented 3 years ago

In case you didn't see the README change, now you can just run npx @codemodsquad/asyncify path/to/your/project/**/*.js

eryon commented 3 years ago

@jedwards1211 I think you were planning on updating the babel deps still, right? It does still fail on Node 12.20 with

Sending 1 files to free worker...
internal/modules/cjs/loader.js:430
      throw e;
      ^

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /<path>/asyncify/node_modules/@babel/helper-compilation-targets/package.json
jedwards1211 commented 3 years ago

Yeah, just haven't done that yet because it will take some time

jedwards1211 commented 3 years ago

There are tons of errors when I upgrade the type defs for babel, seems like they broke the type inference for path.get...

jedwards1211 commented 3 years ago

okay actually it was just that yarn upgrade --latest isn't very good at deduping and I wound up with duplicate versions of something, that was throwing off tsc. I got it working with node 12.20 now!

eryon commented 3 years ago

Thanks for the follow-up, working on my side 🎉