Repository navigation
feat: store imported sources once and share import resolution between compileFile and compileString - #453
Merged
Conversation
… compileFile and compileString - Store the source code of every imported file once in the artifact's `debug.sources`, replacing the full file text on every debug frame. It is keyed by the file's logical path (also used as the frame's `sourceFile`), so it can be passed as `files` to `compileString` to recompile the artifact - Identify imported files by a logical path that compileFile and compileString compute the same way: a POSIX path relative to the main source, or `package:<import path>` for files in packages. Package files are provided under `package:` keys in compileString's `files` option - Resolve imports from real (symlink-resolved) paths, so a package's own dependencies are found when it is installed with pnpm or linked - Reject importing multiple copies of a package, and absolute import paths - Quote object keys that are not identifiers in TS artifacts Closes #449 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## next #453 +/- ##
==========================================
- Coverage 88.76% 88.75% -0.02%
==========================================
Files 61 61
Lines 5012 5025 +13
Branches 927 933 +6
==========================================
+ Hits 4449 4460 +11
- Misses 433 434 +1
- Partials 130 131 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch was successfully deployed
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.
Closes #449, and replaces #450.
Artifacts now store the source code of every imported file once, in a format that
compileStringaccepts directly, so any artifact can be recompiled from itself:Changes
debug.sources: every imported file's source code is stored once in the artifact, instead of the full file text on every debug frame (DebugFrame.sourceis removed). It contains every file the compiler reads, including files whose definitions are unused, so that recompiling works.compileFileandcompileStringcompute in the same (shared) way. This is the file's key infilesanddebug.sources, and the frame'ssourceFile:package:<import path>, e.g.package:@example/math-lib/math.cash. Relative imports inside a package stay inside it. This keeps package files apart from local files with the same path, which previously resolved to the samefileskey (so e.g. a missing./inimport "lib/math.cash"compiled withcompileStringbut not withcompileFile).npm linkor workspaces. Linked packages keep their package names in the artifact.node_modules/fooandnode_modules/bar/node_modules/foo), since one logical path can only refer to one file. These copies usually define the same functions, so this was already a redefinition error in practice.debug.sources.debug.sources.debug.sources) are quoted.debug.sources, recompiling from an artifact,package:keys, symlinks and absolute imports.Only formats and behaviour from 0.14 prereleases change, so there is no compatibility for per-frame
sourceor the old package keys.Tests
debug.sourcesand must give an identical artifact.debug.sourcescontains files without used definitions, and is absent without imports.fileskeys, local and package files with the same path stay separate, and transitive package dependencies give the same artifact from disk and from memory.yarn build,yarn test,yarn lintandyarn spellcheckpass.Note: the VS Code extension mirrors cashc's import resolution in
ImportGraph.ts, and will need a follow-up to use the newpackage:keys and real paths.🤖 Generated with Claude Code