Skip to content

Convert TiaCodegen-ts to ESM: add .js extensions to all imports/exports - #32

Merged
jogibear9988 merged 2 commits into
mainfrom
copilot/add-js-file-extensions
Feb 21, 2026
Merged

Convert TiaCodegen-ts to ESM: add .js extensions to all imports/exports#32
jogibear9988 merged 2 commits into
mainfrom
copilot/add-js-file-extensions

Conversation

CopilotAI commented Feb 21, 2026

Copy link
Copy Markdown
Contributor

The TypeScript library needs to be consumable as a native ESM module. This requires .js extensions on all relative imports/exports in compiled output and switching from CommonJS to NodeNext module resolution.

Changes

  • tsconfig.json: moduleNodeNext, moduleResolutionNodeNext, added isolatedModules: true
  • package.json: Added "type": "module", exports field, updated Jest config to ts-jest/presets/default-esm with moduleNameMapper for .js.ts test resolution, updated test script to use --experimental-vm-modules
  • All src/ files: Added .js to every relative import/export specifier
  • src/index.ts: Changed interface re-exports to export type (required by isolatedModules)
  • src/Commands/BaseOperationOrSignal.ts: Removed circular imports of And/Or that worked under CommonJS lazy resolution but cause TDZ errors in ESM. Replaced instanceof And/Or with constructor.name checks since neither class has subclasses
// Before (CommonJS only — circular imports hoisted in ESM cause TDZ errors)import{And}from'./And.js';import{Or}from'./Or.js';if(thisinstanceofAnd||thisinstanceofOr){ ... }// After (ESM-safe)constname=this.constructor.name;if(name==='And'||name==='Or'){ ... }
Original prompt

This section details on the original issue you should resolve

<issue_title>Add .js to all imports/exports in typescript</issue_title>
<issue_description>We want to use the library directly as ESM lib.
So all the import and exports need a file extension.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: jogibear9988 <364896+jogibear9988@users.noreply.github.com>
CopilotAI changed the title [WIP] Add .js to all imports/exports in TypeScriptConvert TiaCodegen-ts to ESM: add .js extensions to all imports/exportsFeb 21, 2026
@jogibear9988
jogibear9988 marked this pull request as ready for review February 21, 2026 15:20
@jogibear9988
jogibear9988 merged commit c559e92 into mainFeb 21, 2026
1 check passed
@jogibear9988
jogibear9988 deleted the copilot/add-js-file-extensions branch February 21, 2026 15:21
Sign up for freeto 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.

Add .js to all imports/exports in typescript

2 participants

@jogibear9988