Port transpileModule, transpileDeclaration - #4849
Port transpileModule, transpileDeclaration#4849Andrew Branch (andrewbranch) wants to merge 5 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds single-file JavaScript and declaration transpilation to the native compiler API.
Changes:
- Implements transpilation with diagnostics, source maps, cancellation, and minimal declaration libraries.
- Exposes synchronous and asynchronous string/file APIs.
- Clarifies builder-only declaration emit naming and adds coverage.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
internal/transpile/transpile.go |
Implements transpilation. |
internal/transpile/transpile_test.go |
Tests core behavior. |
internal/execute/incremental/affectedfileshandler.go |
Uses renamed signature emit mode. |
internal/compiler/program.go |
Updates emit-mode handling. |
internal/compiler/emitter.go |
Renames builder signature mode. |
internal/api/session.go |
Handles transpilation requests. |
internal/api/proto.go |
Defines protocol methods and types. |
_packages/native-preview/test/sync/api.test.ts |
Tests synchronous APIs. |
_packages/native-preview/test/async/api.test.ts |
Tests asynchronous APIs. |
_packages/native-preview/src/api/sync/api.ts |
Exposes generated synchronous APIs. |
_packages/native-preview/src/api/async/api.ts |
Exposes asynchronous APIs. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
| EmitOnlyJs | ||
| EmitOnlyDts | ||
| EmitOnlyForcedDts | ||
| EmitOnlyBuilderSignature |
There was a problem hiding this comment.
I renamed this internal enum member because it's intended to be used as an opaque description of what the builder needs, which is specifically .d.ts files without declaration maps. The other ForceDTS option (inherited from Strada) includes declaration maps.
| "gotest.tools/v3/assert" | ||
| ) | ||
|
|
||
| func TestTranspileModule(t *testing.T) { |
There was a problem hiding this comment.
Can we port over the transpile test runner instead of relying on unit tests?
There was a problem hiding this comment.
This exposed a couple real emit diffs, which I don’t have time to address here before the beta.
In the TS API, these are exposed as
transpileModule(input: string, options?: TranspileOptions)transpileModuleFromFile(fileName: string, options?: TranspileOptions)transpileDeclaration(input: string, options?: TranspileOptions)transpileDeclarationFromFile(fileName: string, options?: TranspileOptions)Part of #4830 (cc John Reilly (@johnnyreilly))