Skip to content

Rspack production builds miss imported void-root specialization #1839

Closed

Description

@callie-openai

Missed production optimization

With [email protected], @octanejs/[email protected], @rspack/[email protected] and Node 26, a root imported from a compiled TSRX module keeps the generic hydrateRoot path. The neutral compiler specializes the same root when given its existing cross-module void-export proof callbacks. Rendering remains correct; this report is about missing specialization.

Standalone reproduction

In an empty directory:

npm init -y
npm install --save-exact [email protected] @octanejs/[email protected] @rspack/[email protected]

Greeting.tsrx:

export function Greeting() @{ <p>Hello</p>; }

entry.ts:

/** @jsxImportSource octane */
import { hydrateRoot } from 'octane';
import { Greeting } from './Greeting.tsrx';
hydrateRoot(document.getElementById('app'), Greeting, {});

build.mjs:

import { rspack } from '@rspack/core';
import { OctaneRspackPlugin } from '@octanejs/rspack-plugin';
import { resolve } from 'node:path';

const root = process.cwd();
const compiler = rspack({
  context: root,
  mode: 'production',
  target: 'web',
  entry: './entry.ts',
  output: { path: resolve('dist'), filename: 'bundle.js' },
  resolve: { extensions: ['.tsrx', '.ts', '.js'] },
  optimization: { minimize: false, concatenateModules: false },
  plugins: [
    new OctaneRspackPlugin({
      root, environment: 'client', requireDirective: true,
      strong: true, parallel: false,
    }),
    { apply(compiler) {
      compiler.hooks.thisCompilation.tap('InspectEntry', compilation => {
        compilation.hooks.finishModules.tap('InspectEntry', modules => {
          for (const module of modules) {
            if (module.resource === resolve('entry.ts')) {
              console.log(module.originalSource().source().toString());
            }
          }
        });
      });
    } },
  ],
});
compiler.run((error, stats) => {
  if (error || stats.hasErrors()) {
    console.error(error || stats.toString({ all: false, errors: true }));
    process.exitCode = 1;
  }
  compiler.close(() => {});
});

Run node build.mjs. The printed entry still imports and calls hydrateRoot, rather than the compiler's __hydrateVoidRoot specialization.

Source-level cause and fix direction

The Rspack loader does not supply collectVoidComponentExports or isVoidComponentImport to the neutral compiler. The Vite integration supplies both.

A local adapter experiment confirms specialization is possible using the actual resolved module graph and verified final loader outputs. This is not safe as a filesystem-only export scan: SWC can rewrite compiled output, post-loaders can change provider return behavior or the imported export, and watch/cache transitions can invalidate a proof. Unverified transforms must stay generic; mutation after specialization must fail closed.

Regression checks should cover a compiled void export, a value-returning export, parallel loading, changed provider output, changed importer binding, mutation after specialization, production compiler.watch(), and run/watch/run transitions. These cases pass in that conservative adapter experiment; it is not a claim of broad Rspack parity or application bundle savings.

Related broader discussion: #1118. I did not find an existing report of this exact missing Rspack proof plumbing.

This report and its synthetic reproduction were prepared with an agent.

Activity

  1. added a commit that references this issue on Oct 7, 2026
    b8e55da
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions