Skip to content

Conversation

@Tobbe
Copy link
Member

@Tobbe Tobbe commented Jan 4, 2026

This PR migrates a couple of files for test-project generation from JavaScript to ESM-compliant TypeScript.

  • ESM/TS Migration:
    • Renamed tasks/test-project/util.js to util.mts.
    • Renamed tasks/test-project/tasks.js to tasks.mts.
    • Renamed tasks/test-project/codemods/models.ts to models.mts to support typed imports.
  • Native Node Compatibility:
    • Updated imports in test-project.mts and tasks.mts to use the .mts extension. This ensures the scripts remain executable by native Node (24+) without requiring additional loaders or transpilation steps.
  • TypeScript & Project Config:
    • Enabled allowImportingTsExtensions and noEmit in tasks/tsconfig.json to support the required ESM import syntax.
    • Added templates to the exclude list in tsconfig.json to ensure a clean tsc output for the infrastructure code.

Verification:

  • Ran yarn build:test-project --help using native node to confirm execution.
  • Verified that all modified files pass a comprehensive tsc check via yarn tsc -p tasks/tsconfig.json.

@netlify
Copy link

netlify bot commented Jan 4, 2026

Deploy Preview for cedarjs canceled.

Name Link
🔨 Latest commit 6b4a61e
🔍 Latest deploy log https://app.netlify.com/projects/cedarjs/deploys/695ab426fa3f710008fb4ea9

@github-actions github-actions bot added this to the chore milestone Jan 4, 2026
@nx-cloud
Copy link

nx-cloud bot commented Jan 4, 2026

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 6b4a61e

Command Status Duration Result
nx run-many -t test --minWorkers=1 --maxWorkers=4 ✅ Succeeded 3s View ↗
nx run-many -t build:pack --exclude create-ceda... ✅ Succeeded 6s View ↗
nx run-many -t test:types ✅ Succeeded 10s View ↗
nx run-many -t build ✅ Succeeded 5s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-04 18:54:45 UTC

@Tobbe Tobbe force-pushed the test-project-esm-migration branch from 6df58f3 to ff06e42 Compare January 4, 2026 14:48
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 4, 2026

Greptile Summary

This PR successfully migrates tasks.js and util.js to ESM-compliant TypeScript (.mts files), enabling native Node.js 24+ execution without transpilation tools.

Key Changes:

  • ESM Migration: Converted CommonJS (require/module.exports) to ES modules (import/export) in util.mts and tasks.mts
  • TypeScript Type Safety: Added proper TypeScript interfaces (WebTasksOptions, ApiTasksOptions) and type annotations throughout
  • exec Function Signature: Updated exec() to require explicit args array parameter, aligning with execa's signature and improving type safety
  • Import Path Updates: All imports now use explicit .mts extensions (e.g., from './util.mts') as required by Node's native ESM loader
  • TypeScript Config: Enabled allowImportingTsExtensions and noEmit in tasks/tsconfig.json to support .mts imports
  • CI/CD Updates: Replaced npx tsx with native node execution in GitHub workflows
  • Null Safety: Added proper OUTPUT_PATH validation checks with explicit error messages

Technical Details:

  • The .mts extension signals to Node.js that files should be treated as ES modules regardless of package.json type field
  • Added __filename and __dirname polyfills using fileURLToPath(import.meta.url) for ESM compatibility
  • Type assertions added for execa options (e.g., stdio: 'pipe' as const) to satisfy TypeScript's strict checking
  • Improved error handling with typed ExecaError class properties

Confidence Score: 5/5

  • This PR is safe to merge with no identified issues
  • The migration is methodical and complete. All file renames follow a consistent pattern, import paths are correctly updated with .mts extensions, the exec function signature change is properly applied across all call sites, TypeScript configuration is correctly adjusted for ESM, and the workflow files correctly switch from tsx to native node execution. The changes maintain backward compatibility and improve type safety.
  • No files require special attention

Important Files Changed

Filename Overview
tasks/test-project/util.mts Migrated from CommonJS to ESM with proper TypeScript types, improved exec function signature
tasks/test-project/tasks.mts Migrated from CommonJS to ESM with TypeScript interfaces, improved type safety and null checks
tasks/tsconfig.json Added allowImportingTsExtensions and noEmit for ESM .mts import support, excluded templates

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant Node as Node.js
    participant Tasks as tasks.mts
    participant Util as util.mts
    participant Execa as execa
    participant TS as TypeScript

    Dev->>Node: Run native node (24+) script
    Node->>Tasks: Import with .mts extension
    Tasks->>Util: Import functions from util.mts
    
    Note over Tasks,Util: ESM imports require explicit .mts extensions
    
    Tasks->>Tasks: Set OUTPUT_PATH with type checking
    Tasks->>Util: Call exec(cmd, args[], options)
    
    Note over Util,Execa: exec signature now requires args array
    
    Util->>Execa: execa(cmd, args, options)
    Execa-->>Util: Returns promise with result
    Util->>Util: Handle ExecaError with typed properties
    Util-->>Tasks: Return typed execution result
    
    Tasks->>TS: Type checking with interfaces
    Note over Tasks,TS: WebTasksOptions, ApiTasksOptions provide type safety
    
    Tasks-->>Node: Execute tasks with full type safety
    Node-->>Dev: Native ESM execution complete
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

5 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@Tobbe Tobbe force-pushed the test-project-esm-migration branch from 38e101d to c0af846 Compare January 4, 2026 15:09
@Tobbe Tobbe force-pushed the test-project-esm-migration branch from c0af846 to d416ed3 Compare January 4, 2026 15:16
@Tobbe Tobbe force-pushed the test-project-esm-migration branch from ef0a462 to 59c3d3e Compare January 4, 2026 15:36
@Tobbe Tobbe changed the title chore(test-project): Migrate core maintenance scripts to ESM/TS chore(test-project): Migrate tasks.js and util.js to ESM/TS Jan 4, 2026
@Tobbe
Copy link
Member Author

Tobbe commented Jan 4, 2026

@greptileai please do a full review again, and update your summary

@Tobbe Tobbe merged commit ad68caa into main Jan 4, 2026
42 checks passed
@Tobbe Tobbe deleted the test-project-esm-migration branch January 4, 2026 18:56
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.

2 participants