-
Notifications
You must be signed in to change notification settings - Fork 3.2k
fix(ts-sdk): fix job to publish ts sdk #1576
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
Conversation
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.
Greptile Overview
Summary
This PR fixes the TypeScript SDK publishing job by addressing module system compatibility issues in a monorepo environment. The changes convert the ts-sdk package from CommonJS to ES modules and fix dependency installation in the publishing workflow.The core issue was a mismatch between the package's module system declarations and its actual configuration. The workflow fix changes the dependency installation step to run bun install from the repository root instead of the package directory, which is essential for proper workspace dependency resolution in monorepos. This follows the established pattern used in the publish-cli.yml workflow.
The package configuration changes ensure consistency across the module system: package.json now declares "type": "module", tsconfig.json compiles to ES2020 modules instead of CommonJS, and vitest.config.ts includes proper module resolution conditions for the testing environment. These changes align the TypeScript compilation output with the package's ES module declaration, ensuring compatibility with modern JavaScript environments and npm publishing requirements.
The ts-sdk package maintains backward compatibility through its dual export configuration, supporting both import and require statements while internally using ES modules. This fix resolves publishing pipeline failures that were preventing the SDK from being distributed to npm.
Changed Files
| Filename | Score | Overview |
|---|---|---|
| .github/workflows/publish-ts-sdk.yml | 4/5 | Removes working directory constraint from dependency installation to fix monorepo workspace resolution |
| packages/ts-sdk/package.json | 4/5 | Adds ES module type declaration to match the package's module system configuration |
| packages/ts-sdk/tsconfig.json | 4/5 | Changes TypeScript compilation target from CommonJS to ES2020 modules for consistency |
| packages/ts-sdk/vitest.config.ts | 4/5 | Adds module resolution conditions to fix testing environment compatibility with ES modules |
Confidence score: 4/5
- This PR is safe to merge with low risk as it addresses clear module system compatibility issues
- Score reflects well-coordinated changes across multiple files that work together to resolve the publishing problem
- Pay attention to the workflow change to ensure it properly resolves workspace dependencies in the monorepo
Sequence Diagram
sequenceDiagram
participant Dev as "Developer"
participant Git as "Git Repository"
participant GHA as "GitHub Actions"
participant Bun as "Bun Runtime"
participant Node as "Node.js"
participant NPM as "NPM Registry"
participant GitHub as "GitHub Releases"
Dev->>Git: "Push changes to main branch"
Note over Dev,Git: "Changes in packages/ts-sdk/**"
Git->>GHA: "Trigger workflow: Publish TypeScript SDK"
GHA->>GHA: "Checkout repository"
GHA->>Bun: "Setup Bun (latest version)"
GHA->>Node: "Setup Node.js v18 with npm registry"
GHA->>Bun: "Install dependencies (bun install)"
GHA->>Bun: "Run tests (bun run test)"
Note over GHA,Bun: "Execute vitest in packages/ts-sdk"
GHA->>Bun: "Build package (bun run build)"
Note over GHA,Bun: "TypeScript compilation to dist/"
GHA->>Node: "Get package version from package.json"
Node->>GHA: "Return version (0.1.0)"
GHA->>NPM: "Check if simstudio-ts-sdk@0.1.0 exists"
NPM->>GHA: "Return existence status"
alt Version doesn't exist
GHA->>NPM: "Publish package (npm publish --access=public)"
Note over GHA,NPM: "Using NODE_AUTH_TOKEN secret"
NPM->>GHA: "Publish confirmation"
GHA->>GitHub: "Create GitHub Release"
Note over GHA,GitHub: "Tag: typescript-sdk-v0.1.0"
GitHub->>GHA: "Release created"
else Version already exists
GHA->>GHA: "Log skipped publish message"
end
Additional Comments (1)
-
.github/workflows/publish-ts-sdk.yml, line 82 (link)logic: The README link points to 'simstudio/sim' but the actual repository is 'simstudioai/sim' - this will result in a broken documentation link
4 files reviewed, 1 comment
Summary
fix job to publish ts sdk
Type of Change
Testing
Tested manually.
Checklist