Multi-input compilation#1
Merged
Merged
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 48a61ec. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What changes
Adds a virtual project compile path to
tswasmwith two public call shapes:The string form is shorthand for a generated virtual project with
entrypoint: 'index.ts', anindex.tssource file, and a virtualtsconfig.jsonselecting that file. (The older{ code, fileName }object shape is removed.)Project requests resolve relative imports between in-memory files. Emitted JavaScript is returned from
result.outputs:entrypointselects which emitted output also populatesresult.js:Project requests can include an optional virtual
cwdand an optional virtualtsconfigfile path. Iftsconfigis omitted andfilescontainstsconfig.jsonat the virtual cwd,tswasmuses that virtual config liketscwould. Passingtsconfig: 'tsconfig.lib.json'selects a non-default config file, and the selected config must be present infiles.Type roots are configured the normal TypeScript way in
compilerOptions.typeRoots; when absent, TypeScript Go derives defaultnode_modules/@typesroots from the virtual cwd/config path.Reviewer notes
result.jsis populated from the emitted output forentrypointwhen one is provided.result.outputs, including.js,.mjs, and.cjsoutputs.fileNamewhen TypeScript Go reports one, relative to the virtualcwdwhen possible.node_modules, package dependencies, or declaration files unless they are supplied in the projectfilesmap.CONTEXT.mdto pin down the virtual project/config/cwd/entrypoint terminology from the spike.Verification
pnpm run build && pnpm exec vitest run test/compile.test.tspnpm run release:checkNote
Medium Risk
Public API break (
CompileRequestremoved) and substantial wasm compile-path changes affect how all callers build inputs and read results; behavior is well covered by new integration tests but edge cases around config/file selection remain possible.Overview
Replaces the single-file
{ code, fileName }API with virtual project compilation:compile({ files, entrypoint?, tsconfig?, cwd? }), whilecompile(string)still works by expanding toindex.tsplus a virtualtsconfig.json.The Go wasm layer now builds programs from an in-memory file map, optionally parses virtual tsconfig via TypeScript Go’s config parser (including default
tsconfig.jsonat virtualcwd), emits all JS outputs intoresult.outputs(.js/.mjs/.cjs), and setsresult.jsfrom the entrypoint emit. Diagnostics gain optionalfileName;successis derived from diagnostics even when emit is skipped (e.g.noEmit).Docs (
README.md, newCONTEXT.md) and integration tests cover multi-file imports, virtualnode_modules/typeRoots, and benchmarks now exercise the project request shape.Reviewed by Cursor Bugbot for commit dec08d0. Bugbot is set up for automated code reviews on this repo. Configure here.