Skip to content

Conversation

@tylerbutler
Copy link
Member

Summary

Converts the @fluidframework/build-tools package from CommonJS to ES Modules, following patterns from build-infrastructure.

Changes

  • Package configuration: Added "type": "module" and exports field to package.json
  • Bin scripts: Converted from CJS require() to ESM .mjs files with dynamic imports
  • __dirname replacement: Uses fileURLToPath(import.meta.url) pattern in 3 files (utils.ts, workerPool.ts, test/init.ts)
  • Dynamic requires: Added createRequire from node:module for runtime module loading (tscUtils.ts, taskUtils.ts, worker files)
  • Import extensions: Added .js extensions to all relative imports (~50 files)
  • ESM-incompatible packages: Updated fs-extra, json5, and typescript to use default import + destructuring pattern
  • find-up: Simplified from dynamic import workaround to standard ESM import
  • Test config: Updated tsconfig to use node16 module resolution

Convert the @fluidframework/build-tools package from CommonJS to ES Modules,
following the patterns established in build-infrastructure.

Key changes:
- Add "type": "module" and exports field to package.json
- Convert bin scripts from require() to ESM imports (.mjs)
- Replace __dirname with fileURLToPath(import.meta.url) pattern
- Add createRequire for dynamic require() and require.resolve() calls
- Add .js extensions to all relative imports
- Update ESM-incompatible imports (fs-extra, json5, typescript) to use
  default import pattern
- Simplify find-up imports (no longer need dynamic import workaround)
- Update test tsconfig to use node16 module resolution
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.

1 participant