-
Notifications
You must be signed in to change notification settings - Fork 240
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
✨ Switch to nodenext resolution #1026
Changes from 6 commits
5c89e98
a282b6e
451a223
d0f9fde
3ed1667
31c8f4f
4ea6d32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was the only way I found to have at the same time:
It's also possible to upgrade There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wow that feels like kind of a dubious method tbh ^^' iiuc from https://www.typescriptlang.org/docs/handbook/modules/reference.html#node16-nodenext, the most correct way to get cjs types would be to call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you need to edit the package.json, you can run tsc with But anyway I think the types are the same, only the js flies would be different. And with your solution we still need to rename / edit the .ts and .map files. Thinking about it, we should not use But it was already broken, problaby There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @andrewbranch too on this btw, in case he has some insights for us by any chance on the best way to emit both ESM and CJS types through There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
well, the thing is, it's not the same (from the link shared in my previous message):
^^ I guess this doesn't affect declaration files though, so maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't have dynamic import calls anyway in (to keep in mind for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://github.com/isaacs/tshy automates this in a safe way There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tysm for the pointer, we'll check it out! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Just copy over the already generated .d.ts and .d.ts.map files to .d.cts and .d.cts.map files | ||
import { readdirSync, readFileSync, statSync, writeFileSync } from "node:fs"; | ||
import { join } from "node:path"; | ||
|
||
function recursiveCopy(path: string) { | ||
for (const item of readdirSync(path)) { | ||
if (item.endsWith(".d.ts")) { | ||
const content = readFileSync(join(path, item), "utf-8"); | ||
writeFileSync(join(path, item.replace(".d.ts", ".d.cts")), content.replaceAll(".d.ts.map", ".d.cts.map")); | ||
} else if (item.endsWith(".d.ts.map")) { | ||
const content = readFileSync(join(path, item), "utf-8"); | ||
writeFileSync(join(path, item.replace(".d.ts.map", ".d.cts.map")), content.replaceAll(".d.ts", ".d.cts")); | ||
} else if (statSync(join(path, item)).isDirectory()) { | ||
recursiveCopy(join(path, item)); | ||
} | ||
} | ||
} | ||
|
||
recursiveCopy("dist"); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import * as inputs from "./inputs"; | ||
import * as curl from "./curl"; | ||
import * as python from "./python"; | ||
import * as js from "./js"; | ||
import * as inputs from "./inputs.js"; | ||
import * as curl from "./curl.js"; | ||
import * as python from "./python.js"; | ||
import * as js from "./js.js"; | ||
export * from "./types.js"; | ||
|
||
export { inputs, curl, python, js }; |
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.
I'm curious, do we need this at all? (given it's resolved automatically based on the
require
/import
values anyway, iiuc)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.
(I also see the second option at https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseESM.md#common-causes doesn't have a
types
entry at all)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.
I don't know - maybe for non-node / older contexts?