Skip to content

Conversation

@tknickman
Copy link
Member

This commit converts turbo-utils from a TypeScript-only package to a dual ESM/CommonJS package with proper build outputs, addressing compatibility requirements across different module systems.

Key changes:

  • Package.json: Added "type": "module" and dual export configuration with separate entry points for ESM, CommonJS, and TypeScript declarations
  • Build system: Implemented three-stage build process (ESM, CJS, types) with corresponding TypeScript configurations
  • Import statements: Updated all relative imports to include .js extensions for ESM compatibility
  • Module handling: Fixed imports for packages like tar, fast-glob, and picocolors to work with ESM
  • Jest configuration: Added module name mapping to handle .js extension resolution in tests
  • TypeScript configs: Created separate tsconfig files for ESM (tsconfig.json), CommonJS (tsconfig.cjs.json), and type declarations (tsconfig.types.json)

Build outputs:

  • dist/esm/: ES module build for modern environments
  • dist/cjs/: CommonJS build for Node.js compatibility
  • dist/types/: TypeScript declaration files

The package now supports both import and require syntax while maintaining backward compatibility through the dual export system.

Description

Testing Instructions

@tknickman tknickman requested a review from a team as a code owner August 11, 2025 19:11
@vercel
Copy link
Contributor

vercel bot commented Aug 11, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
examples-basic-web Ready Ready Preview Comment Sep 3, 2025 4:02am
examples-designsystem-docs Ready Ready Preview Comment Sep 3, 2025 4:02am
examples-gatsby-web Ready Ready Preview Comment Sep 3, 2025 4:02am
examples-kitchensink-blog Ready Ready Preview Comment Sep 3, 2025 4:02am
examples-nonmonorepo Ready Ready Preview Comment Sep 3, 2025 4:02am
examples-svelte-web Ready Ready Preview Comment Sep 3, 2025 4:02am
examples-tailwind-web Ready Ready Preview Comment Sep 3, 2025 4:02am
examples-vite-web Ready Ready Preview Comment Sep 3, 2025 4:02am
turbo-site Ready Ready Preview Comment Sep 3, 2025 4:02am

This commit converts turbo-utils from a TypeScript-only package to a dual
ESM/CommonJS package with proper build outputs, addressing compatibility
requirements across different module systems.

Key changes:
- Package.json: Added "type": "module" and dual export configuration with
  separate entry points for ESM, CommonJS, and TypeScript declarations
- Build system: Implemented three-stage build process (ESM, CJS, types) with
  corresponding TypeScript configurations
- Import statements: Updated all relative imports to include .js extensions
  for ESM compatibility
- Module handling: Fixed imports for packages like tar, fast-glob, and
  picocolors to work with ESM
- Jest configuration: Added module name mapping to handle .js extension
  resolution in tests
- TypeScript configs: Created separate tsconfig files for ESM (tsconfig.json),
  CommonJS (tsconfig.cjs.json), and type declarations (tsconfig.types.json)

Build outputs:
- dist/esm/: ES module build for modern environments
- dist/cjs/: CommonJS build for Node.js compatibility
- dist/types/: TypeScript declaration files

The package now supports both import and require syntax while maintaining
backward compatibility through the dual export system.

update
@tknickman tknickman force-pushed the tomknickman/turbo-4812-convert-turboutils-to-esm branch from b7de3bf to 9e5a325 Compare August 12, 2025 15:45
@turbo-orchestrator turbo-orchestrator bot added the pkg: turbo-eslint eslint-config-turbo and eslint-plugin-turbo label Aug 12, 2025
anthonyshew added a commit that referenced this pull request Aug 25, 2025
### Description

Because JavaScript packaging is so finnicky, I'm thinking its a good
idea to make sure our interfaces stay ecosystem compliant. PRs like
#10747 and
#10754 have potential to break
things, so its nice to have some sanity checking. (I haven't checked yet
if those PRs specifically are right, but they made me think about adding
some tooling like this.)

### Testing Instructions

CI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: turbo-eslint eslint-config-turbo and eslint-plugin-turbo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants