Skip to content

chore: move CJS scripts to ESM and use strippable types #10887

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

Merged
merged 4 commits into from
Mar 3, 2025

Conversation

43081j
Copy link
Contributor

@43081j 43081j commented Feb 25, 2025

Depends on #10886

This prepares the various scripts for being consumed by node directly (via the strip-types feature).

Primarily this means the following:

  • Our packages are type: "commonjs", so some of our scripts are incorrectly *.ts (CJS) which tsx covers up by the fact it transpiles it to CJS on the fly
    • Moving any *.ts scripts to *.mts solves this
  • enum are not allowed since they are not strippable types. instead, we just use a string union

DRAFT UNTIL #10885 is accepting PRs and #10886 is merged

PR Checklist

Also related to #10885

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @43081j!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

@43081j 43081j changed the title Nodets types prep cleanup: move ESM scripts to .mts and use strippable types Feb 25, 2025
Copy link

netlify bot commented Feb 25, 2025

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 08096b0
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/67c48baee728e10008e1d74d
😎 Deploy Preview https://deploy-preview-10887--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 93 (🔴 down 5 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (🟢 up 8 from production)
SEO: 98 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

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

@43081j 43081j changed the title cleanup: move ESM scripts to .mts and use strippable types chore: move ESM scripts to .mts and use strippable types Feb 25, 2025
Copy link

nx-cloud bot commented Feb 25, 2025

View your CI Pipeline Execution ↗ for commit 08096b0.

Command Status Duration Result
nx run-many --target=build --exclude website --... ✅ Succeeded 5s View ↗
nx run-many --target=clean ✅ Succeeded 10s View ↗

☁️ Nx Cloud last updated this comment at 2025-03-02 19:45:50 UTC

@kirkwaiblinger kirkwaiblinger changed the title chore: move ESM scripts to .mts and use strippable types chore: move CJS scripts to ESM and use strippable types Feb 27, 2025
@kirkwaiblinger
Copy link
Member

@43081j I edited a few things with which issues are linked. Feel free to undraft once ready for review!

@kirkwaiblinger kirkwaiblinger added the repo maintenance things to do with maintenance of the repo, and not with code/docs label Feb 27, 2025
This switches various repo scripts to be `*.mts` files (since that is
what they actually are, given we don't build them into CJS output, yet
our package `type` is `"commonjs"`).

This will allow newer Node to execute them correctly, as they will now
infer the correct module type.

The `generate-lib` script has also been changed to use only strippable
types (i.e. no enums).

Both of these changes mean we have the option to drop `tsx` in future
and use `--experimental-strip-types` (when it is no longer
experimental).
@43081j 43081j force-pushed the nodets-types-prep branch from 9ce4c74 to ab5ac08 Compare March 1, 2025 19:36
Copy link

codecov bot commented Mar 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.43%. Comparing base (3c7b8ff) to head (08096b0).
Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10887   +/-   ##
=======================================
  Coverage   87.43%   87.43%           
=======================================
  Files         468      468           
  Lines       16040    16040           
  Branches     4649     4649           
=======================================
  Hits        14025    14025           
  Misses       1658     1658           
  Partials      357      357           
Flag Coverage Δ
unittest 87.43% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@43081j 43081j marked this pull request as ready for review March 1, 2025 19:36
@43081j
Copy link
Contributor Author

43081j commented Mar 1, 2025

this should be good to go now @kirkwaiblinger

Copy link
Member

@kirkwaiblinger kirkwaiblinger left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks! One question but no action requested

@JoshuaKGoldberg JoshuaKGoldberg added the awaiting response Issues waiting for a reply from the OP or another party label Mar 2, 2025
@43081j
Copy link
Contributor Author

43081j commented Mar 2, 2025

Not too sure why ci is failing. Doesn't seem related to the changes here, but that is more concerning 😅 if main has problems

Maybe catching up from main will help. Next time I'm at a laptop I'll do that unless someone beats me to it

Copy link
Member

@kirkwaiblinger kirkwaiblinger left a comment

Choose a reason for hiding this comment

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

Thanks for making these changes! It's always satisfying to me to get TS a step closer to out-of-the-box node.js rather than requiring layers of transpilation and/or CLI tools just to be able to execute 🙂

Re the integration test that was failing, that was fixed in #10906 👍

@kirkwaiblinger kirkwaiblinger added 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge and removed awaiting response Issues waiting for a reply from the OP or another party labels Mar 2, 2025
@JoshuaKGoldberg JoshuaKGoldberg merged commit 2810ceb into typescript-eslint:main Mar 3, 2025
94 of 95 checks passed
@43081j 43081j deleted the nodets-types-prep branch March 3, 2025 23:11
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge repo maintenance things to do with maintenance of the repo, and not with code/docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: tsx executes scripts in ESM context in Node 23.6
3 participants