@rspack-canary/core 2.0.0-canary-30d58971-20260122174325 → 2.0.0-canary-615f9a1c-20260123175100

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.
@@ -79,6 +79,7 @@ export type CompilerHooks = {
79
79
  entryOption: liteTapable.SyncBailHook<[string, EntryNormalized], any>;
80
80
  additionalPass: liteTapable.AsyncSeriesHook<[]>;
81
81
  };
82
+ export declare const GET_COMPILER_ID: unique symbol;
82
83
  declare class Compiler {
83
84
  #private;
84
85
  hooks: CompilerHooks;
@@ -21,6 +21,10 @@ export type SwcLoaderOptions = Config & {
21
21
  */
22
22
  rspackExperiments?: {
23
23
  import?: PluginImportOptions;
24
+ /**
25
+ * Enable React Server Components support.
26
+ */
27
+ reactServerComponents?: boolean;
24
28
  };
25
29
  };
26
30
  export interface TerserCompressOptions {
@@ -73,6 +73,7 @@ export * from './RslibPlugin.js';
73
73
  export * from './RstestPlugin.js';
74
74
  export * from './RuntimeChunkPlugin.js';
75
75
  export * from './RuntimePlugin.js';
76
+ export { rsc } from './rsc/index.js';
76
77
  export * from './SideEffectsFlagPlugin.js';
77
78
  export * from './SizeLimitsPlugin.js';
78
79
  export * from './SourceMapDevToolPlugin.js';
@@ -0,0 +1,8 @@
1
+ import { type Compiler } from '../../Compiler.js';
2
+ export declare const GET_OR_INIT_BINDING: unique symbol;
3
+ export declare class Coordinator {
4
+ #private;
5
+ constructor();
6
+ applyServerCompiler(serverCompiler: Compiler): void;
7
+ applyClientCompiler(clientCompiler: Compiler): void;
8
+ }
@@ -0,0 +1,13 @@
1
+ import type binding from '@rspack/binding';
2
+ import type { Compiler } from '../../index.js';
3
+ import { RspackBuiltinPlugin } from '../base.js';
4
+ import { type Coordinator } from './Coordinator.js';
5
+ export type RscClientPluginOptions = {
6
+ coordinator: Coordinator;
7
+ };
8
+ export declare class RscClientPlugin extends RspackBuiltinPlugin {
9
+ #private;
10
+ name: string;
11
+ constructor(options: RscClientPluginOptions);
12
+ raw(compiler: Compiler): binding.BuiltinPlugin;
13
+ }
@@ -0,0 +1,14 @@
1
+ import type binding from '@rspack/binding';
2
+ import type { Compiler } from '../../index.js';
3
+ import { RspackBuiltinPlugin } from '../base.js';
4
+ import { type Coordinator } from './Coordinator.js';
5
+ export type RscServerPluginOptions = {
6
+ coordinator: Coordinator;
7
+ onServerComponentChanges?: () => Promise<void>;
8
+ };
9
+ export declare class RscServerPlugin extends RspackBuiltinPlugin {
10
+ #private;
11
+ name: string;
12
+ constructor(options: RscServerPluginOptions);
13
+ raw(compiler: Compiler): binding.BuiltinPlugin;
14
+ }
@@ -0,0 +1,24 @@
1
+ import { RscClientPlugin, type RscClientPluginOptions } from './RscClientPlugin.js';
2
+ import { RscServerPlugin } from './RscServerPlugin.js';
3
+ declare class ServerPlugin extends RscServerPlugin {
4
+ constructor(options?: Omit<RscClientPluginOptions, 'coordinator'>);
5
+ }
6
+ declare class ClientPlugin extends RscClientPlugin {
7
+ }
8
+ export declare const rsc: {
9
+ createPlugins: () => {
10
+ ServerPlugin: new (options?: Omit<RscClientPluginOptions, "coordinator">) => ServerPlugin;
11
+ ClientPlugin: new () => ClientPlugin;
12
+ };
13
+ Layers: {
14
+ /**
15
+ * The layer for server-only runtime and picking up `react-server` export conditions.
16
+ */
17
+ readonly rsc: "react-server-components";
18
+ /**
19
+ * Server Side Rendering layer for app.
20
+ */
21
+ readonly ssr: "server-side-rendering";
22
+ };
23
+ };
24
+ export {};
package/dist/exports.d.ts CHANGED
@@ -55,7 +55,7 @@ export { EnvironmentPlugin } from './lib/EnvironmentPlugin.js';
55
55
  export { LoaderOptionsPlugin } from './lib/LoaderOptionsPlugin.js';
56
56
  export { LoaderTargetPlugin } from './lib/LoaderTargetPlugin.js';
57
57
  export type { OutputFileSystem, WatchFileSystem } from './util/fs.js';
58
- import { FetchCompileAsyncWasmPlugin, lazyCompilationMiddleware, SubresourceIntegrityPlugin } from './builtin-plugin/index.js';
58
+ import { FetchCompileAsyncWasmPlugin, lazyCompilationMiddleware, rsc, SubresourceIntegrityPlugin } from './builtin-plugin/index.js';
59
59
  export { SubresourceIntegrityPlugin };
60
60
  interface Web {
61
61
  FetchCompileAsyncWasmPlugin: typeof FetchCompileAsyncWasmPlugin;
@@ -161,5 +161,6 @@ interface Experiments {
161
161
  CssChunkingPlugin: typeof CssChunkingPlugin;
162
162
  createNativePlugin: typeof createNativePlugin;
163
163
  VirtualModulesPlugin: typeof VirtualModulesPlugin;
164
+ rsc: typeof rsc;
164
165
  }
165
166
  export declare const experiments: Experiments;
package/dist/index.js CHANGED
@@ -4563,6 +4563,66 @@ RuntimePlugin.getCompilationHooks = (compilation)=>{
4563
4563
  ])
4564
4564
  }, RuntimePlugin_compilationHooksMap.set(compilation, hooks)), hooks;
