You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit was created on GitHub.com and signed with GitHub’s verified signature.
Changed
rolldown 1.3.2 (from 1.3.0) and oxc 0.158 (from 0.157), which 1.3.2 requires. oj build output still matches vite build byte for byte on the parity apps. What reaches oj from rolldown 1.3.1 and 1.3.2 is bundler fixes and speedups: a build fails instead of hanging when a module task panics, a partial dev rebuild that adds a relative-path external no longer panics, var is hoisted out of top-level catch, for-in and for-of heads of wrapped modules, top-level await in a top-level catch block is detected, a module without module syntax that is both imported and required is CommonJS, cross-chunk export names no longer depend on module load order, statements made dead by imported constants are dropped before chunk linking, and incremental rebuilds reuse link-time facade symbols and share sourcemap chains.
Fixed
Dev server: a dependency installed after the server started and imported through await import("pkg") in a handler loads, where the import rejected with "Failed to fetch dynamically imported module" (a 504) a moment before the page reloaded; a second click after the reload worked. The edit that imports the new package registers it for re-optimization and rewrites the import to its future pre-bundle, whose request waits for the rerun to commit. When that rerun moves a pre-bundled chunk the page already loaded (a React page's pre-bundles share their runtime chunk), the commit gives every entry a new version and reloads the page, and oj compared the waiting request's version against the new one and answered it outdated. Vite's optimizedDeps load hook checks the request's version against the entry's when the request arrives, and after the await compares the discovered entry's info, which its commit updates in place, with the committed one, so a request held across the commit is served the bundle it waited for and the reload follows; the dep route now does the same. A request that arrives after the commit under the old version is still Vite's outdated 504, which the reload retries.
TanStack Start dev: a change that adds an export to a module and reads it from a component importing that module (an export const visibleConcerts in a data module, mapped over in the component, written as two files) reaches an open page as one hot update. The two writes are two patches, one per file; the page applied each as it came, so the component's patch re-ran the component against the data module's exports from before the edit: the new export was undefined, the render threw on it (into the router's error component, or unmounting the page without an error boundary), and the data module's patch, applied next, had nothing left to refresh, while a fresh load rendered fine. A page close to its server rarely saw it (the refresh runtime waits 16ms before it re-renders, and the second patch usually landed first); one far from its server, where fetching a patch takes longer, saw it on most such changes, the editor's gate releasing both patches together making no difference. The page now fetches every patch it has been sent, those released together and any that arrive while it fetches, before it re-runs a module, then re-runs the changed modules once over all of them, so each importer binds to the newest exports, as under Vite, whose module graph invalidates every changed file as the watcher reports it (onFileChange) and whose boundary re-import then loads each import fresh.
Dev server: Vite's URL for a pre-bundled dependency, /node_modules/.vite/deps/react.js (react-dom_client.js for react-dom/client, @tanstack_react-query.js for @tanstack/react-query: the optimizer's flattenId), is served, where oj answered 404 and knew its pre-bundles by /@oj-deps/<file>?v=<version> alone. A script or a retained test written against Vite's cache paths, or tooling that drives the page with them, loads the dependency the app itself runs on: an import of the Vite URL in a served module is rewritten to the pre-bundle's own URL, as the bare import is, and a request for the URL itself (a dynamic import from outside oj's transform) gets a module re-exporting that pre-bundle, so the page keeps one instance of each dependency however the import was spelled. Serving the bundle's bytes under the second URL, or redirecting to the first, would have evaluated it twice, the second React or QueryClient some worked around the 404 with by importing an /@oj-deps/ URL by hand. A CommonJS dependency's names come with it (createRoot from react-dom_client.js), as Vite's import analysis gives them to an importer of its optimized file. A stem that names an installed dependency nothing has imported yet registers it with the optimizer, as a bare import would (Vite's registerMissingImport), and the request waits for the re-optimization; one that is not a dependency is a 404, as Vite's optimized-deps plugin answers a file missing from its cache dir, and one whose re-optimization fails is Vite's processing error, a 504. The URL follows the config's cacheDir as Vite resolves it: /.cache/vite/deps/ for cacheDir: ".cache/vite", else node_modules/.vite under the nearest package.json at or above the root, which for a root inside a package is the /@fs/ form of that directory. Vite's ?v= hash on such a URL is Vite's and is ignored.
TanStack Start dev: an edit saved while the server is still warming its engine after boot (the first seconds, longer on a slow machine or a cold cache) reloads the page once, when its rebuild ends. The boot's revalidation, which drops the modules edited while the engine warmed, counted a reload for them too, and the watcher's rebuild for the same edit counted its own: without the editor's HMR gate the page reloaded twice, and under the gate a flush that landed while the rebuild ran published the revalidation's reload first, onto the bundle from before the edit, with the rebuild's reload following; and while the watcher thread was still scanning the app (seconds on a slow disk), the edit queued on its feed behind the scan, the revalidation's reload went out past the gate, before any hold was taken. The revalidation now leaves the reload to the watcher's rebuild whenever the watcher is going to see the edit, decided by waiting until the watcher has read its feed, and reloads itself only for an edit no watcher run covers; and a flush that lands while a rebuild runs waits for that run, whose end releases the held reloads and hot updates once, onto its output, as a flush between rebuilds always did.
TanStack Start dev: the script tag oj appends to a server-rendered document (its live-reload client) carries the document's CSP nonce. An app under a strict policy (Content-Security-Policy: script-src 'nonce-..' 'strict-dynamic', the nonce handed to Start as the request context and the router's ssr.nonce) had every tag Start rendered nonced and oj's alone not, so the browser refused it: no reload on an edit, no build-error overlay, and a policy violation in the console on every page. Under Vite no tag of its own reaches a Start document (its client arrives as an import of the nonced client entry), and the tags Vite injects into a page take html.cspNonce (plugins/html.ts injectNonceAttributeTagHook). oj's tag now takes the nonce the document's own <script> tags carry, read off the body as it streams (Start's <Scripts> writes the router's nonce double-quoted, router-core's injectScript single-quoted; a tag split across two chunks is read whole), which is the nonce the request's policy header names, else html.cspNonce when the config sets it. A document whose tags have no nonce gets a tag without one, and the app's own tags are never given one, as Vite leaves a Start document's tags alone. The stylesheet links the live-reload client adds for a hot update's new CSS carry a nonce too, the one Vite's client reads for the tags it creates (<meta property="csp-nonce">, client.ts updateStyle), else the nonce of oj's own tag, so a style-src policy that names a nonce accepts them.
TanStack Start dev: a page open across many rebundles keeps loading its chunks. A rebundle renames every chunk whose content changed, and a document served before it imports a route's chunk lazily by the old name when the user first navigates there; the dev server kept the chunks of the last seven bundles behind the current one (the bundle store's window on disk), so a page behind by more, its reload held for the editor's flush while the edits kept coming, or on a hot session, where the pages never reload and every pause in typing rebundles, got a 404 and went blank ("Importing a module script failed" in Safari, "Failed to fetch dynamically imported module" in Chrome) until a hard reload; and a bundle the store could not cache lost its chunk files to the next rebundle at once, since the bundler emptied the chunks directory before writing. The chunks directory is the dev server's now: every bundle's chunk files stay in it for as long as the server retains that bundle, a window that is a budget on disk (256 MiB of chunks beyond the current bundle's, at most 64 bundles) rather than a count the store sets, and a bundle's files leave when it falls out of the window and no served bundle names them. A bundle restored from the store at boot has its chunks linked in; what an earlier run left is removed. Vite's bundled dev keeps every output of the session in memory for the same reason (server/bundledDev.ts storeOutputFiles never clears memoryFiles).
Dev server: a plugin's configureServer middleware mounted on a route (server.middlewares.use("/api", handler)) runs as it does on Vite's connect stack: the route matches the request path case-insensitively and only at a segment boundary (/api takes /api/users and /api.json, not /apiary), the handler reads req.url with the route stripped (/users?page=2) and the browser's url in req.originalUrl, and the url is whole again for the middlewares after it, spelled with the route as mounted. oj matched the route as a plain, case-sensitive prefix and handed the handler the full url with no originalUrl, so a handler written for connect (one that routes on req.url past its mount point, or reads req.originalUrl) took the wrong branch. Every middleware now sees req.originalUrl, which changes what some do under a non-root base: @cloudflare/vite-plugin's worker dispatch, for one, serves req.originalUrl when it is set, so its worker gets the browser's url with the base, as under Vite, where it got the stripped one. The stack's other connect shapes hold too: server.middlewares.stack entries carry the route as mounted (the empty string for the root, which plugins that splice their own entry in read), use(route, app) takes a sub-app with a handle and an http.Server, and an absolute-form url (http://host/path, the form a plugin's own bridge may call the stack with) matches on its path and keeps its scheme and host. Found while looking into a report of vite-plugin-static-copy's copied files answering 404 under oj dev, which reproduces under a non-root base alone: the plugin moves its middleware ahead of Vite's viteServePublicMiddleware in server.middlewares.stack, which sits after Vite's base strip, and oj's stack had no entry of that name, so the plugin's splice landed its middleware before the strip, where it looked the file up with the base still on and missed. The stack now carries Vite's viteServePublicMiddleware and viteTransformMiddleware by name (they only pass; oj serves those requests itself), so a plugin's splice lands where it does under Vite. At the root base the plugin worked: its file map is built in buildStart, which oj awaits before serving, as under Vite; tests hold both shapes.
Dev server: a module import of a file whose extension oj does not compile, where a plugin would make a module of it, is served by the plugin pipeline. An app with @mdx-js/rollup and import.meta.glob("./content/blog/*.mdx", { eager: true }) got every post as the raw file under application/octet-stream, which the browser refused as a module (a blank page, the plugin listed as active and never run), and import hero from "./hero.jpg?w=72&format=webp" with an image plugin got the original image's url module instead of the plugin's module. oj compiled the extensions it knows (scripts, styles, JSON, svg?react, the asset queries) and served anything else as the file without asking the plugin host. Vite's transformMiddleware hands every module request (sec-fetch-dest: script, ?import, a known JS source) to transformRequest, which runs the plugin container's load and transform whatever the extension, and only a request nothing loads falls to its static middlewares; and its plugin container asks every load before vite:asset answers an asset with its url, so an image plugin's module wins for the query it claims. A module request for a file a plugin's load or transform filter claims (the file path with the request's query, as the hooks see it) now goes through the pipeline, an asset among them when a load answers, and the plugin's output compiles as JavaScript; the same url fetched as a resource (<img src>) is still the file, and a file no plugin claims is served as before. An edit of such a file is a hot update of its importers, which name it under the new ?t= stamp, where oj left a file of an unknown extension out of the update, so a self-accepting importer re-ran against the module the page already had.
Dev server: vite-plugin-svgr configured for every .svg (svgr({ include: "**/*.svg", svgrOptions: { exportType: "named", namedExport: "ReactComponent" } }), the CRA convention, or the same include with the default export) makes a plain import { ReactComponent as Logo } from "./logo.svg" the component in dev, as it did in oj build and under vite dev. oj routed a plain svg through the plugins only when one had a transform hook, and vite-plugin-svgr works in load; with @vitejs/plugin-react done natively the plugin was the only active one, so every plain svg import was rewritten to ?url and served as its URL module, and the page failed on the missing ReactComponent export. Vite offers each plugin's load before vite:asset's, which answers the URL only for a file no plugin claimed (plugins/asset.ts load), so a load hook now makes a plain svg a candidate as a transform did; one the plugin's filter does not match is still its URL, stored under the file's key like any module so the next request for the unchanged file is the warm path (one stat, a real ETag) rather than the hooks again, and a load hook is asked only as Vite's container would ask it: not when its own filter cannot match the svg's id (a virtual-module plugin's), and not when Vite runs it after vite:asset (a normal or post plugin's, unless the hook has order: "pre"), whose URL module answers a plain svg first; a pre plugin's function-form load (lovable-tagger's) is offered the id once, as under Vite. The plain svg import now carries Vite's ?t= stamp after an edit, as a ?url import did, so the page loads the edited module rather than the one its module map holds. A BOM-prefixed svg counts as markup too (the BOM is no Unicode white space, so the check for the < missed it). An import that asks for the URL itself (import logoUrl from "./logo.svg?url", beside the component import in the CRA idiom) keeps it, as under Vite, where the plugin's filter does not match the query form; only the ?url oj adds to a plain import comes off for the plugin. With the plugin at its default include (**/*.svg?react), import Logo from "./logo.svg?react" is the plugin's component: oj's own ?react svgr wrapped the component the plugin had already made and the module failed to parse (500).
TanStack Start dev: a batch that only may have changed the server-fn resolver (a removed source file, a tsconfig or package.json, a module its scan read) reloads the page when the resolver made again is another one, not for having been made again: a .ts temp that came and went, a file named as a tsconfig, or a tsconfig saved as it was leaves the edit beside it a hot update, as a JSON temp does. A file beside an import the scan asked for (authed.json beside ./authed) is no answer to it unless it is a module, and a changed path is matched with the scan's however the watcher spells the root (through a symlink, /var for /private/var).
oj build of a TanStack Start app: the server bundle's tanstack-start-manifest:v is the installed Start's own manifest, and a plugin's transform sees it. Under vite build Start's manifest plugins capture the client bundle's chunks and answer the module with every route's preloads and scripts (export const tsrStartManifest = () => (...), under Vite's id \0tanstack-start-manifest:v); oj left those plugins out and aliased the specifier to a file of its own holding the root route's entry and stylesheets alone, so the routes had no preloads of their own, and a plugin rewriting the manifest (one that expands each route's preloads to the chunks they import, say) never ran on it: an app asserting that its transform ran failed the build. A build now hosts Start's two manifest plugins, as it hosts Start's import protection and route splitters, on the client bundle and the server's. The stylesheets stay oj's to link, since their URLs settle after the client bundle is written (a plugin's late CSS replaces a sheet): the framework's import of the manifest goes to a wrapper that adds them to the root route of whatever Start and the app's plugins made, so every page links the sheets it linked before. Dev is unchanged, and an app whose Start has no such plugins keeps oj's manifest.
oj build: an asset in the bundle generateBundle and writeBundle receive carries originalFileNames and originalFileName, as Rollup's OutputAsset does: the source paths the asset was emitted for (root-relative for an imported file, as Vite's asset plugin emits them), an empty array and null when there are none. oj passed name, names and source alone, so a plugin reading the field as the type allows, output.originalFileNames.some((file) => ...) in a guard over what a build ships, failed the build with Cannot read properties of undefined (reading 'some') where vite build passed. The .vite/manifest.json asset a plugin sees has the same shape.
The plugin host's JS heap is sized as Node sizes its own: by V8, from the memory the process may use (the machine's, or the cgroup ceiling when that is lower), which is also how Deno's CLI does it. oj capped the whole heap at a fixed 4096 MB, young and old generation together, where V8 gives the old space half the memory up to 4096 MB and puts the young generation on top: 4192 MB from 8 GB of memory up with oj's V8, so a plugin hook that just fit under vite build could fail under oj with plugin host exceeded its memory limit, and on a machine with less memory the cap was more than V8 would allow there (1072 MB at 2 GB, 2144 MB at 4 GB). --max-old-space-size=N in NODE_OPTIONS sizes the old space as it does for Node, the young generation above it. OJ_PLUGIN_MEMORY_MB is removed: NODE_OPTIONS=--max-old-space-size=<MB> is the one way to set the cap, as under Vite, and the memory-limit error names it.
TanStack Start dev: oj dev on an app whose modules import one another (a lib/ directory of helpers that use each other, a chain of modules each re-exporting the next's bindings) starts, where it printed server-fn resolver cache miss and then sat at a full core for minutes without binding its port, and oj build scanned the same tree the same way. The server-function finder follows an import to the module that exports the binding, as Start's compiler does (resolveImportKind), but it read that module anew for every name imported from it and for every path the imports reached it by, each read resolving the module's own imports the same way: the walk visited every simple path through the import graph, exponentially many, before it answered for the first file. The finder now reads each module once per resolution and resolves a binding when a chain names it, memoizing the result, as the compiler's moduleCache and resolvedKind do, so the time a scan takes grows with the modules reached. With a binding resolved where it is named, a variable holding the factory (const make = createServerFn; export const x = make().handler(..)) is the factory in its own module too, as it already was through an import, as the compiler's resolveIdentifierKind reads it. What a module exports under a name is searched as the compiler's findExportInModule searches it: the module's own export, then its export * modules in order, each module looked at once in a search and every search starting anew, the first module that exports the name answering whatever the name is bound to there. So with m re-exporting all of n and o and n all of m, a builder o declares is found through n as through m, in whichever order a file imports them, and modules that each re-export all of the others are looked at once each. Only a chain ending in .handler(..) has its root resolved, so a z.object(..) or db.query() in a server-function file reads no module and builds no resolver.
TanStack Start: a server function finished on a builder another module exports (export const authedFn = createServerFn().middleware([auth]), then authedFn.handler(..) in a *.functions.ts module) is found when the import is spelled through a tsconfig paths alias (import { authedFn } from "@app/lib/authed"), through the package.json imports map (#lib/authed), or as the module's default export (import authedFn from "./authed", export default authedFn there). oj followed a relative specifier and a named export alone, so a chain rooted at a builder imported any other way was no server function to it: the client bundle kept the handler, and Start's import protection denied the *.server.* module (or @tanstack/react-start/server) only the handler used, in dev (no page hydrated) and in the build, while the same app built under Vite, whose Start compiler resolves the import with this.resolve and reads the module's default export like any other (resolveImportKind, findExportInModule). The finder now resolves a non-relative specifier with the app's resolver (the tsconfig that owns the importer applying its paths, as Vite 8's own resolver does, and Node's imports map), a file under the app's root and outside node_modules counting as the app's, and reads export default for a default import, on every side that must agree on the ids: the client rewrite, the server rewrite and the server-fn resolver's scan.
TanStack Start: a namespace import of one of the app's modules names what the module exports, the factory included (import * as kit from "@app/lib/kit", export { createServerFn } from "@tanstack/react-start" there, then kit.createServerFn().handler(..)), as Start's compiler resolves a namespace's member as an import of that name (resolveCalleeKind): a relative namespace's member was never the factory, and the handler stayed in the client. A module's own export default is its default though an export * is written before it, as the compiler's findExportInModule reads the module's export map first.
TanStack Start dev: the server-fn resolver cached under .oj-cache is regenerated when any source file, a tsconfig or package.json changed, and in a running dev server when an edit touches a module the last scan read for an imported builder (the builder's module, a barrel re-exporting it). It was keyed on the files naming createServerFn alone, so a server function added to a file whose builder is imported (authedFn.handler(..), no createServerFn in the file) restored the old resolver, across restarts too, and the client called an id the server answered with Server function info not found. The key also covers what the scan read that is not a .ts/.tsx file under src/ (a .js builder, a module of a directory an alias names), a file created where an import found none (a new barrel, the target of an alias) or that takes the place of the one read (barrel.js beside barrel.ts), the tsconfig files under src/ and the files a tsconfig names by a relative extends or references path; a cache written by an earlier oj, whose memo recorded which files named createServerFn, no longer keeps the others out of the key, and a cached resolver is restored only when the modules it lists as read are the ones the key was made with.