@rspack/core 2.0.0-alpha.0 → 2.0.0-alpha.1

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 {};
@@ -1989,25 +1989,17 @@ export type Incremental = {
1989
1989
  */
1990
1990
  silent?: boolean;
1991
1991
  /**
1992
- * Enable incremental make.
1992
+ * Enable incremental build module graph.
1993
1993
  */
1994
- make?: boolean;
1994
+ buildModuleGraph?: boolean;
1995
1995
  /**
1996
- * Enable inference of async modules.
1996
+ * Enable incremental finish modules.
1997
1997
  */
1998
- inferAsyncModules?: boolean;
1998
+ finishModules?: boolean;
1999
1999
  /**
2000
- * Enable incremental provided exports.
2000
+ * Enable incremental optimize dependencies.
2001
2001
  */
2002
- providedExports?: boolean;
2003
- /**
2004
- * Enables diagnostics for dependencies.
2005
- */
2006
- dependenciesDiagnostics?: boolean;
2007
- /**
2008
- * Enables incremental side effects optimization.
2009
- */
2010
- sideEffects?: boolean;
2002
+ optimizeDependencies?: boolean;
2011
2003
  /**
2012
2004
  * Enable incremental build chunk graph.
2013
2005
  */
@@ -2041,11 +2033,11 @@ export type Incremental = {
2041
2033
  */
2042
2034
  chunksHashes?: boolean;
2043
2035
  /**
2044
- * Enable incremental chunk render.
2036
+ * Enable incremental chunk asset.
2045
2037
  */
2046
- chunksRender?: boolean;
2038
+ chunkAsset?: boolean;
2047
2039
  /**
2048
- * Enable incremental asset emission.
2040
+ * Enable incremental emit assets.
2049
2041
  */
2050
2042
  emitAssets?: boolean;
2051
2043
  };
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
@@ -598,6 +598,17 @@ class Stats {
598
598
  compilation: this.compilation,
599
599
  getStatsCompilation: (compilation)=>{
600
600
  if (statsCompilationMap.has(compilation)) return statsCompilationMap.get(compilation);
601
+ if (this.compilation !== this.compilation.compiler._lastCompilation) return {
602
+ assets: [],
603
+ assetsByChunkName: [],
604
+ chunks: [],
605
+ entrypoints: [],
606
+ errors: [],
607
+ hash: 'XXXX',
608
+ modules: [],
609
+ namedChunkGroups: [],
610
+ warnings: []
611
+ };
601
612
  let innerStats = this.#getInnerByCompilation(compilation);
602
613
  options.warnings = !1;
603
614
  let innerStatsCompilation = innerStats.toJson(options);
@@ -613,6 +624,17 @@ class Stats {
613
624
  compilation: this.compilation,
614
625
  getStatsCompilation: (compilation)=>{
615
626
  if (statsCompilationMap.has(compilation)) return statsCompilationMap.get(compilation);
627
+ if (this.compilation !== this.compilation.compiler._lastCompilation) return {
628
+ assets: [],
629
+ assetsByChunkName: [],
630
+ chunks: [],
631
+ entrypoints: [],
632
+ errors: [],
633
+ hash: 'XXXX',
634
+ modules: [],
635
+ namedChunkGroups: [],
636
+ warnings: []
637
+ };
616
638
  let innerStatsCompilation = this.#getInnerByCompilation(compilation).toJson(options);
617
639
  return statsCompilationMap.set(compilation, innerStatsCompilation), innerStatsCompilation;
618
640
  },
@@ -4563,6 +4585,66 @@ RuntimePlugin.getCompilationHooks = (compilation)=>{
4563
4585
  ])
4564
4586
  }, RuntimePlugin_compilationHooksMap.set(compilation, hooks)), hooks;
4565
4587
  };
