-
Notifications
You must be signed in to change notification settings - Fork 80
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
refactor: use full relative paths in imports #552
Conversation
This works fine with the TS compiler itself, but not Jest |
If jest is the problem, I'm okay with moving away from it. I heard from others that Jest is a big pain point in the transition to ESM |
ESM support is not in the current stable release of Here's what I have found with some testing:
|
this is the weirdest thing! Is this related to jest or do you see the same when you just import |
I'd personally prefer to stick with |
ok 👍🏼
You are working on |
I mainly maintain |
This is the test in question: It only fails in this test, and only when you import with types for express. Wether in ESM or CommonJS EDIT: Only happens in |
The The test stalls right after we call the EDIT: something to do with the versions of |
@G-Rath do you know what could be causing this? |
@wolfy1339 not off the top of my head, but could try looking into it this weekend.
|
a50213f
to
a2c4203
Compare
a2c4203
to
09f89bb
Compare
I think we are running into this issue: kulshekhar/ts-jest#2010 |
I have tried forcing @G-Rath Can you help out here to figure out a way to go? |
f3e4216
to
2c3cf2f
Compare
I did some more testing, found a fix.
It seems the reverse of #534 but only when paths are unknown to the middleware |
Just to clarify: Is the problem in our end and how we define types or is something maybe we should report to |
I am really not sure what the underlying issue really is. I only know that the issue doesn't arise if it is the first in the chain of middleware, and only happens when you try to access a path that isn't handled by the Webhooks middleware. The types don't seem to be anything wrong with them that would conflict like this |
Do you think it would be interesting to try to reproduce it without Octokit (a small codesanbox maybe?)? This way we could know if it's something related to Octokit or to jest under concrete circumstances. Only if it is not a big effort to create this simplified example. |
Yes, it would probably be helpful to diagnose the issue to create a simplified example. We'd just need to extract the middleware logic from this module. |
2af81d4
to
216efe4
Compare
I was discussing with some friends the status of jest regarding ESModules. Do you know what's the status on that? Is this the issue I should subscribe: jestjs/jest#11167? |
Jest should work fine with plain JS using ESM. The only issue we have, is because of TypeScript and the way Jest handles imports (kulshekhar/ts-jest#2010), since the file Since we are going to be moving to pure ESM + external TypeScript definition files, most of the changes in this PR are moot. |
I assume this will get unblocked by #819. |
I don't think it will have an effect |
I thought that #819 was using "esbuild to transpile the TS source code into an ESM source ...". Does that mean that it should only unblock it once the changes go to the other areas in the repository? |
Yes, we do build for ESM. However, those builds are meant for the browser/deno and we are still using CommonJS for NodeJS |
This should help bring ESM compatibility in the future
30c7bc7
to
a6e9186
Compare
I came back to this PR, and I have gotten it working |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Just one question: looks like we're using .ts
for type
imports and .js
for runtime code in the source code but not in tests - I'm figuring that's because the tests go through an extra step somewhere that handles that? but my actual question is are we able to use .js
for the type imports too, and if so I think we should do that for consistency
(and sorry for not responding to your last ping on this - I don't recall ever seeing it in my inbox 😬)
It's a functionality included in recent versions of TypeScript using the
We are absolutely able to use the |
🎉 This PR is included in version 12.0.8 🎉 The release is available on: Your semantic-release bot 📦🚀 |
octokit/webhooks.js#552 broke `npm publish` in this repository by introduces `.ts`extensions to some imports (which caused `npm publish` to fail with "error TS2691: An import path cannot end with a '.ts' extension"). This fixes that.
octokit/webhooks.js#552 broke `npm publish` in this repository by introduces `.ts`extensions to some imports (which caused `npm publish` to fail with "error TS2691: An import path cannot end with a '.ts' extension"). This fixes that by adding the ts-node.esm configuration to tsconfig.json (which in turn required several dependency bumps).
This should help bring ESM compatibility in the future