Conversation
intellild
force-pushed
the
codex/js-loader-context-class
branch
from
September 11, 2026 05:37
0c244ef to
a3d45c1
Compare
Deploying rspack with
|
| Latest commit: |
78a6a63
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://43fefc37.rspack-v2.pages.dev |
| Branch Preview URL: | https://codex-js-loader-context-clas.rspack-v2.pages.dev |
Contributor
📦 Binary Size-limit
❌ Size increased by 44.13KB from 68.82MB to 68.87MB (⬆️0.06%) |
Contributor
Rsdoctor Bundle Diff AnalysisFound 5 projects in monorepo, 0 projects with changes. 📊 Quick Summary
Generated by Rsdoctor GitHub Action |
Contributor
Merging this PR will not alter performance
Comparing Footnotes
|
intellild
force-pushed
the
codex/js-loader-context-class
branch
2 times, most recently
from
September 15, 2026 03:26
c9db7a3 to
8680131
Compare
Separate reusable loader metadata from execution state and move the boxed context through the JavaScript boundary. Batch mutable state writeback while preserving borrowed native hook access. Cache native getter results per JavaScript entry, including missing values. Keep content and source maps separate throughout the loader chain, with regression coverage for ownership, state updates, and raw buffer handling.
intellild
force-pushed
the
codex/js-loader-context-class
branch
from
September 15, 2026 09:16
8680131 to
ab73d39
Compare
Add typed lifecycle guards and environment-scoped thread-local reference caching in rspack_napi. Batch reference cleanup on owning JavaScript threads when native guards drop. Reuse loader context classes and JavaScript wrappers without carrying facade state through Rust. Preserve boxed ownership, borrowed hooks, and per-entry read cache resets, with identity and cross-environment GC regression coverage.
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.
Motivation
Crossing the Rust/JavaScript loader boundary currently materializes the loader context and splits source content from its source map, even when JavaScript does not consume them. Builtin loaders also pass content and maps separately, losing the opportunity to preserve native source graphs between loaders.
For example, a JavaScript pitch loader that returns no output should leave the native source untouched. A chain of builtin loaders should retain
BoxSourceuntil a JavaScript normal loader actually needs a string or Buffer and a separate source map. When a native consumer needs owned text, consuming a uniquely owned raw buffer can reuse its allocation instead of copying the whole file. No benchmark speedup is claimed.Changes
JsLoaderContextinto a N-API class directly owningOption<Box<LoaderContext>>. The JavaScript loader runner receives and returns the same Box; return-value conversion takes it on the JavaScript thread, leaving retained instances empty.napi(object)state. The JavaScript facade reads and updates this state locally and writes it back once, while source content and maps remain lazy.&mut LoaderContext. JavaScript hooks exchange a state snapshot and return the complete state without moving the native context. Preserve hook-installed properties, loader object identity, and native/JavaScript hook ordering.BoxSourcethrough builtin loaders and normal module processing. Add consuming Source access that reuses uniquely owned leaf allocations, including after cache restoration, and use SIMD UTF-8 validation. Remove full-content copies in NormalModule and SWC and per-module static runtime copies in React/Preact refresh.Validation
-D warningspassed for the binding API, loader runner, sources, builtin loader crates, and HMR.rspack_loader_runner,rspack_sources, andrspack_cacheable_test(135 tests plus 11 doc tests). Pointer checks verify allocation reuse before and after cache restoration and shared-source preservation.git diff --checkpassed.by OpenAI Codex