4565
4565
  };
4566
+ let Coordinator_PLUGIN_NAME = 'RscPlugin', GET_OR_INIT_BINDING = Symbol('GET_OR_INIT_BINDING');
4567
+ class Coordinator {
4568
+ #serverCompiler;
4569
+ #clientCompiler;
4570
+ #clientLastCompilation;
4571
+ #isProxyingClientWatching = !1;
4572
+ #binding;
4573
+ constructor(){
4574
+ Object.defineProperty(this, GET_OR_INIT_BINDING, {
4575
+ enumerable: !1,
4576
+ configurable: !1,
4577
+ writable: !1,
4578
+ value: ()=>(this.#binding || (this.#binding = new binding_namespaceObject.JsCoordinator(()=>{
4579
+ if (!this.#serverCompiler) throw Error("[RscPlugin] Coordinator.getOrInitBinding() called before the server compiler was attached. Call coordinator.applyServerCompiler(serverCompiler) first.");
4580
+ return this.#serverCompiler[GET_COMPILER_ID]();
4581
+ })), this.#binding)
4582
+ });
4583
+ }
4584
+ applyServerCompiler(serverCompiler) {
4585
+ this.#serverCompiler = serverCompiler, serverCompiler.hooks.done.tap(Coordinator_PLUGIN_NAME, (stats)=>{
4586
+ this.#isProxyingClientWatching = !0, this.#clientLastCompilation && (stats.compilation.fileDependencies.addAll(this.#clientLastCompilation.fileDependencies), stats.compilation.contextDependencies.addAll(this.#clientLastCompilation.contextDependencies), stats.compilation.missingDependencies.addAll(this.#clientLastCompilation.missingDependencies));
4587
+ }), serverCompiler.hooks.watchRun.tap(Coordinator_PLUGIN_NAME, ()=>{
4588
+ this.#isProxyingClientWatching && this.#clientCompiler.watching.invalidateWithChangesAndRemovals(new Set(this.#serverCompiler.modifiedFiles), new Set(this.#serverCompiler.removedFiles));
4589
+ });
4590
+ }
4591
+ applyClientCompiler(clientCompiler) {
4592
+ this.#clientCompiler = clientCompiler;
4593
+ let originalWatch = clientCompiler.watch;
4594
+ clientCompiler.watch = function(watchOptions, handler) {
4595
+ return watchOptions.ignored = ()=>!0, originalWatch.call(this, watchOptions, handler);
4596
+ }, clientCompiler.hooks.done.tap(Coordinator_PLUGIN_NAME, (stats)=>{
4597
+ this.#clientLastCompilation = stats.compilation;
4598
+ });
4599
+ }
4600
+ }
4601
+ class RscClientPlugin extends RspackBuiltinPlugin {
4602
+ name = 'RscClientPlugin';
4603
+ #options;
4604
+ constructor(options){
4605
+ super(), this.#options = options;
4606
+ }
4607
+ raw(compiler) {
4608
+ return this.#options.coordinator.applyClientCompiler(compiler), createBuiltinPlugin(this.name, {
4609
+ coordinator: this.#options.coordinator[GET_OR_INIT_BINDING]()
4610
+ });
4611
+ }
4612
+ }
4613
+ class RscServerPlugin extends RspackBuiltinPlugin {
4614
+ name = 'RscServerPlugin';
4615
+ #options;
4616
+ constructor(options){
4617
+ super(), this.#options = options;
4618
+ }
4619
+ raw(compiler) {
4620
+ return this.#options.coordinator.applyServerCompiler(compiler), createBuiltinPlugin(this.name, {
4621
+ coordinator: this.#options.coordinator[GET_OR_INIT_BINDING](),
4622
+ onServerComponentChanges: this.#options.onServerComponentChanges
4623
+ });
4624
+ }
4625
+ }
4566
4626
  let SideEffectsFlagPlugin = base_create(binding_namespaceObject.BuiltinPluginName.SideEffectsFlagPlugin, ()=>{}, 'compilation'), SizeLimitsPlugin = base_create(binding_namespaceObject.BuiltinPluginName.SizeLimitsPlugin, (options)=>{
4567
4627
  let hints = !1 === options.hints ? void 0 : options.hints;
4568
4628
  return {
@@ -6272,7 +6332,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6272
6332
  return output.wasmLoading && enabledWasmLoadingTypes.add(output.wasmLoading), output.workerWasmLoading && enabledWasmLoadingTypes.add(output.workerWasmLoading), forEachEntry((desc)=>{
6273
6333
  desc.wasmLoading && enabledWasmLoadingTypes.add(desc.wasmLoading);
6274
6334
  }), Array.from(enabledWasmLoadingTypes);
6275
- }), D(output, 'bundlerInfo', {}), 'object' == typeof output.bundlerInfo && (D(output.bundlerInfo, 'version', "2.0.0-canary-30d58971-20260122174325"), D(output.bundlerInfo, 'bundler', 'rspack'), D(output.bundlerInfo, 'force', !output.library));
6335
+ }), D(output, 'bundlerInfo', {}), 'object' == typeof output.bundlerInfo && (D(output.bundlerInfo, 'version', "2.0.0-canary-615f9a1c-20260123175100"), D(output.bundlerInfo, 'bundler', 'rspack'), D(output.bundlerInfo, 'force', !output.library));
6276
6336
  }, applyExternalsPresetsDefaults = (externalsPresets, { targetProperties, buildHttp, outputModule })=>{
6277
6337
  let isUniversal = (key)=>!!(outputModule && targetProperties && null === targetProperties[key]);
6278
6338
  D(externalsPresets, 'web', !buildHttp && targetProperties && (targetProperties.web || isUniversal('node'))), D(externalsPresets, 'node', targetProperties && (targetProperties.node || isUniversal('node'))), D(externalsPresets, 'electron', targetProperties && targetProperties.electron || isUniversal('electron')), D(externalsPresets, 'electronMain', targetProperties && !!targetProperties.electron && (targetProperties.electronMain || isUniversal('electronMain'))), D(externalsPresets, 'electronPreload', targetProperties && !!targetProperties.electron && (targetProperties.electronPreload || isUniversal('electronPreload'))), D(externalsPresets, 'electronRenderer', targetProperties && !!targetProperties.electron && (targetProperties.electronRenderer || isUniversal('electronRenderer'))), D(externalsPresets, 'nwjs', targetProperties && (targetProperties.nwjs || isUniversal('nwjs')));
@@ -7524,7 +7584,7 @@ class MultiStats {
7524
7584
  obj.children = this.stats.map((stat, idx)=>{
7525
7585
  let obj = stat.toJson(childOptions.children[idx]), compilationName = stat.compilation.name;
7526
7586
  return obj.name = compilationName && makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root), obj;
7527
- }), childOptions.version && (obj.rspackVersion = "2.0.0-canary-30d58971-20260122174325", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(''));
7587
+ }), childOptions.version && (obj.rspackVersion = "2.0.0-canary-615f9a1c-20260123175100", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(''));
7528
7588
  let mapError = (j, obj)=>({
7529
7589
  ...obj,
7530
7590
  compilerPath: obj.compilerPath ? `${j.name}.${obj.compilerPath}` : j.name
@@ -8777,7 +8837,7 @@ let iterateConfig = (config, options, fn)=>{
8777
8837
  object.hash = context.getStatsCompilation(compilation).hash;
8778
8838
  },
8779
8839
  version: (object)=>{
8780
- object.version = "5.75.0", object.rspackVersion = "2.0.0-canary-30d58971-20260122174325";
8840
+ object.version = "5.75.0", object.rspackVersion = "2.0.0-canary-615f9a1c-20260123175100";
8781
8841
  },
8782
8842
  env: (object, _compilation, _context, { _env })=>{
8783
8843
  object.env = _env;
@@ -10438,7 +10498,7 @@ class TraceHookPlugin {
10438
10498
  });
10439
10499
  }
10440
10500
  }