4588
+ let Coordinator_PLUGIN_NAME = 'RscPlugin', GET_OR_INIT_BINDING = Symbol('GET_OR_INIT_BINDING');
4589
+ class Coordinator {
4590
+ #serverCompiler;
4591
+ #clientCompiler;
4592
+ #clientLastCompilation;
4593
+ #isProxyingClientWatching = !1;
4594
+ #binding;
4595
+ constructor(){
4596
+ Object.defineProperty(this, GET_OR_INIT_BINDING, {
4597
+ enumerable: !1,
4598
+ configurable: !1,
4599
+ writable: !1,
4600
+ value: ()=>(this.#binding || (this.#binding = new binding_namespaceObject.JsCoordinator(()=>{
4601
+ if (!this.#serverCompiler) throw Error("[RscPlugin] Coordinator.getOrInitBinding() called before the server compiler was attached. Call coordinator.applyServerCompiler(serverCompiler) first.");
4602
+ return this.#serverCompiler[GET_COMPILER_ID]();
4603
+ })), this.#binding)
4604
+ });
4605
+ }
4606
+ applyServerCompiler(serverCompiler) {
4607
+ this.#serverCompiler = serverCompiler, serverCompiler.hooks.done.tap(Coordinator_PLUGIN_NAME, (stats)=>{
4608
+ 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));
4609
+ }), serverCompiler.hooks.watchRun.tap(Coordinator_PLUGIN_NAME, ()=>{
4610
+ this.#isProxyingClientWatching && this.#clientCompiler.watching.invalidateWithChangesAndRemovals(new Set(this.#serverCompiler.modifiedFiles), new Set(this.#serverCompiler.removedFiles));
4611
+ });
4612
+ }
4613
+ applyClientCompiler(clientCompiler) {
4614
+ this.#clientCompiler = clientCompiler;
4615
+ let originalWatch = clientCompiler.watch;
4616
+ clientCompiler.watch = function(watchOptions, handler) {
4617
+ return watchOptions.ignored = ()=>!0, originalWatch.call(this, watchOptions, handler);
4618
+ }, clientCompiler.hooks.done.tap(Coordinator_PLUGIN_NAME, (stats)=>{
4619
+ this.#clientLastCompilation = stats.compilation;
4620
+ });
4621
+ }
4622
+ }
4623
+ class RscClientPlugin extends RspackBuiltinPlugin {
4624
+ name = 'RscClientPlugin';
4625
+ #options;
4626
+ constructor(options){
4627
+ super(), this.#options = options;
4628
+ }
4629
+ raw(compiler) {
4630
+ return this.#options.coordinator.applyClientCompiler(compiler), createBuiltinPlugin(this.name, {
4631
+ coordinator: this.#options.coordinator[GET_OR_INIT_BINDING]()
4632
+ });
4633
+ }
4634
+ }
4635
+ class RscServerPlugin extends RspackBuiltinPlugin {
4636
+ name = 'RscServerPlugin';
4637
+ #options;
4638
+ constructor(options){
4639
+ super(), this.#options = options;
4640
+ }
4641
+ raw(compiler) {
4642
+ return this.#options.coordinator.applyServerCompiler(compiler), createBuiltinPlugin(this.name, {
4643
+ coordinator: this.#options.coordinator[GET_OR_INIT_BINDING](),
4644
+ onServerComponentChanges: this.#options.onServerComponentChanges
4645
+ });
4646
+ }
4647
+ }
4566
4648
  let SideEffectsFlagPlugin = base_create(binding_namespaceObject.BuiltinPluginName.SideEffectsFlagPlugin, ()=>{}, 'compilation'), SizeLimitsPlugin = base_create(binding_namespaceObject.BuiltinPluginName.SizeLimitsPlugin, (options)=>{
4567
4649
  let hints = !1 === options.hints ? void 0 : options.hints;
4568
4650
  return {
@@ -5998,7 +6080,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
5998
6080
  }, applyExperimentsDefaults = (experiments)=>{
5999
6081
  D(experiments, 'futureDefaults', !1), D(experiments, 'asyncWebAssembly', !0), D(experiments, 'deferImport', !1), D(experiments, 'buildHttp', void 0), experiments.buildHttp && 'object' == typeof experiments.buildHttp && D(experiments.buildHttp, 'upgrade', !1), D(experiments, 'useInputFileSystem', !1);
6000
6082
  }, applyIncrementalDefaults = (options)=>{
6001
- D(options, 'incremental', {}), 'object' == typeof options.incremental && (D(options.incremental, 'silent', !0), D(options.incremental, 'make', !0), D(options.incremental, 'inferAsyncModules', !0), D(options.incremental, 'providedExports', !0), D(options.incremental, 'dependenciesDiagnostics', !0), D(options.incremental, 'sideEffects', !0), D(options.incremental, 'buildChunkGraph', !1), D(options.incremental, 'moduleIds', !0), D(options.incremental, 'chunkIds', !0), D(options.incremental, 'modulesHashes', !0), D(options.incremental, 'modulesCodegen', !0), D(options.incremental, 'modulesRuntimeRequirements', !0), D(options.incremental, 'chunksRuntimeRequirements', !0), D(options.incremental, 'chunksHashes', !0), D(options.incremental, 'chunksRender', !0), D(options.incremental, 'emitAssets', !0));
6083
+ D(options, 'incremental', {}), 'object' == typeof options.incremental && (D(options.incremental, 'silent', !0), D(options.incremental, 'buildModuleGraph', !0), D(options.incremental, 'finishModules', !0), D(options.incremental, 'optimizeDependencies', !0), D(options.incremental, 'buildChunkGraph', !1), D(options.incremental, 'moduleIds', !0), D(options.incremental, 'chunkIds', !0), D(options.incremental, 'modulesHashes', !0), D(options.incremental, 'modulesCodegen', !0), D(options.incremental, 'modulesRuntimeRequirements', !0), D(options.incremental, 'chunksRuntimeRequirements', !0), D(options.incremental, 'chunksHashes', !0), D(options.incremental, 'chunkAsset', !0), D(options.incremental, 'emitAssets', !0));
6002
6084
  }, applySnapshotDefaults = (_snapshot, _env)=>{}, applyCssGeneratorOptionsDefaults = (generatorOptions, { targetProperties })=>{
6003
6085
  D(generatorOptions, 'exportsOnly', !targetProperties || !1 === targetProperties.document), D(generatorOptions, 'esModule', !0);
6004
6086
  }, applyModuleDefaults = (module, { cache, asyncWebAssembly, targetProperties, mode, uniqueName, deferImport })=>{
@@ -6272,7 +6354,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6272
6354
  return output.wasmLoading && enabledWasmLoadingTypes.add(output.wasmLoading), output.workerWasmLoading && enabledWasmLoadingTypes.add(output.workerWasmLoading), forEachEntry((desc)=>{
6273
6355
  desc.wasmLoading && enabledWasmLoadingTypes.add(desc.wasmLoading);
6274
6356
  }), Array.from(enabledWasmLoadingTypes);
6275
- }), D(output, 'bundlerInfo', {}), 'object' == typeof output.bundlerInfo && (D(output.bundlerInfo, 'version', "2.0.0-alpha.0"), D(output.bundlerInfo, 'bundler', 'rspack'), D(output.bundlerInfo, 'force', !output.library));
6357
+ }), D(output, 'bundlerInfo', {}), 'object' == typeof output.bundlerInfo && (D(output.bundlerInfo, 'version', "2.0.0-alpha.1"), D(output.bundlerInfo, 'bundler', 'rspack'), D(output.bundlerInfo, 'force', !output.library));
6276
6358
  }, applyExternalsPresetsDefaults = (externalsPresets, { targetProperties, buildHttp, outputModule })=>{
6277
6359
  let isUniversal = (key)=>!!(outputModule && targetProperties && null === targetProperties[key]);
6278
6360
  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')));
@@ -6687,11 +6769,9 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6687
6769
  }
