Skip to content

Conversation

@sjchmiela
Copy link
Contributor

@sjchmiela sjchmiela commented Jan 9, 2026

Why

The @expo/steps package was configured with a dual ESM/CJS build setup that added unnecessary complexity:

  • Two TypeScript config files (tsconfig.build.json and tsconfig.build.commonjs.json)
  • A complex build.sh script that used sed to rename .js files to .cjs
  • ESM-specific workarounds like this-file package and import.meta.url
  • .js extensions required on all imports

This complexity was not needed as the package runs in Node.js where CJS is well supported, and other packages in the workspace (like @expo/eas-build-job) use plain CJS successfully and we're not planning to move off of CJS without moving all the rest of the packages to ESM too. Having this package as the only package with ESM enabled is a bit weird.

How

  • Removed "type": "module" from package.json
  • Simplified exports to plain main and types fields pointing to dist/
  • Replaced dual tsconfig setup with a single tsconfig.build.json using module: \"commonjs\"
  • Deleted build.sh script and replaced with simple tsc command
  • Removed .js extensions from all import statements (~40 files)
  • Replaced this-file package usage with native __dirname
  • Replaced import.meta.url with __dirname equivalents
  • Simplified Jest configuration to use standard ts-jest preset
  • Updated cli.sh to point to dist/cli/cli.js
  • Removed this-file and chokidar-cli dev dependencies

Test Plan

  • yarn build completes successfully
  • yarn test passes all 281 tests across 20 test suites

- Remove 'type: module' field
- Simplify main/types to use single dist/ directory
- Remove dual exports field
- Update build scripts to use simple tsc
- Remove chokidar-cli (no longer needed for watch)
- Remove this-file dependency (replaced with native __dirname)
- Update tsconfig.build.json to use commonjs module and output to dist/
- Delete tsconfig.build.commonjs.json (no longer need dual build)
- Delete build.sh (replaced by simple tsc command in package.json)
Remove ESM-style .js extensions from all relative imports in source files.
CommonJS module resolution doesn't require explicit extensions.
- Replace this-file createContext() with native __dirname
- Remove import.meta.url usage in test files (use built-in __dirname)
- Update SCRIPTS_PATH to point to dist/scripts instead of dist_commonjs/scripts
- Update cli.sh to reference dist/cli/cli.js instead of dist_commonjs/cli/cli.cjs
- Simplify jest.config.cjs to use standard ts-jest preset (not ESM)
- Remove moduleNameMapper for .js extensions (no longer needed)
- Remove custom transform with useESM option
- Remove this-file import from runCustomFunction-test.ts
- Update SCRIPTS_PATH reference to runCustomFunction.js (not .cjs)
@sjchmiela sjchmiela marked this pull request as ready for review January 12, 2026 11:10
@sjchmiela sjchmiela requested a review from hSATAC January 12, 2026 11:10
Copy link
Contributor

@hSATAC hSATAC left a comment

Choose a reason for hiding this comment

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

I am going to have a rebase hell after this was merged. 😭

@sjchmiela
Copy link
Contributor Author

oh no

maybe git merge will be more helpful?

@sjchmiela
Copy link
Contributor Author

hmm most of your changes are in build-tools so maybe this few steps files won't be this bad

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