10441
- let CORE_VERSION = "2.0.0-canary-30d58971-20260122174325", VFILES_BY_COMPILER = new WeakMap();
10501
+ let CORE_VERSION = "2.0.0-canary-615f9a1c-20260123175100", VFILES_BY_COMPILER = new WeakMap();
10442
10502
  class VirtualModulesPlugin {
10443
10503
  #staticModules;
10444
10504
  #compiler;
@@ -10583,22 +10643,23 @@ class Watching {
10583
10643
  let startTime = this.startTime;
10584
10644
  this.startTime = void 0, compilation.startTime = startTime, compilation.endTime = Date.now();
10585
10645
  let cbs = this.callbacks;
10586
- this.callbacks = [];
10587
- let fileDependencies = new Set([
10588
- ...compilation.fileDependencies
10589
- ]);
10590
- fileDependencies.added = new Set(compilation.__internal__addedFileDependencies), fileDependencies.removed = new Set(compilation.__internal__removedFileDependencies);
10591
- let contextDependencies = new Set([
10592
- ...compilation.contextDependencies
10593
- ]);
10594
- contextDependencies.added = new Set(compilation.__internal__addedContextDependencies), contextDependencies.removed = new Set(compilation.__internal__removedContextDependencies);
10595
- let missingDependencies = new Set([
10596
- ...compilation.missingDependencies
10597
- ]);
10598
- missingDependencies.added = new Set(compilation.__internal__addedMissingDependencies), missingDependencies.removed = new Set(compilation.__internal__removedMissingDependencies), this.compiler.hooks.done.callAsync(stats, (err)=>{
10646
+ this.callbacks = [], this.compiler.hooks.done.callAsync(stats, (err)=>{
10599
10647
  if (err) return handleError(err, cbs);
10600
10648
  for (let cb of (this.handler(null, stats), process.nextTick(()=>{
10601
- this.#closed || this.watch(fileDependencies, contextDependencies, missingDependencies);
10649
+ if (!this.#closed) {
10650
+ let fileDependencies = new Set([
10651
+ ...compilation.fileDependencies
10652
+ ]);
10653
+ fileDependencies.added = new Set(compilation.__internal__addedFileDependencies), fileDependencies.removed = new Set(compilation.__internal__removedFileDependencies);
10654
+ let contextDependencies = new Set([
10655
+ ...compilation.contextDependencies
10656
+ ]);
10657
+ contextDependencies.added = new Set(compilation.__internal__addedContextDependencies), contextDependencies.removed = new Set(compilation.__internal__removedContextDependencies);
10658
+ let missingDependencies = new Set([
10659
+ ...compilation.missingDependencies
10660
+ ]);
10661
+ missingDependencies.added = new Set(compilation.__internal__addedMissingDependencies), missingDependencies.removed = new Set(compilation.__internal__removedMissingDependencies), this.watch(fileDependencies, contextDependencies, missingDependencies);
10662
+ }
10602
10663
  }), cbs))cb(null);
10603
10664
  this.compiler.hooks.afterDone.call(stats);
10604
10665
  });
@@ -10618,7 +10679,7 @@ class Watching {
10618
10679
  this.suspended && (this.suspended = !1, this.#invalidate());
10619
10680
  }
10620
10681
  }
10621
- let Compiler_require = createRequire(import.meta.url);
10682
+ let Compiler_require = createRequire(import.meta.url), GET_COMPILER_ID = Symbol('getCompilerId');
10622
10683
  class Compiler {
10623
10684
  #instance;
10624
10685
  #initial;
@@ -10763,7 +10824,12 @@ class Compiler {
10763
10824
  electron: null
10764
10825
  }, this.#target = {}, this.__internal_browser_require = ()=>{
10765
10826
  throw Error('Cannot execute user defined code in browser without `BrowserRequirePlugin`');
10766
- }, this.resolverFactory = new ResolverFactory(options.resolve.pnp ?? getPnpDefault(), options.resolve, options.resolveLoader), new JsLoaderRspackPlugin(this).apply(this), new ExecuteModulePlugin().apply(this), new TraceHookPlugin().apply(this);
10827
+ }, this.resolverFactory = new ResolverFactory(options.resolve.pnp ?? getPnpDefault(), options.resolve, options.resolveLoader), new JsLoaderRspackPlugin(this).apply(this), new ExecuteModulePlugin().apply(this), new TraceHookPlugin().apply(this), Object.defineProperty(this, GET_COMPILER_ID, {
10828
+ writable: !1,
10829
+ configurable: !1,
10830
+ enumerable: !1,
10831
+ value: ()=>this.#instance.getCompilerId()
10832
+ });
10767
10833
  }
10768
10834
  get recordsInputPath() {
10769
10835
  return unsupported('Compiler.recordsInputPath');
@@ -12227,7 +12293,7 @@ async function transform(source, options) {
12227
12293
  let _options = JSON.stringify(options || {});
12228
12294
  return binding_default().transform(source, _options);
12229
12295
  }
12230
- let exports_rspackVersion = "2.0.0-canary-30d58971-20260122174325", exports_version = "5.75.0", exports_WebpackError = Error, exports_config = {
12296
+ let exports_rspackVersion = "2.0.0-canary-615f9a1c-20260123175100", exports_version = "5.75.0", exports_WebpackError = Error, exports_config = {
12231
12297
  getNormalizedRspackOptions: getNormalizedRspackOptions,
12232
12298
  applyRspackOptionsDefaults: applyRspackOptionsDefaults,
12233
12299
  getNormalizedWebpackOptions: getNormalizedRspackOptions,
@@ -12486,7 +12552,33 @@ let exports_rspackVersion = "2.0.0-canary-30d58971-20260122174325", exports_vers
12486
12552
  if (INTERNAL_PLUGIN_NAMES.includes(name)) throw Error(`Cannot register native plugin with name '${name}', it conflicts with internal plugin names.`);
12487
12553
  return base_create(name, resolve, affectedHooks);
12488
12554
  },
12489
- VirtualModulesPlugin: VirtualModulesPlugin
12555
+ VirtualModulesPlugin: VirtualModulesPlugin,
12556
+ rsc: {
12557
+ createPlugins: ()=>{
12558
+ let coordinator = new Coordinator();
12559
+ return {
12560
+ ServerPlugin: class extends RscServerPlugin {
12561
+ constructor(options = {}){
12562
+ super({
12563
+ coordinator,
12564
+ ...options
12565
+ });
12566
+ }
12567
+ },
12568
+ ClientPlugin: class extends RscClientPlugin {
12569
+ constructor(){
12570
+ super({
12571
+ coordinator
12572
+ });
12573
+ }
12574
+ }
12575
+ };
12576
+ },
12577
+ Layers: {
12578
+ rsc: 'react-server-components',
12579
+ ssr: 'server-side-rendering'
12580
+ }
12581
+ }
12490
12582
  }, src_fn = Object.assign(rspack, exports_namespaceObject);
12491
12583
  src_fn.rspack = src_fn, src_fn.webpack = src_fn;
12492
12584
  let src_rspack_0 = src_fn;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack-canary/core",
3
- "version": "2.0.0-canary-30d58971-20260122174325",
3
+ "version": "2.0.0-canary-615f9a1c-20260123175100",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "The fast Rust-based web bundler with webpack-compatible API",
@@ -58,7 +58,7 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "@rspack/lite-tapable": "1.1.0",
61
- "@rspack/binding": "npm:@rspack-canary/binding@2.0.0-canary-30d58971-20260122174325"
61
+ "@rspack/binding": "npm:@rspack-canary/binding@2.0.0-canary-615f9a1c-20260123175100"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "@module-federation/runtime-tools": ">=0.22.0",