react-on-rails-rsc 19.0.4 → 19.0.5-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/README.md +0 -0
- package/dist/react-server-dom-rspack/injection-loader.d.ts +22 -0
- package/dist/react-server-dom-rspack/injection-loader.d.ts.map +1 -0
- package/dist/react-server-dom-rspack/injection-loader.js +37 -0
- package/dist/react-server-dom-rspack/injection-loader.js.map +1 -0
- package/dist/react-server-dom-rspack/loader.d.ts +21 -0
- package/dist/react-server-dom-rspack/loader.d.ts.map +1 -0
- package/dist/react-server-dom-rspack/loader.js +63 -0
- package/dist/react-server-dom-rspack/loader.js.map +1 -0
- package/dist/react-server-dom-rspack/plugin.d.ts +163 -0
- package/dist/react-server-dom-rspack/plugin.d.ts.map +1 -0
- package/dist/react-server-dom-rspack/plugin.js +504 -0
- package/dist/react-server-dom-rspack/plugin.js.map +1 -0
- package/dist/react-server-dom-rspack/shared.d.ts +15 -0
- package/dist/react-server-dom-rspack/shared.d.ts.map +1 -0
- package/dist/react-server-dom-rspack/shared.js +37 -0
- package/dist/react-server-dom-rspack/shared.js.map +1 -0
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.d.ts.map +1 -1
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js +65 -39
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.development.js.map +1 -1
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.production.d.ts.map +1 -1
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.production.js +53 -33
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-client.browser.production.js.map +1 -1
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.d.ts.map +1 -1
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js +65 -39
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.development.js.map +1 -1
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.d.ts.map +1 -1
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.js +53 -33
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-client.edge.production.js.map +1 -1
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.d.ts.map +1 -1
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js +65 -39
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.development.js.map +1 -1
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.production.d.ts.map +1 -1
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.production.js +53 -33
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.production.js.map +1 -1
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.d.ts.map +1 -1
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js +65 -39
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.development.js.map +1 -1
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.production.d.ts.map +1 -1
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.production.js +53 -33
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-client.node.unbundled.production.js.map +1 -1
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-plugin.d.ts.map +1 -1
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-plugin.js +21 -12
- package/dist/react-server-dom-webpack/cjs/react-server-dom-webpack-plugin.js.map +1 -1
- package/package.json +13 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this package will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [19.0.5-rc.2] - 2026-05-30
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- Added `RSCRspackPlugin` and `RSCRspackLoader` exports for Rspack-native RSC client reference manifest generation.
|
|
9
|
+
- Added Rspack compatibility and plugin coverage for browser, client, server, directive parsing, dead-code, multiple-client, production-client, and symlinked-module scenarios.
|
|
10
|
+
- Added a plan for eliminating the React fork repository by moving RSC patches into this repo.
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- Updated RSC payload parsing to walk parsed models rather than relying on JSON revivers.
|
|
14
|
+
- Preserved server bundle exports while injecting client-reference metadata for Rspack builds.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- Fixed Rspack RSC client manifest generation, including symlinked client component references.
|
|
18
|
+
- Fixed `RSCRspackPlugin` server bundle injection and export preservation.
|
|
19
|
+
- Fixed the package `prepare`/`prepack` artifact check to look for emitted build outputs.
|
|
20
|
+
- Updated Claude workflow permissions for checks and statuses.
|
|
21
|
+
|
|
22
|
+
## [19.0.5-rc.1] - 2026-02-28
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
- Released the first `19.0.5` release candidate.
|
|
26
|
+
|
|
27
|
+
[19.0.5-rc.2]: https://github.com/shakacode/react_on_rails_rsc/compare/19.0.5-rc.1...19.0.5-rc.2
|
|
28
|
+
[19.0.5-rc.1]: https://github.com/shakacode/react_on_rails_rsc/releases/tag/19.0.5-rc.1
|
package/README.md
CHANGED
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Injection loader — prepends dynamic import() statements to the Flight
|
|
3
|
+
* client runtime module for every "use client" file discovered by the
|
|
4
|
+
* plugin's FS walk.
|
|
5
|
+
*
|
|
6
|
+
* This replicates what the webpack RSC plugin achieves with
|
|
7
|
+
* AsyncDependenciesBlock: each import() creates an async chunk group
|
|
8
|
+
* attached to the runtime module. rspack does not expose a constructible
|
|
9
|
+
* AsyncDependenciesBlock from JS, so dynamic imports are the only way to
|
|
10
|
+
* create proper async chunks.
|
|
11
|
+
*
|
|
12
|
+
* The loader reads the discovered file list from module-level variables
|
|
13
|
+
* set by the plugin during `beforeCompile`. The plugin and loader run
|
|
14
|
+
* in the same Node process, so direct assignment works.
|
|
15
|
+
*/
|
|
16
|
+
import type { LoaderDefinition } from 'webpack';
|
|
17
|
+
export declare let _discoveredClientFiles: string[];
|
|
18
|
+
export declare let _chunkName: string;
|
|
19
|
+
export declare let _generatedChunkNames: Set<string>;
|
|
20
|
+
declare const InjectionLoader: LoaderDefinition;
|
|
21
|
+
export default InjectionLoader;
|
|
22
|
+
//# sourceMappingURL=injection-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injection-loader.d.ts","sourceRoot":"","sources":["../../src/react-server-dom-rspack/injection-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,IAAI,sBAAsB,EAAE,MAAM,EAAO,CAAC;AACjD,eAAO,IAAI,UAAU,QAAkB,CAAC;AACxC,eAAO,IAAI,oBAAoB,EAAE,GAAG,CAAC,MAAM,CAAa,CAAC;AAEzD,QAAA,MAAM,eAAe,EAAE,gBActB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Injection loader — prepends dynamic import() statements to the Flight
|
|
4
|
+
* client runtime module for every "use client" file discovered by the
|
|
5
|
+
* plugin's FS walk.
|
|
6
|
+
*
|
|
7
|
+
* This replicates what the webpack RSC plugin achieves with
|
|
8
|
+
* AsyncDependenciesBlock: each import() creates an async chunk group
|
|
9
|
+
* attached to the runtime module. rspack does not expose a constructible
|
|
10
|
+
* AsyncDependenciesBlock from JS, so dynamic imports are the only way to
|
|
11
|
+
* create proper async chunks.
|
|
12
|
+
*
|
|
13
|
+
* The loader reads the discovered file list from module-level variables
|
|
14
|
+
* set by the plugin during `beforeCompile`. The plugin and loader run
|
|
15
|
+
* in the same Node process, so direct assignment works.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports._generatedChunkNames = exports._chunkName = exports._discoveredClientFiles = void 0;
|
|
19
|
+
exports._discoveredClientFiles = [];
|
|
20
|
+
exports._chunkName = 'client[index]';
|
|
21
|
+
exports._generatedChunkNames = new Set();
|
|
22
|
+
const InjectionLoader = function InjectionLoader(source) {
|
|
23
|
+
if (!exports._discoveredClientFiles.length)
|
|
24
|
+
return source;
|
|
25
|
+
const names = [];
|
|
26
|
+
const imports = exports._discoveredClientFiles.map((file, i) => {
|
|
27
|
+
const name = exports._chunkName
|
|
28
|
+
.replace(/\[index\]/g, String(i))
|
|
29
|
+
.replace(/\[request\]/g, file.replace(/[^a-zA-Z0-9_]/g, '_'));
|
|
30
|
+
names.push(name);
|
|
31
|
+
return `import(/* webpackChunkName: ${JSON.stringify(name)} */ ${JSON.stringify(file)});`;
|
|
32
|
+
});
|
|
33
|
+
exports._generatedChunkNames = new Set(names);
|
|
34
|
+
return imports.join('\n') + '\n' + source;
|
|
35
|
+
};
|
|
36
|
+
exports.default = InjectionLoader;
|
|
37
|
+
//# sourceMappingURL=injection-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injection-loader.js","sourceRoot":"","sources":["../../src/react-server-dom-rspack/injection-loader.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAIQ,QAAA,sBAAsB,GAAa,EAAE,CAAC;AACtC,QAAA,UAAU,GAAG,eAAe,CAAC;AAC7B,QAAA,oBAAoB,GAAgB,IAAI,GAAG,EAAE,CAAC;AAEzD,MAAM,eAAe,GAAqB,SAAS,eAAe,CAAC,MAAM;IACvE,IAAI,CAAC,8BAAsB,CAAC,MAAM;QAAE,OAAO,MAAM,CAAC;IAElD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,OAAO,GAAG,8BAAsB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;QACrD,MAAM,IAAI,GAAG,kBAAU;aACpB,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;aAChC,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC,CAAC;QAChE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,OAAO,+BAA+B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;IAC5F,CAAC,CAAC,CAAC;IAEH,4BAAoB,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IACtC,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,MAAM,CAAC;AAC5C,CAAC,CAAC;AAEF,kBAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "use client" detector loader.
|
|
3
|
+
*
|
|
4
|
+
* Attached by RSCRspackPlugin to every JS/TS module during compilation.
|
|
5
|
+
* Reads the source, checks if the file starts with a `"use client"`
|
|
6
|
+
* directive (accounting for BOM, shebangs, and leading comments), and if
|
|
7
|
+
* so adds the module's resourcePath to a per-compilation Set keyed by the
|
|
8
|
+
* `CLIENT_MODULES_KEY` Symbol. The plugin consumes that Set at
|
|
9
|
+
* `processAssets` time to emit the manifest.
|
|
10
|
+
*
|
|
11
|
+
* The loader passes the source through unchanged — it is purely a reporter.
|
|
12
|
+
*
|
|
13
|
+
* IMPORTANT: communication with the plugin goes via a Symbol-keyed
|
|
14
|
+
* property on the compilation object (`compilation[CLIENT_MODULES_KEY]`).
|
|
15
|
+
* The plugin eagerly creates the Set in `thisCompilation` so the loader
|
|
16
|
+
* never races on initialization.
|
|
17
|
+
*/
|
|
18
|
+
import type { LoaderDefinition } from 'webpack';
|
|
19
|
+
declare const RSCRspackLoader: LoaderDefinition;
|
|
20
|
+
export default RSCRspackLoader;
|
|
21
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/react-server-dom-rspack/loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGhD,QAAA,MAAM,eAAe,EAAE,gBA6CtB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* "use client" detector loader.
|
|
4
|
+
*
|
|
5
|
+
* Attached by RSCRspackPlugin to every JS/TS module during compilation.
|
|
6
|
+
* Reads the source, checks if the file starts with a `"use client"`
|
|
7
|
+
* directive (accounting for BOM, shebangs, and leading comments), and if
|
|
8
|
+
* so adds the module's resourcePath to a per-compilation Set keyed by the
|
|
9
|
+
* `CLIENT_MODULES_KEY` Symbol. The plugin consumes that Set at
|
|
10
|
+
* `processAssets` time to emit the manifest.
|
|
11
|
+
*
|
|
12
|
+
* The loader passes the source through unchanged — it is purely a reporter.
|
|
13
|
+
*
|
|
14
|
+
* IMPORTANT: communication with the plugin goes via a Symbol-keyed
|
|
15
|
+
* property on the compilation object (`compilation[CLIENT_MODULES_KEY]`).
|
|
16
|
+
* The plugin eagerly creates the Set in `thisCompilation` so the loader
|
|
17
|
+
* never races on initialization.
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
const shared_1 = require("./shared");
|
|
21
|
+
const RSCRspackLoader = function RSCRspackLoader(source) {
|
|
22
|
+
// Our loader has a side effect: it mutates the compilation via
|
|
23
|
+
// `compilation[CLIENT_MODULES_KEY]`. That side effect must happen on
|
|
24
|
+
// EVERY build, including incremental rebuilds — but rspack's default
|
|
25
|
+
// loader caching would skip re-executing on cache hits, leaving the
|
|
26
|
+
// tag-set stale or empty across watch-mode rebuilds. Declaring the
|
|
27
|
+
// loader non-cacheable forces re-execution every time, which restores
|
|
28
|
+
// a correct manifest on incremental builds.
|
|
29
|
+
//
|
|
30
|
+
// The loader is effectively free (one regex test on source text), so
|
|
31
|
+
// the caching cost is negligible compared to the correctness win.
|
|
32
|
+
this.cacheable(false);
|
|
33
|
+
// Defensive: if another `pre` loader runs before ours and returns a
|
|
34
|
+
// Buffer (e.g., a binary loader or an ill-behaved plugin), `source`
|
|
35
|
+
// could arrive as Buffer instead of string. `charCodeAt` + `startsWith`
|
|
36
|
+
// would throw. Coerce to string so the detector is always safe.
|
|
37
|
+
const text = typeof source === 'string' ? source : String(source);
|
|
38
|
+
// Report the module if it has "use client" at the top.
|
|
39
|
+
if ((0, shared_1.hasUseClientDirective)(text)) {
|
|
40
|
+
// `this._compilation` is the rspack/webpack Compilation object. It is a
|
|
41
|
+
// loader-context private but both rspack and webpack expose it reliably.
|
|
42
|
+
// We guard with optional chaining in case the loader gets called outside
|
|
43
|
+
// a regular compilation (e.g., loader tests).
|
|
44
|
+
const compilation = this._compilation;
|
|
45
|
+
if (compilation) {
|
|
46
|
+
// Plugin eagerly initializes the Set in its `thisCompilation` hook,
|
|
47
|
+
// which always runs before any loader. If the Set is missing here,
|
|
48
|
+
// the plugin wasn't applied to this compiler — skip silently (the
|
|
49
|
+
// loader is harmless on its own).
|
|
50
|
+
//
|
|
51
|
+
// Guard an empty / missing resourcePath (virtual modules synthesized
|
|
52
|
+
// by other plugins have no physical file and may report `undefined`
|
|
53
|
+
// or `""`). Tagging an empty string would pollute the manifest.
|
|
54
|
+
const set = compilation[shared_1.CLIENT_MODULES_KEY];
|
|
55
|
+
if (set && typeof this.resourcePath === 'string' && this.resourcePath.length > 0) {
|
|
56
|
+
set.add(this.resourcePath);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return source;
|
|
61
|
+
};
|
|
62
|
+
exports.default = RSCRspackLoader;
|
|
63
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/react-server-dom-rspack/loader.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;AAGH,qCAAqE;AAErE,MAAM,eAAe,GAAqB,SAAS,eAAe,CAAC,MAAM;IACvE,+DAA+D;IAC/D,qEAAqE;IACrE,qEAAqE;IACrE,oEAAoE;IACpE,mEAAmE;IACnE,sEAAsE;IACtE,4CAA4C;IAC5C,EAAE;IACF,qEAAqE;IACrE,kEAAkE;IAClE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAEtB,oEAAoE;IACpE,oEAAoE;IACpE,wEAAwE;IACxE,gEAAgE;IAChE,MAAM,IAAI,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAElE,uDAAuD;IACvD,IAAI,IAAA,8BAAqB,EAAC,IAAI,CAAC,EAAE,CAAC;QAChC,wEAAwE;QACxE,yEAAyE;QACzE,yEAAyE;QACzE,8CAA8C;QAC9C,MAAM,WAAW,GAAI,IAA8C,CAAC,YAEvD,CAAC;QACd,IAAI,WAAW,EAAE,CAAC;YAChB,oEAAoE;YACpE,mEAAmE;YACnE,kEAAkE;YAClE,kCAAkC;YAClC,EAAE;YACF,qEAAqE;YACrE,oEAAoE;YACpE,gEAAgE;YAChE,MAAM,GAAG,GAAG,WAAW,CAAC,2BAAkB,CAA4B,CAAC;YACvE,IAAI,GAAG,IAAI,OAAO,IAAI,CAAC,YAAY,KAAK,QAAQ,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACjF,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,kBAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RSCRspackPlugin — rspack-native equivalent of RSCWebpackPlugin.
|
|
3
|
+
*
|
|
4
|
+
* Emits React on Rails' existing client-manifest JSON schema using only
|
|
5
|
+
* standard rspack public APIs — no dependency on rspack's experimental RSC
|
|
6
|
+
* system (`rspackExperiments.reactServerComponents`, `experiments.rsc`,
|
|
7
|
+
* `react-server-dom-rspack`).
|
|
8
|
+
*
|
|
9
|
+
* Discovery technique: a small loader (`loader.ts`) tags modules containing
|
|
10
|
+
* a `"use client"` directive during parse by adding the module's resource
|
|
11
|
+
* path to a per-compilation Set keyed under the `CLIENT_MODULES_KEY`
|
|
12
|
+
* Symbol. A second loader prepends dynamic imports to the Flight client
|
|
13
|
+
* runtime so file-system-discovered client references become async chunk
|
|
14
|
+
* groups. At `processAssets`, the plugin walks chunk groups and emits the
|
|
15
|
+
* React on Rails client-manifest JSON schema.
|
|
16
|
+
*
|
|
17
|
+
* Output schema matches RoR's existing webpack-side plugin so
|
|
18
|
+
* `buildServerRenderer` / `buildClientRenderer` in server.node.ts /
|
|
19
|
+
* client.node.ts work without changes.
|
|
20
|
+
*/
|
|
21
|
+
type AnyLogger = {
|
|
22
|
+
warn(...args: unknown[]): void;
|
|
23
|
+
info(...args: unknown[]): void;
|
|
24
|
+
debug(...args: unknown[]): void;
|
|
25
|
+
};
|
|
26
|
+
type AnyCompiler = {
|
|
27
|
+
options: {
|
|
28
|
+
module?: {
|
|
29
|
+
rules?: unknown[];
|
|
30
|
+
};
|
|
31
|
+
context?: string;
|
|
32
|
+
};
|
|
33
|
+
context: string;
|
|
34
|
+
hooks: {
|
|
35
|
+
beforeCompile: {
|
|
36
|
+
tapAsync: (name: string, fn: (params: unknown, cb: (err?: Error | null) => void) => void) => void;
|
|
37
|
+
};
|
|
38
|
+
thisCompilation: {
|
|
39
|
+
tap: (name: string, fn: (compilation: unknown) => void) => void;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
rspack?: {
|
|
43
|
+
version?: string;
|
|
44
|
+
};
|
|
45
|
+
webpack?: {
|
|
46
|
+
version?: string;
|
|
47
|
+
};
|
|
48
|
+
inputFileSystem?: {
|
|
49
|
+
readFileSync?(p: string, enc: string): string;
|
|
50
|
+
};
|
|
51
|
+
resolverFactory?: {
|
|
52
|
+
get(type: string, options?: unknown): unknown;
|
|
53
|
+
};
|
|
54
|
+
getInfrastructureLogger?(name: string): AnyLogger;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* A search-path descriptor matching the webpack plugin's `clientReferences`
|
|
58
|
+
* shape. Each entry tells the plugin to walk a directory for files matching
|
|
59
|
+
* `include` (a RegExp), optionally excluding via `exclude`.
|
|
60
|
+
*/
|
|
61
|
+
export type ClientReferenceSearchPath = {
|
|
62
|
+
directory: string;
|
|
63
|
+
recursive?: boolean;
|
|
64
|
+
include: RegExp;
|
|
65
|
+
exclude?: RegExp;
|
|
66
|
+
};
|
|
67
|
+
export type ClientReferencePath = string | ClientReferenceSearchPath;
|
|
68
|
+
export interface Options {
|
|
69
|
+
/**
|
|
70
|
+
* Whether the plugin is applied to the server bundle (as opposed to the
|
|
71
|
+
* client bundle). Determines the default manifest filename and which
|
|
72
|
+
* runtime module the plugin looks for the client runtime against.
|
|
73
|
+
*/
|
|
74
|
+
isServer: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Override the client manifest filename. Defaults to
|
|
77
|
+
* `react-client-manifest.json` for client, `react-server-client-manifest.json`
|
|
78
|
+
* for server, matching the webpack plugin's defaults.
|
|
79
|
+
*/
|
|
80
|
+
clientManifestFilename?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Where to look for `"use client"` files. Each entry is either:
|
|
83
|
+
* - A string (absolute path to a single file), or
|
|
84
|
+
* - A search descriptor: `{ directory, recursive?, include, exclude? }`
|
|
85
|
+
*
|
|
86
|
+
* The plugin FS-walks each descriptor at `beforeCompile` time, reads
|
|
87
|
+
* every matching file, checks for the `"use client"` directive, and
|
|
88
|
+
* injects the discovered files into the bundle as named async chunks
|
|
89
|
+
* through the Flight runtime injection loader. This ensures the client/SSR
|
|
90
|
+
* bundle includes every client component even if nothing in the entry graph
|
|
91
|
+
* explicitly imports it — matching the webpack plugin's behavior.
|
|
92
|
+
*
|
|
93
|
+
* Default: `[{ directory: ".", recursive: true, include: /\.(js|ts|jsx|tsx)$/ }]`
|
|
94
|
+
* (scan the entire compiler context directory).
|
|
95
|
+
*/
|
|
96
|
+
clientReferences?: ClientReferencePath | ReadonlyArray<ClientReferencePath>;
|
|
97
|
+
/**
|
|
98
|
+
* Template for naming async chunks created for each client reference.
|
|
99
|
+
* Supports `[index]` (sequential number) and `[request]` (sanitised
|
|
100
|
+
* file path). Default: `"client[index]"`.
|
|
101
|
+
*/
|
|
102
|
+
chunkName?: string;
|
|
103
|
+
}
|
|
104
|
+
export declare const RSC_LOADER_RULE: {
|
|
105
|
+
test: RegExp;
|
|
106
|
+
exclude: RegExp;
|
|
107
|
+
enforce: "pre";
|
|
108
|
+
use: {
|
|
109
|
+
loader: string;
|
|
110
|
+
}[];
|
|
111
|
+
};
|
|
112
|
+
export declare class RSCRspackPlugin {
|
|
113
|
+
private readonly options;
|
|
114
|
+
private readonly clientReferences;
|
|
115
|
+
private readonly chunkName;
|
|
116
|
+
constructor(options: Options);
|
|
117
|
+
apply(compiler: AnyCompiler): void;
|
|
118
|
+
private resolveAllClientFiles;
|
|
119
|
+
private walkDir;
|
|
120
|
+
private addResolvedClientFile;
|
|
121
|
+
private normalizeResourcePath;
|
|
122
|
+
/**
|
|
123
|
+
* Resolves the bundler runtime namespace. Prefers `compiler.rspack` (if
|
|
124
|
+
* present — rspack sets this), falls back to `compiler.webpack` (webpack 5
|
|
125
|
+
* convention), then tries `require('webpack')` as a last resort.
|
|
126
|
+
*
|
|
127
|
+
* This means the same plugin code works under both rspack and webpack
|
|
128
|
+
* without an explicit bundler option, as long as the bundler exposes the
|
|
129
|
+
* convention-standard `Compilation` and `sources` types.
|
|
130
|
+
*/
|
|
131
|
+
private resolveBundler;
|
|
132
|
+
/**
|
|
133
|
+
* Injects the tagging loader rule into compiler.options.module.rules at
|
|
134
|
+
* position 0 (so it runs `pre` relative to user rules). Idempotent — if
|
|
135
|
+
* the rule is already present, do nothing.
|
|
136
|
+
*/
|
|
137
|
+
private ensureLoaderRule;
|
|
138
|
+
private hasLoaderRule;
|
|
139
|
+
/**
|
|
140
|
+
* Build the RoR-shape manifest from the tagged module set.
|
|
141
|
+
*
|
|
142
|
+
* Iterates `compilation.chunkGroups` (matching the webpack plugin's
|
|
143
|
+
* pattern) so the `chunks` array for each module reflects ALL chunks
|
|
144
|
+
* in the chunk group — not just the ones directly containing the
|
|
145
|
+
* module. This matters for split-chunk configurations where sibling
|
|
146
|
+
* chunks must be preloaded together.
|
|
147
|
+
*/
|
|
148
|
+
private buildManifest;
|
|
149
|
+
/** Stash resolved client files so buildManifest can filter by them. */
|
|
150
|
+
private _resolvedClientFiles;
|
|
151
|
+
/** Build the chunks array from all async-loadable chunks in a chunk group. */
|
|
152
|
+
private getGroupChunks;
|
|
153
|
+
private getInitialChunks;
|
|
154
|
+
private isInitialChunk;
|
|
155
|
+
/**
|
|
156
|
+
* Record a single module in the manifest if it is a resolved client reference.
|
|
157
|
+
* `moduleId` and `chunks` come from the enclosing context (the chunk
|
|
158
|
+
* group walk or the outer ConcatenatedModule).
|
|
159
|
+
*/
|
|
160
|
+
private recordModule;
|
|
161
|
+
}
|
|
162
|
+
export default RSCRspackPlugin;
|
|
163
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/react-server-dom-rspack/pl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