You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(turbo-utils): convert package to dual ESM/CommonJS build
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
Copy file name to clipboardExpand all lines: packages/turbo-utils/src/getTurboRoot.ts
+1-2Lines changed: 1 addition & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,13 @@
1
1
importtype{Schema}from"@turbo/types";
2
2
import{findRootSync}from"@manypkg/find-root";
3
3
importjson5from"json5";
4
-
import{searchUp}from"./searchUp";
4
+
import{searchUp}from"./searchUp.js";
5
5
6
6
interfaceOptions{
7
7
cache?: boolean;
8
8
}
9
9
10
10
functioncontentCheck(content: string): boolean{
11
-
// eslint-disable-next-line import/no-named-as-default-member -- json5 exports different objects depending on if you're using esm or cjs (https://github.com/json5/json5/issues/240)
0 commit comments