Skip to content

chore: upgrade to typescript v6.0.2#274

Open
Tony133 wants to merge 4 commits intomainfrom
chore/upgrade-typescript-v6
Open

chore: upgrade to typescript v6.0.2#274
Tony133 wants to merge 4 commits intomainfrom
chore/upgrade-typescript-v6

Conversation

@Tony133
Copy link
Copy Markdown
Member

@Tony133 Tony133 commented Apr 3, 2026

Proposal:

  • Upgrade to typescript v6.0.2

  • Changes made:

    • post-build.js:
      - Migrated from CommonJS (require) to ESM (import) syntax
      - Added fileURLToPath + import.meta.url to polyfill __dirname in ESM context
      - Added automatic creation of dist/cjs/package.json with { "type": "commonjs" } to ensure CJS output is correctly interpreted by Node.js
      - Fixed file extension mapping: CJS output now correctly renamed from .mjs.cjs (and .d.mts.d.cts)

    • tsconfig.json:
      - Added "module": "Node16" and "moduleResolution": "Node16" for proper dual CJS/ESM support

    • package.json:
      - Bumped typebox peer dependency from ^1.0.13 to ^1.1.14
      - Updated build:cjs script: switched --moduleResolution from Node10 to bundler
      - Fixed test:node script: now runs test/index.cjs instead of test/index.js
      - Added files field to control what gets published to npm (dist, index.ts)
      - Updated typescript devDependency from ~5.9.3 to ~6.0.2
      - Added "type": "module" and "module" field to package exports
      - Reorganized exports map: moved require condition after import

  • Note:

    • eslint.config.cjs uses the .cjs extension because the package is now "type": "module".
    • TypeScript 6.x changed how module resolution works, requiring a dual CJS/ESM build setup to maintain compatibility with both import and require consumers.

This PR should resolve this PR: #272

@Tony133 Tony133 force-pushed the chore/upgrade-typescript-v6 branch from 841f8cc to 34ad6d0 Compare April 3, 2026 11:13
@Tony133 Tony133 marked this pull request as ready for review April 3, 2026 11:17
Copy link
Copy Markdown
Member

@gurgunday gurgunday left a comment

Choose a reason for hiding this comment

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

lgtm

post-build.js Outdated
import path from 'node:path'
import { fileURLToPath } from 'node:url'

const __dirname = path.dirname(fileURLToPath(import.meta.url))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

import.meta.dirname is a thing.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

-import { fileURLToPath } from 'node:url'

-const __dirname = path.dirname(fileURLToPath(import.meta.url))
+const __dirname = import.meta.dirname

Yeah, we can do it that way too

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

see commit here: 0c845ac

@Tony133 Tony133 requested a review from mcollina April 5, 2026 16:14
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.

3 participants