-
Notifications
You must be signed in to change notification settings - Fork 154
feat: bundle in CJS and ESM formats #1130
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1130 +/- ##
==========================================
- Coverage 97.48% 97.47% -0.01%
==========================================
Files 49 49
Lines 5997 5974 -23
Branches 1518 1518
==========================================
- Hits 5846 5823 -23
Misses 149 149
Partials 2 2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
6a30950 to
618a9fc
Compare
There were some necessary changes to make the code compatible with tsdown bundling: 1. Replace CJS require with ESM import 2. Replace CJS export with ESM default export 3. Type all node-type guards explicitly to avoid "This is likely not portable. A type annotation is necessary" errors
78e7c26 to
05f7fcf
Compare
287f839 to
7361a6e
Compare
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.
Pull request overview
This PR modernizes the build infrastructure by converting from CommonJS to ESM format and setting up a bundler (tsdown). The changes enable dual CJS/ESM bundle distribution, improve TypeScript configuration for module preservation, and reorganize the source structure from lib/ to src/ to better distinguish between source code and built artifacts.
Key changes:
- Convert module system from CommonJS (
require/module.exports) to ESM (import/export default) - Update Node.js built-in imports to use
node:protocol - Rename
lib/directory tosrc/throughout the codebase - Configure TypeScript with
"module": "preserve"and"noEmit": truefor bundler compatibility
Reviewed changes
Copilot reviewed 59 out of 106 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| vitest.setup.ts | New test setup file for typescript-eslint RuleTester |
| vitest.config.ts | Updated setup file path and coverage directory from lib/ to src/ |
| tsconfig.json | Changed module system to "preserve" with noEmit enabled |
| tools/generate-configs/utils.ts | Converted to ESM imports, updated dirname handling, changed export to default |
| tools/generate-configs/index.ts | Updated import paths from lib/ to src/ |
| tests/**/*.test.ts | Updated all test imports from ../lib/ or ../../../lib/ to ../src/ or ../../src/ |
| tests/test-utils.ts | Updated import path to ../src/utils |
| tests/fake-rule.ts | Updated import path to ../src/create-testing-library-rule |
| tests/eslint-remote-tester.config.js | Deleted file (removed) |
| tests/create-testing-library-rule.test.ts | Fixed import path from ./lib/test-utils to ./test-utils |
| tests/index.test.ts | Updated paths from lib/ to src/ and imports to ESM |
| src/utils/*.ts | New ESM files with export statements |
| src/rules/*.ts | New ESM rule files with default exports |
| src/node-utils/*.ts | New ESM utility files |
| src/index.ts | Converted to ESM with default export, updated package.json imports |
| src/create-testing-library-rule/*.ts | New ESM files for rule creation utilities |
| src/configs/*.ts | Converted config exports from export = to export default |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Checks
Changes
tsdown)package.jsonfields for CJS and ESM exposed filespublintfor linting the published bundletypeto "module"lib/tosrc/to better reflect the folder holds the source code but must be bundledContext
Closes #900