@rspack/browser 1.6.1 → 1.6.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.
@@ -1,6 +1,16 @@
1
1
  import type binding from "./binding";
2
2
  import type { ResolveCallback } from "./config/adapterRuleUse";
3
- type ResolveContext = {};
3
+ export type ResolveContext = {
4
+ contextDependencies?: {
5
+ add: (context: string) => void;
6
+ };
7
+ missingDependencies?: {
8
+ add: (dependency: string) => void;
9
+ };
10
+ fileDependencies?: {
11
+ add: (dependency: string) => void;
12
+ };
13
+ };
4
14
  export type ResourceData = binding.JsResourceData;
5
15
  export interface ResolveRequest {
6
16
  path: string;
@@ -8,6 +18,9 @@ export interface ResolveRequest {
8
18
  fragment: string;
9
19
  descriptionFileData?: string;
10
20
  descriptionFilePath?: string;
21
+ fileDependencies?: string[];
22
+ missingDependencies?: string[];
23
+ contextDependencies?: string[];
11
24
  }
12
25
  export declare class Resolver {
13
26
  #private;
@@ -15,4 +28,3 @@ export declare class Resolver {
15
28
  resolveSync(context: object, path: string, request: string): string | false;
16
29
  resolve(context: object, path: string, request: string, resolveContext: ResolveContext, callback: ResolveCallback): void;
17
30
  }
18
- export {};
@@ -111,6 +111,9 @@ export interface ExperimentsNormalized {
111
111
  */
112
112
  layers?: boolean;
113
113
  incremental?: false | Incremental;
114
+ /**
115
+ * @deprecated This option is deprecated, as it has a huge regression in some edge cases where the chunk graph has lots of cycles. We will improve performance of build_chunk_graph.
116
+ */
114
117
  parallelCodeSplitting?: boolean;
115
118
  futureDefaults?: boolean;
116
119
  rspackFuture?: RspackFutureOptions;
@@ -2100,6 +2100,7 @@ export type Experiments = {
2100
2100
  incremental?: IncrementalPresets | Incremental;
2101
2101
  /**
2102
2102
  * Enable multi-threaded code splitting algorithm.
2103
+ * @deprecated This option is deprecated, it has a huge regression in some edge cases where the chunk graph has lots of cycles. We'll improve the performance of build_chunk_graph in the future instead
2103
2104
  */
2104
2105
  parallelCodeSplitting?: boolean;
2105
2106
  /**
@@ -0,0 +1,37 @@
1
+ import { type BuiltinPlugin, BuiltinPluginName } from "../binding";
2
+ import { RspackBuiltinPlugin } from "../builtin-plugin/base";
3
+ import type { Compiler } from "../Compiler";
4
+ export type RemoteAliasMap = Record<string, {
5
+ name: string;
6
+ entry?: string;
7
+ }>;
8
+ export type ManifestExposeOption = {
9
+ path: string;
10
+ name: string;
11
+ };
12
+ export type ManifestSharedOption = {
13
+ name: string;
14
+ version?: string;
15
+ requiredVersion?: string;
16
+ singleton?: boolean;
17
+ };
18
+ export type ModuleFederationManifestPluginOptions = {
19
+ name?: string;
20
+ globalName?: string;
21
+ filePath?: string;
22
+ disableAssetsAnalyze?: boolean;
23
+ fileName?: string;
24
+ remoteAliasMap?: RemoteAliasMap;
25
+ exposes?: ManifestExposeOption[];
26
+ shared?: ManifestSharedOption[];
27
+ };
28
+ /**
29
+ * JS-side post-processing plugin: reads mf-manifest.json and mf-stats.json, executes additionalData callback and merges/overwrites manifest.
30
+ * To avoid cross-NAPI callback complexity, this plugin runs at the afterProcessAssets stage to ensure Rust-side MfManifestPlugin has already output its artifacts.
31
+ */
32
+ export declare class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
33
+ name: BuiltinPluginName;
34
+ private opts;
35
+ constructor(opts: ModuleFederationManifestPluginOptions);
36
+ raw(compiler: Compiler): BuiltinPlugin;
37
+ }
@@ -1,9 +1,11 @@
1
1
  import type { Compiler } from "../Compiler";
2
+ import { type ModuleFederationManifestPluginOptions } from "./ModuleFederationManifestPlugin";
2
3
  import type { ModuleFederationPluginV1Options } from "./ModuleFederationPluginV1";
3
4
  export interface ModuleFederationPluginOptions extends Omit<ModuleFederationPluginV1Options, "enhanced"> {
4
5
  runtimePlugins?: RuntimePlugins;
5
6
  implementation?: string;
6
7
  shareStrategy?: "version-first" | "loaded-first";
8
+ manifest?: boolean | Omit<ModuleFederationManifestPluginOptions, "remoteAliasMap" | "globalName" | "name" | "exposes" | "shared">;
7
9
  }
8
10
  export type RuntimePlugins = string[] | [string, Record<string, unknown>][];
9
11
  export declare class ModuleFederationPlugin {
package/dist/index.mjs CHANGED
@@ -58126,7 +58126,7 @@ const applybundlerInfoDefaults = (rspackFuture, library)=>{
58126
58126
  if ("object" == typeof rspackFuture) {
58127
58127
  D(rspackFuture, "bundlerInfo", {});
58128
58128
  if ("object" == typeof rspackFuture.bundlerInfo) {
58129
- D(rspackFuture.bundlerInfo, "version", "1.6.1");
58129
+ D(rspackFuture.bundlerInfo, "version", "1.6.2");
58130
58130
  D(rspackFuture.bundlerInfo, "bundler", "rspack");
58131
58131
  D(rspackFuture.bundlerInfo, "force", !library);
58132
58132
  }
@@ -58986,6 +58986,7 @@ const getNormalizedRspackOptions = (config)=>({
58986
58986
  experiments: nestedConfig(config.experiments, (experiments)=>{
58987
58987
  if (experiments.layers) util_default().deprecate(()=>{}, "`experiments.layers` config has been deprecated and will be removed in Rspack v2.0. Feature layers will be always enabled. Please remove this option from your Rspack configuration.")();
58988
58988
  if (false === experiments.topLevelAwait) util_default().deprecate(()=>{}, "`experiments.topLevelAwait` config has been deprecated and will be removed in Rspack v2.0. Top-level await will be always enabled. Please remove this option from your Rspack configuration.")();
58989
+ if (experiments.parallelCodeSplitting) util_default().deprecate(()=>{}, "`experiments.parallelCodeSplitting` config has been deprecated and will be removed in next minor. It has huge regression in some edge cases where the chunk graph has lots of cycles, we'll improve the performance of build_chunk_graph in the future instead")();
58989
58990
  return {
58990
58991
  ...experiments,
58991
58992
  cache: optionalNestedConfig(experiments.cache, (cache)=>{
@@ -59907,6 +59908,12 @@ class Resolver {
59907
59908
  Resolver_class_private_field_get(this, _binding).resolve(path, request, (error, text)=>{
59908
59909
  if (error) return void callback(error);
59909
59910
  const req = text ? JSON.parse(text) : void 0;
59911
+ if (req?.fileDependencies) req.fileDependencies.forEach((file)=>{
59912
+ resolveContext.fileDependencies?.add(file);
59913
+ });
59914
+ if (req?.missingDependencies) req.missingDependencies.forEach((missing)=>{
59915
+ resolveContext.missingDependencies?.add(missing);
59916
+ });
59910
59917
  callback(error, req ? `${req.path.replace(/#/g, "\u200b#")}${req.query.replace(/#/g, "\u200b#")}${req.fragment}` : false, req);
59911
59918
  });
59912
59919
  }
@@ -62068,7 +62075,7 @@ class MultiStats {
62068
62075
  return obj;
62069
62076
  });
62070
62077
  if (childOptions.version) {
62071
- obj.rspackVersion = "1.6.1";
62078
+ obj.rspackVersion = "1.6.2";
62072
62079
  obj.version = "5.75.0";
62073
62080
  }
62074
62081
  if (childOptions.hash) obj.hash = obj.children.map((j)=>j.hash).join("");
@@ -63373,7 +63380,7 @@ const SIMPLE_EXTRACTORS = {
63373
63380
  },
63374
63381
  version: (object)=>{
63375
63382
  object.version = "5.75.0";
63376
- object.rspackVersion = "1.6.1";
63383
+ object.rspackVersion = "1.6.2";
63377
63384
  },
63378
63385
  env: (object, _compilation, _context, { _env })=>{
63379
63386
  object.env = _env;
@@ -65802,6 +65809,100 @@ class NodeTemplatePlugin {
65802
65809
  this._options = _options;
65803
65810
  }
65804
65811
  }
65812
+ const VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
65813
+ function isRequiredVersion(str) {
65814
+ return VERSION_PATTERN_REGEXP.test(str);
65815
+ }
65816
+ var ModuleFederationManifestPlugin_process = __webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/process/browser.js");
65817
+ function ModuleFederationManifestPlugin_define_property(obj, key, value) {
65818
+ if (key in obj) Object.defineProperty(obj, key, {
65819
+ value: value,
65820
+ enumerable: true,
65821
+ configurable: true,
65822
+ writable: true
65823
+ });
65824
+ else obj[key] = value;
65825
+ return obj;
65826
+ }
65827
+ const MANIFEST_FILE_NAME = "mf-manifest.json";
65828
+ const STATS_FILE_NAME = "mf-stats.json";
65829
+ const LOCAL_BUILD_VERSION = "local";
65830
+ const JSON_EXT = ".json";
65831
+ function isPlainObject(value) {
65832
+ return Boolean(value) && "object" == typeof value && !Array.isArray(value);
65833
+ }
65834
+ function parseJSON(input, guard) {
65835
+ try {
65836
+ const parsed = JSON.parse(input);
65837
+ if (guard(parsed)) return parsed;
65838
+ } catch {}
65839
+ }
65840
+ function readPKGJson(root) {
65841
+ const base = root ? (0, path_browserify.resolve)(root) : ModuleFederationManifestPlugin_process.cwd();
65842
+ const pkgPath = (0, path_browserify.join)(base, "package.json");
65843
+ try {
65844
+ const content = (0, browser_fs.readFileSync)(pkgPath, "utf-8");
65845
+ const parsed = parseJSON(content, isPlainObject);
65846
+ if (parsed) {
65847
+ const filtered = {};
65848
+ for (const [key, value] of Object.entries(parsed))if ("string" == typeof value) filtered[key] = value;
65849
+ if (Object.keys(filtered).length > 0) return filtered;
65850
+ }
65851
+ } catch {}
65852
+ return {};
65853
+ }
65854
+ function getBuildInfo(isDev, root) {
65855
+ const rootPath = root || ModuleFederationManifestPlugin_process.cwd();
65856
+ const pkg = readPKGJson(rootPath);
65857
+ const buildVersion = isDev ? LOCAL_BUILD_VERSION : pkg?.version;
65858
+ return {
65859
+ buildVersion: ModuleFederationManifestPlugin_process.env.MF_BUILD_VERSION || buildVersion || "UNKNOWN",
65860
+ buildName: ModuleFederationManifestPlugin_process.env.MF_BUILD_NAME || pkg?.name || "UNKNOWN"
65861
+ };
65862
+ }
65863
+ function getFileName(manifestOptions) {
65864
+ if (!manifestOptions) return {
65865
+ statsFileName: STATS_FILE_NAME,
65866
+ manifestFileName: MANIFEST_FILE_NAME
65867
+ };
65868
+ const filePath = "boolean" == typeof manifestOptions ? "" : manifestOptions.filePath || "";
65869
+ const fileName = "boolean" == typeof manifestOptions ? "" : manifestOptions.fileName || "";
65870
+ const addExt = (name)=>{
65871
+ if (name.endsWith(JSON_EXT)) return name;
65872
+ return `${name}${JSON_EXT}`;
65873
+ };
65874
+ const insertSuffix = (name, suffix)=>name.replace(JSON_EXT, `${suffix}${JSON_EXT}`);
65875
+ const manifestFileName = fileName ? addExt(fileName) : MANIFEST_FILE_NAME;
65876
+ const statsFileName = fileName ? insertSuffix(manifestFileName, "-stats") : STATS_FILE_NAME;
65877
+ return {
65878
+ statsFileName: (0, path_browserify.join)(filePath, statsFileName),
65879
+ manifestFileName: (0, path_browserify.join)(filePath, manifestFileName)
65880
+ };
65881
+ }
65882
+ class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
65883
+ raw(compiler) {
65884
+ const { fileName, filePath, disableAssetsAnalyze, remoteAliasMap, exposes, shared } = this.opts;
65885
+ const { statsFileName, manifestFileName } = getFileName(this.opts);
65886
+ const rawOptions = {
65887
+ name: this.opts.name,
65888
+ globalName: this.opts.globalName,
65889
+ fileName,
65890
+ filePath,
65891
+ manifestFileName,
65892
+ statsFileName,
65893
+ disableAssetsAnalyze,
65894
+ remoteAliasMap,
65895
+ exposes,
65896
+ shared,
65897
+ buildInfo: getBuildInfo("development" === compiler.options.mode, compiler.context)
65898
+ };
65899
+ return createBuiltinPlugin(this.name, rawOptions);
65900
+ }
65901
+ constructor(opts){
65902
+ super(), ModuleFederationManifestPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.ModuleFederationManifestPlugin), ModuleFederationManifestPlugin_define_property(this, "opts", void 0);
65903
+ this.opts = opts;
65904
+ }
65905
+ }
65805
65906
  const ModuleFederationRuntimePlugin = base_create(external_rspack_wasi_browser_js_.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options);
65806
65907
  const options_process = (options, normalizeSimple, normalizeOptions, fn)=>{
65807
65908
  const array = (items)=>{
@@ -65854,12 +65955,93 @@ class ModuleFederationPlugin {
65854
65955
  ...this._options,
65855
65956
  enhanced: true
65856
65957
  }).apply(compiler);
65958
+ if (this._options.manifest) {
65959
+ const manifestOptions = true === this._options.manifest ? {} : {
65960
+ ...this._options.manifest
65961
+ };
65962
+ const containerName = manifestOptions.name ?? this._options.name;
65963
+ const globalName = manifestOptions.globalName ?? resolveLibraryGlobalName(this._options.library) ?? containerName;
65964
+ const remoteAliasMap = Object.entries(getRemoteInfos(this._options)).reduce((sum, cur)=>{
65965
+ if (cur[1].length > 1) return sum;
65966
+ const remoteInfo = cur[1][0];
65967
+ const { entry, alias, name } = remoteInfo;
65968
+ if (entry && name) sum[alias] = {
65969
+ name,
65970
+ entry
65971
+ };
65972
+ return sum;
65973
+ }, {});
65974
+ const manifestExposes = collectManifestExposes(this._options.exposes);
65975
+ if (void 0 === manifestOptions.exposes && manifestExposes) manifestOptions.exposes = manifestExposes;
65976
+ const manifestShared = collectManifestShared(this._options.shared);
65977
+ if (void 0 === manifestOptions.shared && manifestShared) manifestOptions.shared = manifestShared;
65978
+ new ModuleFederationManifestPlugin({
65979
+ ...manifestOptions,
65980
+ name: containerName,
65981
+ globalName,
65982
+ remoteAliasMap
65983
+ }).apply(compiler);
65984
+ }
65857
65985
  }
65858
65986
  constructor(_options){
65859
65987
  ModuleFederationPlugin_define_property(this, "_options", void 0);
65860
65988
  this._options = _options;
65861
65989
  }
65862
65990
  }
65991
+ function collectManifestExposes(exposes) {
65992
+ if (!exposes) return;
65993
+ const parsed = parseOptions(exposes, (value, key)=>({
65994
+ import: Array.isArray(value) ? value : [
65995
+ value
65996
+ ],
65997
+ name: void 0
65998
+ }), (value)=>({
65999
+ import: Array.isArray(value.import) ? value.import : [
66000
+ value.import
66001
+ ],
66002
+ name: value.name ?? void 0
66003
+ }));
66004
+ const result = parsed.map(([exposeKey, info])=>{
66005
+ const exposeName = info.name ?? exposeKey.replace(/^\.\//, "");
66006
+ return {
66007
+ path: exposeKey,
66008
+ name: exposeName
66009
+ };
66010
+ });
66011
+ return result.length > 0 ? result : void 0;
66012
+ }
66013
+ function collectManifestShared(shared) {
66014
+ if (!shared) return;
66015
+ const parsed = parseOptions(shared, (item, key)=>{
66016
+ if ("string" != typeof item) throw new Error("Unexpected array in shared");
66017
+ return item !== key && isRequiredVersion(item) ? {
66018
+ import: key,
66019
+ requiredVersion: item
66020
+ } : {
66021
+ import: item
66022
+ };
66023
+ }, (item)=>item);
66024
+ const result = parsed.map(([key, config])=>{
66025
+ const name = config.shareKey || key;
66026
+ const version = "string" == typeof config.version ? config.version : void 0;
66027
+ const requiredVersion = "string" == typeof config.requiredVersion ? config.requiredVersion : void 0;
66028
+ return {
66029
+ name,
66030
+ version,
66031
+ requiredVersion,
66032
+ singleton: config.singleton
66033
+ };
66034
+ });
66035
+ return result.length > 0 ? result : void 0;
66036
+ }
66037
+ function resolveLibraryGlobalName(library) {
66038
+ if (!library) return;
66039
+ const libName = library.name;
66040
+ if (!libName) return;
66041
+ if ("string" == typeof libName) return libName;
66042
+ if (Array.isArray(libName)) return libName[0];
66043
+ if ("object" == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
66044
+ }
65863
66045
  function getRemoteInfos(options) {
65864
66046
  if (!options.remotes) return {};
65865
66047
  function extractUrlAndGlobal(urlAndGlobal) {
@@ -65985,10 +66167,6 @@ class ShareRuntimePlugin extends RspackBuiltinPlugin {
65985
66167
  super(), ShareRuntimePlugin_define_property(this, "enhanced", void 0), ShareRuntimePlugin_define_property(this, "name", void 0), this.enhanced = enhanced, this.name = external_rspack_wasi_browser_js_.BuiltinPluginName.ShareRuntimePlugin;
65986
66168
  }
65987
66169
  }
65988
- const VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
65989
- function isRequiredVersion(str) {
65990
- return VERSION_PATTERN_REGEXP.test(str);
65991
- }
65992
66170
  function ConsumeSharedPlugin_define_property(obj, key, value) {
65993
66171
  if (key in obj) Object.defineProperty(obj, key, {
65994
66172
  value: value,
@@ -66339,7 +66517,7 @@ function transformSync(source, options) {
66339
66517
  const _options = JSON.stringify(options || {});
66340
66518
  return external_rspack_wasi_browser_js_["default"].transformSync(source, _options);
66341
66519
  }
66342
- const exports_rspackVersion = "1.6.1";
66520
+ const exports_rspackVersion = "1.6.2";
66343
66521
  const exports_version = "5.75.0";
66344
66522
  const exports_WebpackError = Error;
66345
66523
  const sources = __webpack_require__("../../node_modules/.pnpm/webpack-sources@3.3.3_patch_hash=b2a26650f08a2359d0a3cd81fa6fa272aa7441a28dd7e601792da5ed5d2b4aee/node_modules/webpack-sources/lib/index.js");
@@ -545,6 +545,7 @@ export declare enum BuiltinPluginName {
545
545
  ProvideSharedPlugin = 'ProvideSharedPlugin',
546
546
  ConsumeSharedPlugin = 'ConsumeSharedPlugin',
547
547
  ModuleFederationRuntimePlugin = 'ModuleFederationRuntimePlugin',
548
+ ModuleFederationManifestPlugin = 'ModuleFederationManifestPlugin',
548
549
  NamedModuleIdsPlugin = 'NamedModuleIdsPlugin',
549
550
  NaturalModuleIdsPlugin = 'NaturalModuleIdsPlugin',
550
551
  DeterministicModuleIdsPlugin = 'DeterministicModuleIdsPlugin',
@@ -2434,6 +2435,32 @@ export interface RawLimitChunkCountPluginOptions {
2434
2435
  maxChunks: number
2435
2436
  }
2436
2437
 
2438
+ export interface RawManifestExposeOption {
2439
+ path: string
2440
+ name: string
2441
+ }
2442
+
2443
+ export interface RawManifestSharedOption {
2444
+ name: string
2445
+ version?: string
2446
+ requiredVersion?: string
2447
+ singleton?: boolean
2448
+ }
2449
+
2450
+ export interface RawModuleFederationManifestPluginOptions {
2451
+ name?: string
2452
+ globalName?: string
2453
+ fileName?: string
2454
+ filePath?: string
2455
+ statsFileName?: string
2456
+ manifestFileName?: string
2457
+ disableAssetsAnalyze?: boolean
2458
+ remoteAliasMap?: Record<string, RawRemoteAliasTarget>
2459
+ exposes?: Array<RawManifestExposeOption>
2460
+ shared?: Array<RawManifestSharedOption>
2461
+ buildInfo?: RawStatsBuildInfo
2462
+ }
2463
+
2437
2464
  export interface RawModuleFederationRuntimePluginOptions {
2438
2465
  entryRuntime?: string | undefined
2439
2466
  }
@@ -2656,6 +2683,11 @@ export interface RawRelated {
2656
2683
  sourceMap?: string
2657
2684
  }
2658
2685
 
2686
+ export interface RawRemoteAliasTarget {
2687
+ name: string
2688
+ entry?: string
2689
+ }
2690
+
2659
2691
  export interface RawRemoteOptions {
2660
2692
  key: string
2661
2693
  external: Array<string>
@@ -2815,6 +2847,11 @@ export interface RawSplitChunksOptions {
2815
2847
  maxInitialSize?: number | RawSplitChunkSizes
2816
2848
  }
2817
2849
 
2850
+ export interface RawStatsBuildInfo {
2851
+ buildVersion: string
2852
+ buildName?: string
2853
+ }
2854
+
2818
2855
  export interface RawStatsOptions {
2819
2856
  colors: boolean
2820
2857
  }
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/browser",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "Rspack for running in the browser. This is still in early stage and may not follow the semver.",