6688
6770
  }, getNormalizedIncrementalOptions = (incremental)=>!1 !== incremental && 'none' !== incremental && ('safe' === incremental ? {
6689
6771
  silent: !0,
6690
- make: !0,
6691
- inferAsyncModules: !1,
6692
- providedExports: !1,
6693
- dependenciesDiagnostics: !1,
6694
- sideEffects: !1,
6772
+ buildModuleGraph: !0,
6773
+ finishModules: !1,
6774
+ optimizeDependencies: !1,
6695
6775
  buildChunkGraph: !1,
6696
6776
  moduleIds: !1,
6697
6777
  chunkIds: !1,
@@ -6700,7 +6780,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6700
6780
  modulesRuntimeRequirements: !1,
6701
6781
  chunksRuntimeRequirements: !1,
6702
6782
  chunksHashes: !1,
6703
- chunksRender: !1,
6783
+ chunkAsset: !1,
6704
6784
  emitAssets: !0
6705
6785
  } : !0 === incremental || 'advance-silent' === incremental ? {} : 'advance' === incremental ? {
6706
6786
  silent: !1
@@ -7526,7 +7606,7 @@ class MultiStats {
7526
7606
  obj.children = this.stats.map((stat, idx)=>{
7527
7607
  let obj = stat.toJson(childOptions.children[idx]), compilationName = stat.compilation.name;
7528
7608
  return obj.name = compilationName && makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root), obj;
7529
- }), childOptions.version && (obj.rspackVersion = "2.0.0-alpha.0", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(''));
7609
+ }), childOptions.version && (obj.rspackVersion = "2.0.0-alpha.1", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(''));
7530
7610
  let mapError = (j, obj)=>({
7531
7611
  ...obj,
7532
7612
  compilerPath: obj.compilerPath ? `${j.name}.${obj.compilerPath}` : j.name
@@ -8682,15 +8762,21 @@ let iterateConfig = (config, options, fn)=>{
8682
8762
  if (context.makePathsRelative || (context.makePathsRelative = makePathsRelative.bindContextCache(compilation.compiler.context, compilation.compiler.root)), !context.cachedGetErrors) {
8683
8763
  let map = new WeakMap();
8684
8764
  context.cachedGetErrors = (compilation)=>{
8685
- var errors;
8686
- return map.get(compilation) || (errors = statsCompilation.errors, map.set(compilation, errors), errors);
8765
+ if (compilation.compiler._lastCompilation !== compilation) return [];
8766
+ let cache = map.get(compilation);
8767
+ if (cache) return cache;
8768
+ let errors = statsCompilation.errors;
8769
+ return map.set(compilation, errors), errors;
8687
8770
  };
8688
8771
  }
8689
8772
  if (!context.cachedGetWarnings) {
8690
8773
  let map = new WeakMap();
8691
8774
  context.cachedGetWarnings = (compilation)=>{
8692
- var warnings;
8693
- return map.get(compilation) || (warnings = compilation.__internal_getInner().createStatsWarnings(compilation.getWarnings(), !!options.colors), map.set(compilation, warnings), warnings);
8775
+ if (compilation.compiler._lastCompilation !== compilation) return [];
8776
+ let cache = map.get(compilation);
8777
+ if (cache) return cache;
8778
+ let warnings = compilation.__internal_getInner().createStatsWarnings(compilation.getWarnings(), !!options.colors);
8779
+ return map.set(compilation, warnings), warnings;
8694
8780
  };
8695
8781
  }
8696
8782
  compilation.name && (object.name = compilation.name);
@@ -8779,7 +8865,7 @@ let iterateConfig = (config, options, fn)=>{
8779
8865
  object.hash = context.getStatsCompilation(compilation).hash;
8780
8866
  },
8781
8867
  version: (object)=>{
8782
- object.version = "5.75.0", object.rspackVersion = "2.0.0-alpha.0";
8868
+ object.version = "5.75.0", object.rspackVersion = "2.0.0-alpha.1";
8783
8869
  },
8784
8870
  env: (object, _compilation, _context, { _env })=>{
8785
8871
  object.env = _env;
@@ -10440,7 +10526,7 @@ class TraceHookPlugin {
10440
10526
  });
10441
10527
  }
10442
10528
  }
10443
- let CORE_VERSION = "2.0.0-alpha.0", VFILES_BY_COMPILER = new WeakMap();
10529
+ let CORE_VERSION = "2.0.0-alpha.1", VFILES_BY_COMPILER = new WeakMap();
10444
10530
  class VirtualModulesPlugin {
10445
10531
  #staticModules;
10446
10532
  #compiler;
@@ -10585,22 +10671,23 @@ class Watching {
10585
10671
  let startTime = this.startTime;
10586
10672
  this.startTime = void 0, compilation.startTime = startTime, compilation.endTime = Date.now();
10587
10673
  let cbs = this.callbacks;
10588
- this.callbacks = [];
10589
- let fileDependencies = new Set([
10590
- ...compilation.fileDependencies
10591
- ]);
10592
- fileDependencies.added = new Set(compilation.__internal__addedFileDependencies), fileDependencies.removed = new Set(compilation.__internal__removedFileDependencies);
10593
- let contextDependencies = new Set([
10594
- ...compilation.contextDependencies
10595
- ]);
10596
- contextDependencies.added = new Set(compilation.__internal__addedContextDependencies), contextDependencies.removed = new Set(compilation.__internal__removedContextDependencies);
10597
- let missingDependencies = new Set([
10598
- ...compilation.missingDependencies
10599
- ]);
10600
- missingDependencies.added = new Set(compilation.__internal__addedMissingDependencies), missingDependencies.removed = new Set(compilation.__internal__removedMissingDependencies), this.compiler.hooks.done.callAsync(stats, (err)=>{
10674
+ this.callbacks = [], this.compiler.hooks.done.callAsync(stats, (err)=>{
10601
10675
  if (err) return handleError(err, cbs);
10602
10676
  for (let cb of (this.handler(null, stats), process.nextTick(()=>{
10603
- this.#closed || this.watch(fileDependencies, contextDependencies, missingDependencies);
10677
+ if (!this.#closed) {
10678
+ let fileDependencies = new Set([
10679
+ ...compilation.fileDependencies
10680
+ ]);
10681
+ fileDependencies.added = new Set(compilation.__internal__addedFileDependencies), fileDependencies.removed = new Set(compilation.__internal__removedFileDependencies);
10682
+ let contextDependencies = new Set([
10683
+ ...compilation.contextDependencies
10684
+ ]);
10685
+ contextDependencies.added = new Set(compilation.__internal__addedContextDependencies), contextDependencies.removed = new Set(compilation.__internal__removedContextDependencies);
10686
+ let missingDependencies = new Set([
10687
+ ...compilation.missingDependencies
10688
+ ]);
10689
+ missingDependencies.added = new Set(compilation.__internal__addedMissingDependencies), missingDependencies.removed = new Set(compilation.__internal__removedMissingDependencies), this.watch(fileDependencies, contextDependencies, missingDependencies);
10690
+ }
10604
10691
  }), cbs))cb(null);
10605
10692
  this.compiler.hooks.afterDone.call(stats);
10606
10693
  });
@@ -10620,7 +10707,7 @@ class Watching {
10620
10707
  this.suspended && (this.suspended = !1, this.#invalidate());
10621
10708
  }
10622
10709
  }
10623
- let Compiler_require = createRequire(import.meta.url);
10710
+ let Compiler_require = createRequire(import.meta.url), GET_COMPILER_ID = Symbol('getCompilerId');
10624
10711
  class Compiler {
10625
10712
  #instance;
10626
10713
  #initial;
@@ -10765,7 +10852,12 @@ class Compiler {
10765
10852
  electron: null
10766
10853
  }, this.#target = {}, this.__internal_browser_require = ()=>{
10767
10854
  throw Error('Cannot execute user defined code in browser without `BrowserRequirePlugin`');
10768
- }, 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);
10855
+ }, 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, {
10856
+ writable: !1,
10857
+ configurable: !1,
10858
+ enumerable: !1,
10859
+ value: ()=>this.#instance.getCompilerId()
10860
+ });
10769
10861
  }
10770
10862
  get recordsInputPath() {
10771
10863
  return unsupported('Compiler.recordsInputPath');
@@ -12229,7 +12321,7 @@ async function transform(source, options) {
12229
12321
  let _options = JSON.stringify(options || {});
12230
12322
  return binding_default().transform(source, _options);
12231
12323
  }
12232
- let exports_rspackVersion = "2.0.0-alpha.0", exports_version = "5.75.0", exports_WebpackError = Error, exports_config = {
12324
+ let exports_rspackVersion = "2.0.0-alpha.1", exports_version = "5.75.0", exports_WebpackError = Error, exports_config = {
12233
12325
  getNormalizedRspackOptions: getNormalizedRspackOptions,
12234
12326
  applyRspackOptionsDefaults: applyRspackOptionsDefaults,
12235
12327
  getNormalizedWebpackOptions: getNormalizedRspackOptions,
@@ -12488,7 +12580,33 @@ let exports_rspackVersion = "2.0.0-alpha.0", exports_version = "5.75.0", exports
12488
12580
  if (INTERNAL_PLUGIN_NAMES.includes(name)) throw Error(`Cannot register native plugin with name '${name}', it conflicts with internal plugin names.`);
12489
12581
  return base_create(name, resolve, affectedHooks);
12490
12582
  },
12491
- VirtualModulesPlugin: VirtualModulesPlugin
12583
+ VirtualModulesPlugin: VirtualModulesPlugin,
12584
+ rsc: {
12585
+ createPlugins: ()=>{
12586
+ let coordinator = new Coordinator();
12587
+ return {
12588
+ ServerPlugin: class extends RscServerPlugin {
12589
+ constructor(options = {}){
12590
+ super({
12591
+ coordinator,
12592
+ ...options
12593
+ });
12594
+ }
12595
+ },
12596
+ ClientPlugin: class extends RscClientPlugin {
12597
+ constructor(){
12598
+ super({
12599
+ coordinator
12600
+ });
12601
+ }
12602
+ }
12603
+ };
12604
+ },
12605
+ Layers: {
12606
+ rsc: 'react-server-components',
12607
+ ssr: 'server-side-rendering'
12608
+ }
12609
+ }
12492
12610
  }, src_fn = Object.assign(rspack, exports_namespaceObject);
12493
12611
  src_fn.rspack = src_fn, src_fn.webpack = src_fn;
12494
12612
  let src_rspack_0 = src_fn;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/core",
3
- "version": "2.0.0-alpha.0",
3
+ "version": "2.0.0-alpha.1",
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": "2.0.0-alpha.0"
61
+ "@rspack/binding": "2.0.0-alpha.1"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "@module-federation/runtime-tools": ">=0.22.0",