Skip to content

oj v0.5.1

Latest

Choose a tag to compare

@github-actions github-actions released this 30 Nov 21:22
51e9183

Changed

  • Fewer allocations and repeated passes on the paths that run per request, per module, per import and per chunk, with no change to what is served or written. The dev server keeps the validator of a module's last response with the module, so a reload's revalidation is answered 304 without assembling or hashing the body again; the body it does send is built into one buffer, with the map's data URL encoded straight into it; a stylesheet is served from the bytes css-post cached rather than copied; the HMR stamp, the import flag and a query parameter are dropped from a url without copying one that has none; the importer's hook id is computed once per request; a module's bare specifiers are resolved once; the memory cache keys by the compile key's bytes, not its hex; the runtime env's import statement and the cookie-rewrite regexes are built once. A module whose imports cannot need CommonJS interop is no longer parsed for it (a scan of its specifiers decides, as it already did for a dependency), a dependency with neither import nor export in its text is not parsed for module syntax, and the compiled output of a TypeScript or JSX module is parsed and checked again only when the input's own check could not have caught what the lowering leaves (a file read as a script, a name declared twice, an export of nothing, a reserved word as a JSX tag's object, a __proto__ attribute, an octal escape), the rest having been checked by the same checker on the way in. A bundler plugin hands rolldown oxc's source map value instead of JSON it then parses back (Start's refresh transform, the line maps of the glob, URL and Start compiler rewrites), the plugin maps of a compile are each parsed once, and the module source a plugin's transform runs on is shared between the dedupe key, the hook call and V8 (an array of strings is built element by element instead of escaped, copied and JSON.parsed). In oj build, the CSS plugin's load and resolveId and the app plugins' hooks borrow their arguments instead of copying a dozen fields per module (the CSS config travels in an Arc), a chunk's stylesheet is finalized once and shared by renderChunk, augmentChunkHash and the split-CSS emit instead of every compiled sheet being copied per chunk, and the chunk-graph walks borrow their keys. In a Start build, the prior payload the host plugins get is serialized from borrowed fields, resolveId and load decide on borrowed ids and stat an importer once, the glob patterns of ssr.noExternal are compiled once, a page's nonce scan reads each streamed chunk in place, the per-chunk sheet and module registries are maps, and an HMR patch shared by several pages is parsed once. In CSS, a sheet with no @import, nothing to rebase or nothing to lower is passed through borrowed; postcss-import's inlining and rebasing borrow the sheet and compute an inlined file's base once; a CSS module's lightningcss parse and print run only when it composes, an unminified build parsing the scoped sheet for its errors where no later pass would; and a scoped name's line and hash are found without copying the sheet. In StyleX, a parsed CSS value borrows its input, a rule's sort key stays bytes when its text is ASCII, the assembled sheet is shared by reference, a theme token reference hashes into one buffer, a create namespace is built from its entries at once, and an incremental assemble re-resolves constants only when a dirty file's changed. The resolver precompiles regex aliases, keeps the root tsconfig path, answers a directory import's exports from the package.json oxc already parsed, and the module graph's invalidation walks borrow their paths.

Fixed

  • The server-function resolver module of a Start build lists its entries by id, as Start's resolver module does (getResolverManifestEntries sorts serverFnsById by key); oj listed them by file and by order within the file. On a large app the chunk's text, the order the server bundle meets the provider modules in, and with it the identifiers rolldown gives the server's chunks and the server manifest's dynamicImports, now match vite build's.
  • An asset a Start build writes for a file outside the root (a dependency's font named by a stylesheet's url()) is named in the bundle the generateBundle hooks read by its path relative to the root, climbing out of it, as Vite's asset plugin names an emitted file (path.relative(root, file)). oj named it by its absolute path there, so the manifest listed the asset twice, under the relative key Vite writes and under the absolute one; a large app's client manifest carried 91 such rows.
  • A Cloudflare Worker environment's stylesheets are emitted as compiled, as Vite's server environment emits its own copy of a ?url sheet: the environment's generateBundle hooks then replace the sheet themselves, so the StyleX plugin appends its rules to the Worker's sheet once and the sheet ends under the client's name when the rules are the same (oj's native StyleX appends to such a Worker's sheet as the plugin would). oj gave the Worker the client's already-appended sheet and the hooks appended again, so a large app's Worker carried its StyleX rules twice. A chunk's manifest row lists its css and assets as the environment's generateBundle hooks left the chunk's importedCss and importedAssets when Vite's manifest plugin reads them (a hook's delete(old); add(new) ends a sheet it re-emitted last); oj listed them in the order it wrote the files.
  • A Start chunk that statically imports a pure CSS chunk the build drops takes over the chunk's assets (its sheet's url() files) with its sheet, so its manifest row lists them under assets as Vite's does (css-post's generateBundle hands importers both); oj handed importers the sheet alone.
  • A stylesheet entry point's manifest row lists the files its sheet names by url() under assets, as Vite's does (css-post moves the dropped entry chunk's importedAssets to the sheet's record, which the manifest plugin reads); oj's row left them out.
  • The bundle a Start build's generateBundle hooks read names a chunk's stylesheet after the chunk's facade module, relative to the root, and a ?url sheet after its own absolute path, as Vite's css-post emits them (originalFileNames); oj listed the sheets with no original name. A ?url sheet's assetFileNames call carries that absolute path too, as Vite's does; oj passed it root-relative.
  • oj dev: an asset imported ?no-inline (import icon from "./icon.webp?no-inline", or an import.meta.glob with query: "?no-inline", the way to keep one file out of build.assetsInlineLimit) renders again. Its module exports the url with the query kept, as Vite's fileToDevUrl does, so the page's <img src> fetches /src/icon.webp?no-inline; oj answered that request with the module too (export default "/src/icon.webp?no-inline" as text/javascript), so every such image failed to decode. Vite's transform middleware takes such a url as a module only when the request is an import (?import, Sec-Fetch-Dest: script), and its static middleware serves the file to anything else. oj now does the same, and marks the import ?no-inline&import as Vite's import analysis does, so the two requests are told apart where a browser sends no fetch metadata (plain http on a LAN address). ?url, ?raw, ?inline and the worker queries are unchanged: no page fetches those urls.
  • oj dev of a TanStack Start app: an edit batched with a file that came and went under one of the app's import.meta.glob patterns (an editor's safe-write temp, GNU sed's) is patched in place. The client engine watches on its own and takes each event as it comes, so it could take the temp's creation up before its removal reached it, expand the glob over the temp and fail to load it; oj answered the failed update with a full build and a page reload. The update over the removal, which the engine runs next, expands the glob to the members there are and fetches the edit again, and oj now waits for it and takes its verdict. A file of the batch the last bundle loaded, deleted while a module still imports it, still takes the full build at once, which reports the import.