-
Notifications
You must be signed in to change notification settings - Fork 51
ESM migration: Add .js extensions for node16 moduleResolution #257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Migrate expressions, workflow-parser, and languageservice packages to use proper ESM imports with .js extensions that work with node16 moduleResolution. Changes: - Update tsconfig.build.json in each package to use module: node16 and moduleResolution: node16 - Add .js extensions to all relative import paths (Option B approach) - Fix yaml internal type imports in workflow-parser by defining local types - Add skipLibCheck to handle @types/node compatibility issues - Add TypeScript 5.8.3 override in root package.json - Add ESM migration plan documentation The languageserver package is deferred due to test hang issues that need further investigation. Fixes #154 - Upgrade moduleResolution from node to node16 or nodenext Fixes #110 - Published ESM code has imports without file extensions Fixes #64 - expressions: ERR_MODULE_NOT_FOUND attempting to run example Fixes #146 - Can not import @actions/workflow-parser Test results: - expressions: 1068 tests passed - workflow-parser: 292 tests passed - languageservice: 452 tests passed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR migrates three packages (expressions, workflow-parser, and languageservice) to proper ESM with node16 moduleResolution by adding .js extensions to all relative imports. This fixes critical issues where published ESM packages had extensionless imports that failed to load in Node.js 12+.
Key Changes:
- Updated
tsconfig.build.jsonin each package to usemodule: node16andmoduleResolution: node16 - Added
.jsextensions to all relative import statements in TypeScript source files - Upgraded TypeScript to 5.8.3 with override in root
package.json - Added comprehensive migration documentation
Reviewed changes
Copilot reviewed 185 out of 186 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
workflow-parser/tsconfig.build.json |
Added node16 module/moduleResolution config with skipLibCheck |
workflow-parser/src/**/*.ts |
Added .js extensions to ~100+ import statements across all source files |
workflow-parser/src/workflows/yaml-object-reader.ts |
Defined local types for yaml internals to avoid importing unexported types |
languageservice/tsconfig.build.json |
Added node16 module/moduleResolution config with skipLibCheck |
languageservice/src/**/*.ts |
Added .js extensions to ~150+ import statements across all source files |
expressions/tsconfig.build.json |
Added node16 module/moduleResolution config with skipLibCheck |
expressions/src/**/*.ts |
Added .js extensions to ~80+ import statements across all source files |
package.json |
Added TypeScript 5.8.3 as dev dependency with override configuration |
package-lock.json |
Updated TypeScript versions across workspace, maintaining 4.9.5 for languageserver |
docs/esm-migration-plan.md |
Added comprehensive 262-line migration plan documentation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Update languageserver blocker: vscode-languageserver v8.0.2 lacks ESM exports (not a test hang issue) - Document that Option B (manual .js extensions) was chosen over Option A due to ts-jest compatibility issues - Add workaround for yaml package internal types (LinePos, NodeBase) - Update migration status table with accurate reason for deferral - Add skipLibCheck note for @types/node compatibility
Summary
Users importing these packages in Node.js projects get
ERR_MODULE_NOT_FOUNDerrors because the published code is missing file extensions that Node.js requires. This PR adds the missing.jsextensions to fix the imports.Packages fixed:
@actions/expressions,@actions/workflow-parser,@actions/languageserviceDeferred:
@actions/languageserver(blocked by upstream dependency)Related Issues
moduleResolutionfromnodetonode16ornodenextin tsconfig #154@actions/workflow-parser#146Approach
Used Option B (manual
.jsextensions) from the migration plan, which:.jsextensions in source TypeScript filesnode16moduleResolutionrewriteRelativeImportExtensionsChanges
tsconfig.build.jsonin each package to usemodule: node16andmoduleResolution: node16.jsextensions to all relative import pathsskipLibCheck: trueto handle @types/node compatibility issuespackage.jsonTest Results
Deferred
The languageserver package is deferred from this migration due to test hang issues that need further investigation. See
docs/esm-migration-plan.mdfor details.Related