Repository navigation
feat(ts): npm packages in ts_bundle, ts_binary, Vitest and browser tests - #77
Merged
Merged
Conversation
…kpoint) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
ts_bundle and ts_browser_test run deno bundle when the target has npm packages, with the pinned esbuild of the new esbuild_toolchain placed where Deno looks for it (the build fails if Deno fetched one). ts_binary merges the slices and compiles with --cached-only. Vitest declares the packages in a package.json and lets deno materialize node_modules offline, in the test's working directory only. Vitest targets also stop writing into the shared vitest_toolchain: the type check used a shared cache without the slices and without --cached-only, and the unversioned npm:vitest resolved to the registry's latest and was downloaded into it; both use the cached version now. Bundles are reproducible (no random temp path in them). Part of #61. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
4 tasks
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.
Part of #61: the wiring that #62 left out.
ts_npm_modulepackages now work everywhere a target can use them, not only in type checks and Deno tests.What changed
ts_bundle/ts_browser_test: with npm packages,deno bundle(Deno resolvesexports, CommonJS and subpaths itself, as it does forts_test; esbuild cannot resolvenpm:). Deno would download its own esbuild, so the newesbuild_toolchainprovides the pinned binary (sha256 per platform; byte-identical to the one Deno fetches), placed where Deno looks for it. If Deno downloads one anyway the build fails, rather than going non-hermetic. Without npm packages the old esbuild path is unchanged.ts_binary: merges the slices,deno compile --cached-only. The executable embeds the packages and runs with no cache or network (checked with an emptyDENO_DIR).npm:specifiers and Vite cannot resolve them. The runner declares the packages (exact versions) in apackage.jsonanddeno run --node-modules-dir=auto --cached-onlymaterializesnode_modulesoffline from the merged cache. Both exist only in the test's working directory underplz-out/tmp(deleted after the run; verified, and nothing appears in the source tree). This is the mechanism the coverage mode already used.Two bugs found on the way (fixed here)
vitest_toolchainoutput. Their type check ran against the shared cache without the slices and without--cached-only, so Deno downloaded the packages into it. And the unversionednpm:vitestresolves to the registry's latest (5.0.3), not the cached 5.0.1, so Deno also downloaded that into the shared cache at run time, silently. They now use a per-run copy when slices are involved, and the cached version (npmcache.CachedVersion) for vitest and@vitest/coverage-v8.DENO_DIRis now a fixed name in the working directory; three forced rebuilds give identical hashes.Known limits (documented in usage.md)
deno bundleis marked experimental by Deno, and the directory it looks in for esbuild is internal to it, so the plugin knows it per Deno version (esbuildCacheVersions;--esbuild-cache-versionfor others). A Deno bump fails the npm bundle fixtures until it is updated.deno compiledownloads itsdenortruntime from dl.deno.land on every build, with or without npm packages. Pre-existing and not pinned here.ts_bundlepath still runsdeno run npm:esbuild, which fetches esbuild at run time. Pre-existing.Tests
tools/please_ts(new: bundle with a fakedenocovering the esbuild placement, arguments, per-run cache, "Deno downloaded its own esbuild" detection and failures; binary; compile on the Vitest path;CachedVersion; the Vitest package.json, dependencies and cache directory).highlight.js(CommonJS, subpaths), of the exports-onlylegacy-modeswith its declared and its automatically resolved 12-package closure; a compiled binary that runs with an emptyDENO_DIR; a browser test that bundleshighlight.jsand runs in headless Chromium; Vitest tests for both packages (also with coverage). ZeroDownloadlines in the Vitest runs.plz build //...andplz test //...: 35 targets, 324 tests passed locally.🤖 Generated with Claude Code