Skip to content

Rollup family complains about load hook time #41

Description

@ArcadeMode

Slow Rollup-family load for framework binaries

Problem

In build mode, the Rollup-family load hook matches *.wasm|*.dat|*.pdb, readFiles the full file into a Buffer, and emitFiles it. Large .NET wasm assets dominate plugin build time in bundler timing logs.

Dev/serve avoids this (export default '/_framework/…' + middleware).

[PLUGIN_TIMINGS] Your build spent 88% of 3.4s inside plugin hooks (3.0s).
Measured inside the callback, so queue time is excluded and time the callback itself awaited is not:
  - unplugin-dotnet-wasm buildStart (83%, 2.8s, 1 call)
Those rows are 83% of the build; the rest of the 88% is below.
Not measurable — 1 hook whose calls overlap, so elapsed time covers work other calls were doing. Profile with `node --cpu-prof`:
  - unplugin-dotnet-wasm load (207 calls)
See https://rolldown.rs/reference/InputOptions.checks#plugintimings for more details.

Constraint

Assets are typically out of tree. Rollup has no “emit by path” API, emitFile always needs source bytes.

Options

  1. Hand off to bundler asset pipeline: stop handling binaries in load; let Vite/Rollup native new URL / asset plugins emit them. Not a one-line filter remove: Vite currently gets @vite-ignore on those new URLs, and serve’s /_framework/… export lives in the same hook.
  2. writeBundle copy + literal URL: load exports a final URL string; copy files into outDir later. Rollup never re-resolves the wasm (unless you import / tracked new URL it). Tradeoff: own hashing/base/naming.
  3. setAssetSource deferral: still reads fully; only moves cost out of load timing.

Option 1 is preferred atm.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixThis will not be worked on

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions