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.
Added
experimental.renderBuiltUrl in oj build: the config's function is asked for every output URL as Vite asks it (toOutputFilePathInJS from a chunk, toOutputFilePathWithoutRuntime from a sheet or a page), with the file, the host (hostId a chunk's file name, a sheet's cssAssetName, a page's path from the root; hostTypejs, css or html), the kind (asset or public) and ssr. A string is the URL (encoded as Vite encodes it), { runtime } the expression a chunk splices into its string literal (a sheet or a page fails the build on one, as under Vite), { relative } overrides whether the URL is written from its host, and nothing leaves the base to decide. It applies to an asset import, new URL(…, import.meta.url), a worker's URL, a ?url and an ?inline sheet (whose public url()s now resolve when its chunk renders, as its emitted files do), a public file, a sheet's url()s (emitted or public), a page's scripts, preloads, stylesheets, inline styles and attribute assets, and the preload helper's dependency table (whose helper then resolves each dependency against the importer, a runtime entry written as is), in the client, the SSR and the library builds and in a ?worker bundle. The function stays in the plugin host; a build without one, or a Start build (which forms its URLs as it loads each asset, not from markers a chunk renders), writes its URLs under base as before, the Start build saying so. Goldens render-built-url (a CDN per host, a public prefix, an svg at runtime, a text file and the page's icon relative, a font under the base) and render-built-url-ssr (ssr: true, a relative answer ignored), recorded from Vite.
Golden start-cloudflare-composite: the shape of a large app's build in one TanStack Start app on a Cloudflare Worker, each piece a mechanism of such an app's own config that a change to oj could break with no golden to notice, recorded from the fixture's Vite like the rest. StyleX compiled by a plugin of the config's own in place of the package's (the config probes an instance for hooks), whose generateBundle appends the rules to the globals sheet and re-emits it under a new hash, rewriting every chunk's code and metadata and deleting the old entry, with a post plugin repointing what still names it; a pre resolveId with an object filter replacing an installed package by a virtual module in both bundles; server-only post transforms replacing a dependency, a browser-only module (both reached by the root route, called in an effect alone) and a client-only route's ?tsr-split payload by stubs built from this.parse, with a buildEnd tripwire and a generateBundle pruning the Worker's orphan .js assets with their maps; serve-only plugins the build must not run, a false entry and a nested plugin list; virtual data modules a name function groups and twin chunk groups over one directory, the first tagged $initial; a pre transform whose output differs per environment; a client generateBundle listing every chunk's module ids and the server's transform of Start's manifest module writing the routes' preloads beside the client output (the manifest module's content, otherwise compared by presence); a child process of buildStart writing a module the routes import; a PostCSS config with a plugin of its own and no Tailwind; an ?inline sheet with an @import; an SVG as a component, a URL and text; a renamed public directory with an .assetsignore; a regex alias to a file inside a dependency; a Worker with a service binding and vars a guard reads from wrangler.json at writeBundle. Three 0.5.x releases in a row shipped a regression only such an app's own build found; this case fails on two of them (the stand-down for a config's own StyleX compiler, the PostCSS config on every sheet), the engine test on the third.
Fixed
A plugin's spawn of process.execPath, oj itself (an app's StyleX compiler runs oj stylex serve from OJ_BINARY, the binary hosting the build), reaches the child with its arguments as given: oj's JavaScript runtime (the plugin host's and every other engine's) is a standalone binary to Deno's node compat, as a deno compile output is. Deno rewrote such a spawn into a deno run of its first argument (oj run -A … stylex serve --stdio), which oj's command line refused, so a Start build whose StyleX plugin drives the compiler itself (oj's stand-in for @stylexjs/unplugin carries hooks there, so the plugin takes its Vite path) failed every StyleX transform with fru exited: 2; oj dev hands such a plugin a hookless stand-in and compiles natively, so it never spawned.
oj build of a TanStack Start app whose config compiles StyleX with a plugin of its own (a large app's compiler plugin over oj stylex serve) in place of @stylexjs/unplugin: oj's native StyleX stands down. Such a config probes an instance of the package for hooks and lists its own compiler when it has them, which under oj build it does (oj's stand-in composes the real plugin), and lists the instance as it is when it has none (oj dev, and the config extraction that switches oj's native StyleX on). oj compiled every module natively with the probe's options (the default class-name prefix, the sheet appended to whichever stylesheet it picked) before the config's compiler saw it, which then found nothing to compile; a large app's build lost its library prefix and layers in 269 files. The plugin host now says whether the config it evaluated lists the stand-in at all, and the build takes its word, as it already did for a plugin made of the stand-in. A ?worker bundle's plugins are the config's worker.plugins, as under Vite, so a worker that imports StyleX compiles natively only when they list the plugin; oj compiled it natively whenever the top-level config did. A spawn through a shell string (sh -c "$OJ_BINARY …") is still rewritten by Deno's node compat; a direct spawn is what the compiler plugins do.
oj build of a TanStack Start app with a PostCSS config: the config runs on every stylesheet, as Vite runs it (its vite:css hands each sheet to the config's plugins, Tailwind's and the app's own alike), so a plugin of the app's own rewrites the plain sheets too. The Start build ran the config's engine on the sheets that use Tailwind alone (its substring rule), as it did before a config's own plugin existed, so a large app's selector rewrite (one :where(a, b) into a selector per argument, for Chromium's rule filing) was missing from one plain sheet of its client. The plain build already ran the config on every sheet, and oj dev's server on the sheets it links; a Start dev ?inline sheet (the <style> SSR renders) now goes through the config too, as Vite's dev compiles it. Every sheet the Start build or Start dev hands the config has its plain @imports inlined first, as Vite's postcss-import runs ahead of the config's plugins (Tailwind's plugin does not bail on an @import, and would resolve it itself); the emitted sheets had that, a ?inline sheet and a dev sheet a plugin reads did not.
A plugin's transform map joins a build's chain as rolldown's binding takes it from the plugin itself: a map with no sourcesContent names the code that plugin received, and one with no sources (or one source that is not the id) the id. oj runs the app's plugins in one transform of its own, so rolldown filled such a map with the chain's input, the file as loaded; after a transform that changed the code under map: null (which adds nothing to the chain), a bundle's map then named the file where Vite's names that transform's output (an MDX module with frontmatter a plugin appended, in a large app's build). The renderChunk chain is as it was.
oj dev: a plain .svg import under a plugin that may componentize it (one with a transform hook, lovable-tagger's shape) was served under its bare url: the page imported /src/assets/logo.svg and its <img src> fetched the same url, the module and the image told apart by the request's Sec-Fetch-Dest alone, with Vary on it. A cache between the browser and the server that keys on the url (a CDN keeps an svg by its extension when the response names no cache policy, and the image answer named none) could hand the module script the image, which the browser refuses for its MIME type (image/svg+xml), and the page went blank. The import is now marked ?import, as Vite's import analysis marks every import that is neither JS nor CSS (isExplicitImportRequired), and the page preloads that url. The ?import url is the module whoever asks, the mark taken off before the plugins see the id (removeImportQuery); the bare url is the file to anything but a Sec-Fetch-Dest: script request (Vite's isTransformRequest), with sirv's Cache-Control: no-cache, weak ETag and Last-Modified, as Vite's static middleware serves it, so a shared cache revalidates instead of keeping it. Every file oj serves as-is (an image, a font, wasm) carries the same validators and answers byte ranges and If-None-Match with a 304. The same mark now reaches the imports oj left at their bare url: a root-absolute import of a file under the root (/src/hero.png, /src/a.css), an asset in a package or outside the root, and an asset a pre-bundled dependency imports, which the bundle names by its url (a client that sends no Sec-Fetch-Dest could only have been answered by that header).
oj build reads each environment's own build options where Vite does: environments.<name>.build.target lowers that environment's bundle (the client's, the ssr's, a library's, a ?worker's and a Start build's client and server bundles), cssTarget and cssMinify finish its sheets and cssCodeSplit splits them, each falling back to the top level's as Vite resolves an environment's build over build (cssTarget to the environment's own target then, cssMinify to its own minify for a client, on for a server). oj read the top level's for every environment, so environments.ssr.build.target: "esnext" under build.target: "es2018" lowered the server bundle anyway, and the client's own cssMinify: false was minified over. The extraction carries each environment's resolved cssTarget whole (it dropped one equal to the environment's target, which the chain now reads first). A Start build's sheets keep the top level's cssMinify and cssTarget: TanStack Start builds under Vite's builder with sharedPlugins, whose css-post is the first config's, which minifies every environment's sheets by the top level's options. emptyOutDir was already per environment. Goldens env-build-options and env-build-options-ssr, recorded from Vite.