Repository navigation
Conversation
…rces) `scriptc build|run|coverage --sources[=<manifest>]` reads a scriptc-pm schema-1 manifest (default: the nearest .scriptc-pm/manifest.json above the entry) and compiles each augmented package instance from its TypeScript overlay instead of its published JS. - Instances are keyed by realpath(installedDir). The resolver redirects an import that lands in an instance's installed directory to the instance's exports inside its overlay (resolveSourceOverlayModule); overlay files compile as program modules. - tsgo gets the pilot's "paths" injection, but only for names with a single augmented instance; other instances start dropped, and a second installed copy of a redirected name drops it too. - Fallback per instance through the drop-and-reload loop: a preflight diagnostic in an overlay, a program type error naming it, a top-level require() edge to it, a lowering refusal inside it, or a program that only fails against the source surface (probe) drops the overlay and the package compiles from published JS. Reasons are reported on stderr and as "source"/"source-fallback" rows in coverage. - Build caches key by the manifest's lockDigest and bytes instead of being bypassed; the network-fetching --provenance-sources pilot stays uncacheable and becomes one more producer of the same overlay set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
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.
Summary
This is the compiler side of the scriptc-pm proof of concept: DESIGN §5.6 Phase 0 items 1–6, plus the cheapest form of item 7. scriptc reads a scriptc-pm manifest describing TypeScript-source overlays for installed npm package instances and compiles those instances from source instead of from their published JS. Any overlay that does not compile falls back to the published JS, one package at a time.
What changes
Manifest input.
--sources[=<manifest>]works onbuild,run,coverageandbuild --lib. Without a value, scriptc walks up from the entry (or the profile) to the nearest.scriptc-pm/manifest.json.--sourcesand--provenance-sourcesare mutually exclusive. The bootstrap fast paths andcache warmstep aside for both.Instance-keyed registry (
frontend/source-overlays.ts).realpath(installedDir).--provenance-sourcespilot keeps working. It is now one more producer of the same overlay set:setProvenanceSourcesconverts its packages to instances. Its fetch code is untouched. Its set is marked uncacheable.Resolver redirect.
resolveSourceOverlayModuleis the new first step ofresolveProjectModule.node_moduleswalk from the importing file. When the package directory's realpath is an active instance, the subpath resolves against the instance'sexportsinsideoverlayDir, and the result is a program source.resolveNpmImport7and library-mode auto-detection skip redirected imports.node_moduleslink to the instance's own pnpm dependencies. When such an import lands in another augmented instance, it is redirected too, for example server-sdk's source importing core.Agreement with tsgo (MVP).
pathsentries for every exported subpath, including*patterns, of active instances.ambiguous-name: …).pathsentry would disagree with it.Attribution.
static from sourceandpublished JS (source overlay: <reason>)(newNpmStaticStatusvaluessourceandsource-fallback). A generalizedsource overlayssection reports per-package statement totals, the source origin, fallbacks and manifest notes.Per-package fallback. These triggers drop an instance, and the drop-and-reload loop retries the package from published JS:
require()edge to the overlay (the item 7 MVP);As a last resort, a program that fails preflight or lowering outside every overlay is probed with all used overlays dropped. The probe is kept only when it compiles cleanly. This covers consumers that fail only against a declared source type that the published JS's inferred surface avoids (mitt).
Each reason goes to stderr on
buildand to coverage. If the published JS also fails, the build fails exactly as it does today.Build cache.
provenanceSources() === nullbypasses are gone.lockDigestplus a digest of the manifest bytes. The field is omitted without--sources, so existing keys are unchanged.Evidence
The fixture is
tests/fixtures/source-overlays: a real pnpm 11 isolated install ofpath-to-regexp@6.3.0,@openfeature/server-sdk@1.18.0,@openfeature/core@1.9.2andmitt@3.0.1, with the upstream TypeScript at the published commits.tests/harness/source-overlays.test.tswrites.scriptc-pm/the wayscriptc-pm syncwould and drives the CLI. Results on Linux:--sourcesroutes.ts: path-to-regexpparseString#concatfence in the ES5 dist)flags.ts: OpenFeature server SDKcaptureRejections)emit.ts: mittrequire.ctsrequire()edge; same failure as published--sourcesbuildexecutable-cache-hitlockDigestValidation:
tests/harness/source-overlays.test.ts,tests/harness/provenance.test.ts, and the unit tests insource-overlays.test.ts,resolve.test.ts,native/compiler.test.ts,executable-cache.test.tsandverdict-cache.test.tspass.tests/harness/npm-static.test.tspasses (95/95).tests/harness/npm.test.tshas one failure,node24-url-authority, which also fails on the untouched base in the same sandbox.pnpm lintandpnpm format:checkare clean.--emit=irbuild ofpackages/compiler/src/native/cli.tssucceeds with no diagnostics.pnpm test:ts7 --baselines-onlyis complete.tests/harness/self-hosting-native-driver.test.ts, and the full sandbox gate.coverage.test.ts's whole-corpus case hit its 600 s timeout while running concurrently with the npm suites.Findings
Fallbacks are the norm for now. For the sample packages, source overlays mostly reach the next layer of compiler gaps. Each is reproducible outside overlays:
tokensToRegexp);RegExpExecArraydestructuring, SC1031;Record<string, any>unions, SC2009;Error#causeredeclaration;captureRejections;unknown-typed class fields (async-sema);Temporalglobal (smol-toml).Only path-to-regexp's parser compiles end to end today.
Version skew is real. server-sdk@1.18.0's source does not typecheck against the installed core 1.9.2, because it was built against core 1.8.0 sources in its monorepo. Published
.d.tserrors are never reported, but source errors are.Declared types can be worse than inferred ones. The declared surface of a source overlay can lower worse than the published JS's inferred surface (mitt), so the published-surface probe is necessary to keep
--sourcesfrom ever making a build worse.The overlay
package.jsontypefield is optional. Syntax detection handles typeless ESM-syntax overlays.Follow-ups
require()interop shape frompublishedFormat, instead of dropping the overlay.useDefineForClassFields; OpenFeature targets ES2015).detectAutoPackages(§5.6.9).dependencies.mdx.🤖 Generated with Claude Code