Skip to content

Add .js extensions to internal imports#218

Merged
captbaritone merged 1 commit intomainfrom
pr/1-js-extensions
Mar 10, 2026
Merged

Add .js extensions to internal imports#218
captbaritone merged 1 commit intomainfrom
pr/1-js-extensions

Conversation

@captbaritone
Copy link
Owner

Summary

  • Switch to module: nodenext / moduleResolution: nodenext in tsconfig.json
  • Add explicit .js extensions to all relative import paths in src/ and scripts/
  • Add .js to deep graphql-js imports (graphql/language/parsergraphql/language/parser.js)
  • Switch test/profile scripts from ts-node to tsx (better nodenext support)
  • Add src/tests/integrationFixtures to tsconfig excludes
  • Update lib from es2017 to es2020

With module: nodenext but no "type": "module" in package.json, TypeScript still emits CJS. The .js extensions resolve correctly in CJS, making this a safe non-breaking preparatory change for ESM.

Part 1 of 5 — split from #217

Test plan

  • pnpm run build passes
  • pnpm run test passes
  • pnpm run lint passes

@netlify
Copy link

netlify bot commented Mar 10, 2026

Deploy Preview for grats ready!

Name Link
🔨 Latest commit 3da3d3e
🔍 Latest deploy log https://app.netlify.com/projects/grats/deploys/69b09b2797a9340008d80886
😎 Deploy Preview https://deploy-preview-218--grats.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@@ -1,8 +1,9 @@
import { version as gratsTsVersion } from "typescript";
// @ts-ignore — typescript/lib/tsserverlibrary is the standard entry point for TS plugins
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no good. I think this means TS is any typed? This diff makes not changes that should require this. what's going on?

>) {
const x = info.languageService[k];
// @ts-expect-error
// @ts-ignore — dynamic proxy setup
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is going on that thsi should change in this diff?

package.json Outdated
"prettier": "^3.6.2",
"process": "^0.11.10",
"ts-node": "^10.9.2"
"ts-node": "^10.9.2",
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're moving to tsx we should be able to drop ts-node right?

tsconfig.json Outdated
"node_modules",
"dist",
"src/tests/fixtures",
"src/tests/integrationFixtures",
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not migrate integrationFixtures as well?

"resolveJsonModule": true,
"strictPropertyInitialization": true,
"module": "nodenext",
"moduleResolution": "nodenext",
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these needed to support the move to new extensions?

Switch to `module: nodenext` / `moduleResolution: nodenext` in
tsconfig.json and add explicit `.js` extensions to all relative import
paths. This is required by Node.js ESM resolution and is also valid
for CJS, making this a non-breaking preparatory change.

Also switches test/profile scripts from ts-node to tsx, which has
better support for nodenext module resolution.
@captbaritone captbaritone merged commit 617032f into main Mar 10, 2026
14 checks passed
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.

1 participant