-
Notifications
You must be signed in to change notification settings - Fork 382
fix cjs with nodenext interop issue #391
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
Conversation
I'll look soon, but probably won't have time in the next few days. |
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.
Have you double check the emitted file using npm run build-helmet
.
Since the tsconfig.json
is using "module": "NodeNext"
, it will emit ESM
types in both folder.
The CJS
file is transpile by rollup
from ESM
to CJS
instead of TypeScript
.
It is actually why I remove |
Yes. I used your example code and created a new test-project. Then I did npm run build-helmet in my fork and branch of helmet and then did Then I just did "npm run build" in my test-project with the all combinations of |
@climba03003 |
Have you look inside the type file? It may works depends on setting, or bug in TypeScript. But the emitted types is not the correct one. |
You mean because of the .js suffix of the imports? |
Even with typescript original tsc it will result in the same typings. Modify in helmet the tsconfig-commonjs.json include to index.ts run npx tsc -p tsconfig-common.json It doesnt drop the .js suffix. But the last line you claim is missing is with direct use of tsc there |
|
Doesnt actually matter. It works in helmet-test. The only thing, I think is relevant is the question if I should remove the code, which suppresses the export of the Interfaces for CJS |
After deep dive into TypeScript document. I see how the resolution of types works. Old CodeWhen the project is New CodeWhen the project is RemarkThe Regrading the |
Perhaps, tsd tests or some simple TS file with self-import that would be compiled in CI, could be added here, that would have been failing previously? |
https://github.com/Uzlopak/helmet/actions/runs/3601124357/jobs/6066567174 I guess some combinations make no sense and thats why it is failing? |
yeah, looks like it |
Here for comparison against the main branch https://github.com/Uzlopak/helmet/actions/runs/3601170615 |
I plan to review later this month. Sorry for the delay. |
I ignore in the workflow the failing cases. So if @climba03003 or somebody tries to improve the interoperability, it should be possible to remove that specific case from the in the workfllow. But on the other hand it will be mergable at the current state and it is having now a test, so a regression should be impossible. https://github.com/Uzlopak/helmet/actions/runs/3693726445 |
Could someone show me a library that does something similar? I want to make sure I don't break any existing workflows by integrating this change. |
I dont know. I wrote this without any template. |
Is there some quick fix till this gets merged? |
Wazzup? Any ETA? |
No ETA, sorry. I've been busy.
I'll try to get to this soon.
|
Hi, we got another issue opened because of this issue. fastify/fastify-helmet#216 Can you spare some time to review, please? |
Yes, sorry for my slowness. I'll plan to review by Friday. |
I modified this branch and made #405. Please try it out by running: npm install 'https://evanhahn.com/tape/helmet-6.0.1.tgz' Let me know if this works for you. If it does, I'll release a new version. |
I'm closing this in favor of #405. Please tell me if that works for you (or doesn't). I'll be merging that PR soon. |
I modified this and deployed it in |
Resolves #389
I tried to keep a centralized types-folder in dist, but unfortunately but after 2h of trial and error, this was the most straight forward way to fix the issue. Now we have typings next to the index.js for esm and cjs and it works.