Skip to content
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

Fix moduleResolution:node16 CommonJS compatibility #577

Merged
merged 1 commit into from
May 11, 2024

Conversation

benjie
Copy link
Contributor

@benjie benjie commented Apr 25, 2024

Fixes #570.

This fix was tested by applying the equivalent fix to a real project exhibiting the TypeScript issue and seeing if it would now compile (yes):

diff --git a/lib/index.d.cts b/lib/index.d.cts
new file mode 100644
index 0000000000000000000000000000000000000000..3d9337b5edcde8c7b8a98aa9cd81c6b1a1451542
--- /dev/null
+++ b/lib/index.d.cts
@@ -0,0 +1,4 @@
+export { ParameterTransform, QueryParameters, InterpolatedQuery, QueryParameter, } from './preprocessor.js';
+export { processTSQueryAST } from './preprocessor-ts.js';
+export { processSQLQueryIR } from './preprocessor-sql.js';
+export { sql, TaggedQuery, PreparedQuery } from './tag.js';
diff --git a/package.json b/package.json
index bed91dd3d360132d3e0b18375f4dc7d89cb4a10b..57491d5b4b2e6f5e87016a888a01001b8614a663 100644
--- a/package.json
+++ b/package.json
@@ -4,7 +4,11 @@
   "type": "module",
   "exports": {
     ".": {
-      "types": "./lib/index.d.ts",
+      "types": {
+        "import": "./lib/index.d.ts",
+        "require": "./lib/index.d.cts",
+        "default": "./lib/index.d.ts"
+      },
       "import": "./lib/index.js",
       "require": "./lib/index.cjs",
       "default": "./lib/index.js"

and then by running npm run build and checking to see that packages/runtime/lib/index.d.cts exists (yes).

Thanks for your work on this project! ❤️

Copy link

vercel bot commented Apr 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
pgtyped ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 25, 2024 9:02am

@adelsz
Copy link
Owner

adelsz commented May 11, 2024

Thanks for investigating and fixing this @benjie

@adelsz adelsz merged commit 9693e1b into adelsz:master May 11, 2024
2 of 4 checks passed
@benjie benjie deleted the fix-module-resolution-node16 branch May 11, 2024 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

wrong module resolution when using typescript from commonjs
2 participants