@rspack-debug/browser 2.0.0-rc.2 → 2.0.0-rc.3

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.
@@ -83,5 +83,4 @@ export * from './SplitChunksPlugin';
83
83
  export * from './SubresourceIntegrityPlugin';
84
84
  export * from './SwcJsMinimizerPlugin';
85
85
  export * from './URLPlugin';
86
- export * from './WebWorkerTemplatePlugin';
87
86
  export * from './WorkerPlugin';
@@ -10,7 +10,7 @@
10
10
  import type { ReadStream } from 'node:fs';
11
11
  import type { IncomingMessage, ServerResponse } from 'node:http';
12
12
  import type { ServerOptions } from 'node:https';
13
- import type { Server as ConnectApplication, NextFunction } from 'connect-next';
13
+ import type { NextFunction } from 'connect-next';
14
14
  import type { Filter as ProxyFilter, Options as ProxyOptions } from 'http-proxy-middleware';
15
15
  import type { Options as OpenOptions } from 'open';
16
16
  import type { Compiler, Configuration, LiteralUnion, MultiCompiler, MultiStats, Stats, Watching } from '..';
@@ -153,7 +153,7 @@ export type DevServerClient = {
153
153
  webSocketTransport?: LiteralUnion<'ws', string>;
154
154
  webSocketURL?: string | DevServerWebSocketURL;
155
155
  };
156
- export type DevServerOptions<A extends BasicApplication = ConnectApplication, S extends BasicServer = BasicServer> = {
156
+ export type DevServerOptions<A extends BasicApplication = BasicApplication, S extends BasicServer = BasicServer> = {
157
157
  ipc?: string | boolean;
158
158
  host?: DevServerHost;
159
159
  port?: Port;
@@ -153,7 +153,7 @@ export type EntryStatic = EntryObject | EntryUnnamed;
153
153
  export type EntryDynamic = () => EntryStatic | Promise<EntryStatic>;
154
154
  /** The entry options for building */
155
155
  export type Entry = EntryStatic | EntryDynamic;
156
- /** The output directory as an absolute path. */
156
+ /** The output directory. Relative paths are resolved against `context`. */
157
157
  export type Path = string;
158
158
  /** Tells Rspack to include comments in bundles with information about the contained modules. */
159
159
  export type Pathinfo = boolean | 'verbose';
@@ -210,7 +210,7 @@ export type WorkerPublicPath = string;
210
210
  /** Controls [Trusted Types](https://web.dev/articles/trusted-types) compatibility. */
211
211
  export type TrustedTypes = {
212
212
  /**
213
- * The name of the Trusted Types policy created by webpack to serve bundle chunks.
213
+ * The name of the Trusted Types policy created by Rspack to serve bundle chunks.
214
214
  */
215
215
  policyName?: string;
216
216
  /**
@@ -288,7 +288,7 @@ export type Environment = {
288
288
  module?: boolean;
289
289
  /**
290
290
  * Determines if the node: prefix is generated for core module imports in environments that support it.
291
- * This is only applicable to Webpack runtime code.
291
+ * This is only applicable to Rspack runtime code.
292
292
  * */
293
293
  nodePrefixForCoreModules?: boolean;
294
294
  /** The environment supports optional chaining ('obj?.a' or 'obj?.()'). */
@@ -298,7 +298,7 @@ export type Environment = {
298
298
  };
299
299
  export type Output = {
300
300
  /**
301
- * The output directory as an absolute path.
301
+ * The output directory. Relative paths are resolved against `context`.
302
302
  * @default path.resolve(process.cwd(), 'dist')
303
303
  * */
304
304
  path?: Path;
@@ -2241,13 +2241,13 @@ export type Watch = boolean;
2241
2241
  export type WatchOptions = {
2242
2242
  /**
2243
2243
  * Add a delay before rebuilding once the first file changed.
2244
- * This allows webpack to aggregate any other changes made during this time period into one rebuild.
2244
+ * This allows Rspack to aggregate any other changes made during this time period into one rebuild.
2245
2245
  * @default 5
2246
2246
  */
2247
2247
  aggregateTimeout?: number;
2248
2248
  /**
2249
2249
  * Follow symlinks while looking for files.
2250
- * This is usually not needed as webpack already resolves symlinks ('resolve.symlinks' and 'resolve.alias').
2250
+ * This is usually not needed as Rspack already resolves symlinks ('resolve.symlinks' and 'resolve.alias').
2251
2251
  */
2252
2252
  followSymlinks?: boolean;
2253
2253
  /**
@@ -2306,13 +2306,13 @@ export type Performance = false | {
2306
2306
  */
2307
2307
  hints?: false | 'warning' | 'error';
2308
2308
  /**
2309
- * File size limit (in bytes) when exceeded, that webpack will provide performance hints.
2310
- * @default 250000
2309
+ * File size limit (in bytes) when exceeded, Rspack will provide performance hints.
2310
+ * @default 307200 (300 KiB)
2311
2311
  */
2312
2312
  maxAssetSize?: number;
2313
2313
  /**
2314
2314
  * Total size of an entry point (in bytes).
2315
- * @default 250000
2315
+ * @default 512000 (500 KiB)
2316
2316
  */
2317
2317
  maxEntrypointSize?: number;
2318
2318
  };
package/dist/exports.d.ts CHANGED
@@ -57,9 +57,11 @@ export { LoaderOptionsPlugin } from './lib/LoaderOptionsPlugin';
57
57
  export { LoaderTargetPlugin } from './lib/LoaderTargetPlugin';
58
58
  export type { OutputFileSystem, WatchFileSystem } from './util/fs';
59
59
  import { FetchCompileAsyncWasmPlugin, lazyCompilationMiddleware, rsc, SubresourceIntegrityPlugin } from './builtin-plugin';
60
+ import JsonpTemplatePlugin from './web/JsonpTemplatePlugin';
60
61
  export { SubresourceIntegrityPlugin };
61
62
  interface Web {
62
63
  FetchCompileAsyncWasmPlugin: typeof FetchCompileAsyncWasmPlugin;
64
+ JsonpTemplatePlugin: typeof JsonpTemplatePlugin;
63
65
  }
64
66
  export declare const web: Web;
65
67
  import { NodeTargetPlugin } from './builtin-plugin';
@@ -98,7 +100,7 @@ interface JavaScript {
98
100
  JavascriptModulesPlugin: typeof JavascriptModulesPlugin;
99
101
  }
100
102
  export declare const javascript: JavaScript;
101
- import { WebWorkerTemplatePlugin } from './builtin-plugin';
103
+ import WebWorkerTemplatePlugin from './webworker/WebWorkerTemplatePlugin';
102
104
  interface Webworker {
103
105
  WebWorkerTemplatePlugin: typeof WebWorkerTemplatePlugin;
104
106
  }
package/dist/index.js CHANGED
@@ -60032,13 +60032,6 @@ const SwcJsMinimizerRspackPlugin = base_create(external_rspack_wasi_browser_js_B
60032
60032
  };
60033
60033
  }, 'compilation');
60034
60034
  const URLPlugin = base_create(external_rspack_wasi_browser_js_BuiltinPluginName.URLPlugin, ()=>{}, 'compilation');
60035
- class WebWorkerTemplatePlugin extends RspackBuiltinPlugin {
60036
- name = external_rspack_wasi_browser_js_BuiltinPluginName.WebWorkerTemplatePlugin;
60037
- raw(compiler) {
60038
- compiler.options.output.chunkLoading = "import-scripts";
60039
- return createBuiltinPlugin(this.name, void 0);
60040
- }
60041
- }
60042
60035
  class WorkerPlugin extends RspackBuiltinPlugin {
60043
60036
  chunkLoading;
60044
60037
  wasmLoading;
@@ -61363,6 +61356,7 @@ const mergeTargetProperties = (targetProperties)=>{
61363
61356
  };
61364
61357
  const getTargetsProperties = (targets, context)=>mergeTargetProperties(targets.map((t)=>getTargetProperties(t, context)));
61365
61358
  var defaults_process = __webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/process/browser.js");
61359
+ const ERROR_PREFIX = 'Invalid Rspack configuration:';
61366
61360
  const applyRspackOptionsDefaults = (options)=>{
61367
61361
  F(options, 'context', ()=>defaults_process.cwd());
61368
61362
  F(options, 'target', ()=>getDefaultTarget(options.context));
@@ -61774,6 +61768,10 @@ const applyOutputDefaults = (options, { context, targetProperties: tp, isAffecte
61774
61768
  D(output, 'assetModuleFilename', '[hash][ext][query]');
61775
61769
  D(output, 'webassemblyModuleFilename', '[hash].module.wasm');
61776
61770
  D(output, 'compareBeforeEmit', true);
61771
+ if (output.path && !path_browserify_default().isAbsolute(output.path)) {
61772
+ if (!context) throw new Error(`${ERROR_PREFIX} "context" must be a non-empty absolute path when "output.path" is relative, get "${context ?? ''}".`);
61773
+ output.path = path_browserify_default().resolve(context, output.path);
61774
+ }
61777
61775
  F(output, 'path', ()=>path_browserify_default().join(defaults_process.cwd(), 'dist'));
61778
61776
  F(output, 'pathinfo', ()=>false);
61779
61777
  D(output, 'publicPath', tp && (tp.document || tp.importScripts) ? 'auto' : '');
@@ -61884,7 +61882,7 @@ const applyOutputDefaults = (options, { context, targetProperties: tp, isAffecte
61884
61882
  });
61885
61883
  D(output, 'bundlerInfo', {});
61886
61884
  if ('object' == typeof output.bundlerInfo) {
61887
- D(output.bundlerInfo, 'version', "2.0.0-rc.2");
61885
+ D(output.bundlerInfo, 'version', "2.0.0-rc.3");
61888
61886
  D(output.bundlerInfo, 'bundler', 'rspack');
61889
61887
  D(output.bundlerInfo, 'force', false);
61890
61888
  }
@@ -61932,8 +61930,8 @@ const applyNodeDefaults = (node, { outputModule, targetProperties })=>{
61932
61930
  };
61933
61931
  const applyPerformanceDefaults = (performance, { production })=>{
61934
61932
  if (false === performance) return;
61935
- D(performance, 'maxAssetSize', 250000);
61936
- D(performance, 'maxEntrypointSize', 250000);
61933
+ D(performance, 'maxAssetSize', 307200);
61934
+ D(performance, 'maxEntrypointSize', 512000);
61937
61935
  F(performance, 'hints', ()=>production ? 'warning' : false);
61938
61936
  };
61939
61937
  const applyOptimizationDefaults = (optimization, { production, development })=>{
@@ -63542,7 +63540,7 @@ class MultiStats {
63542
63540
  return obj;
63543
63541
  });
63544
63542
  if (childOptions.version) {
63545
- obj.rspackVersion = "2.0.0-rc.2";
63543
+ obj.rspackVersion = "2.0.0-rc.3";
63546
63544
  obj.version = "5.75.0";
63547
63545
  }
63548
63546
  if (childOptions.hash) obj.hash = obj.children.map((j)=>j.hash).join('');
@@ -65245,7 +65243,7 @@ const SIMPLE_EXTRACTORS = {
65245
65243
  },
65246
65244
  version: (object)=>{
65247
65245
  object.version = "5.75.0";
65248
- object.rspackVersion = "2.0.0-rc.2";
65246
+ object.rspackVersion = "2.0.0-rc.3";
65249
65247
  },
65250
65248
  env: (object, _compilation, _context, { _env })=>{
65251
65249
  object.env = _env;
@@ -66909,17 +66907,14 @@ class RspackOptionsApply {
66909
66907
  compiler.hooks.afterResolvers.call(compiler);
66910
66908
  }
66911
66909
  }
66912
- const ERROR_PREFIX = 'Invalid Rspack configuration:';
66910
+ const validateConfig_ERROR_PREFIX = 'Invalid Rspack configuration:';
66913
66911
  const validateContext = ({ context })=>{
66914
- if (context && !(0, path_browserify.isAbsolute)(context)) throw new Error(`${ERROR_PREFIX} "context" must be an absolute path, get "${context}".`);
66915
- };
66916
- const validateOutputPath = ({ output })=>{
66917
- if (output?.path && !(0, path_browserify.isAbsolute)(output.path)) throw new Error(`${ERROR_PREFIX} "output.path" must be an absolute path, get "${output.path}".`);
66912
+ if (context && !(0, path_browserify.isAbsolute)(context)) throw new Error(`${validateConfig_ERROR_PREFIX} "context" must be an absolute path, get "${context}".`);
66918
66913
  };
66919
66914
  const validateSplitChunks = ({ optimization })=>{
66920
66915
  if (optimization?.splitChunks) {
66921
66916
  const { minChunks } = optimization.splitChunks;
66922
- if (void 0 !== minChunks && minChunks < 1) throw new Error(`${ERROR_PREFIX} "optimization.splitChunks.minChunks" must be greater than or equal to 1, get \`${minChunks}\`.`);
66917
+ if (void 0 !== minChunks && minChunks < 1) throw new Error(`${validateConfig_ERROR_PREFIX} "optimization.splitChunks.minChunks" must be greater than or equal to 1, get \`${minChunks}\`.`);
66923
66918
  }
66924
66919
  };
66925
66920
  const validateExternalUmd = ({ output, externals, externalsType })=>{
@@ -66938,14 +66933,13 @@ const validateExternalUmd = ({ output, externals, externalsType })=>{
66938
66933
  'commonjs2',
66939
66934
  'amd'
66940
66935
  ];
66941
- if (requiredKeys.some((key)=>void 0 === value[key])) throw new Error(`${ERROR_PREFIX} External object must have "root", "commonjs", "commonjs2", "amd" properties when "libraryType" or "externalsType" is "umd", get: ${JSON.stringify(value, null, 2)}.`);
66936
+ if (requiredKeys.some((key)=>void 0 === value[key])) throw new Error(`${validateConfig_ERROR_PREFIX} External object must have "root", "commonjs", "commonjs2", "amd" properties when "libraryType" or "externalsType" is "umd", get: ${JSON.stringify(value, null, 2)}.`);
66942
66937
  };
66943
66938
  if (Array.isArray(externals)) externals.forEach((external)=>checkExternalItem(external));
66944
66939
  else checkExternalItem(externals);
66945
66940
  };
66946
66941
  function validateRspackConfig(config) {
66947
66942
  validateContext(config);
66948
- validateOutputPath(config);
66949
66943
  validateSplitChunks(config);
66950
66944
  validateExternalUmd(config);
66951
66945
  }
@@ -68874,6 +68868,13 @@ class LoaderTargetPlugin {
68874
68868
  });
68875
68869
  }
68876
68870
  }
68871
+ class JsonpTemplatePlugin {
68872
+ apply(compiler) {
68873
+ compiler.options.output.chunkLoading = 'jsonp';
68874
+ new ArrayPushCallbackChunkFormatPlugin().apply(compiler);
68875
+ new EnableChunkLoadingPlugin('jsonp').apply(compiler);
68876
+ }
68877
+ }
68877
68878
  class NodeTemplatePlugin {
68878
68879
  _options;
68879
68880
  constructor(_options = {}){
@@ -68886,6 +68887,13 @@ class NodeTemplatePlugin {
68886
68887
  new EnableChunkLoadingPlugin(chunkLoading).apply(compiler);
68887
68888
  }
68888
68889
  }
68890
+ class WebWorkerTemplatePlugin {
68891
+ apply(compiler) {
68892
+ compiler.options.output.chunkLoading = "import-scripts";
68893
+ new ArrayPushCallbackChunkFormatPlugin().apply(compiler);
68894
+ new EnableChunkLoadingPlugin("import-scripts").apply(compiler);
68895
+ }
68896
+ }
68889
68897
  const options_process = (options, normalizeSimple, normalizeOptions, fn)=>{
68890
68898
  const array = (items)=>{
68891
68899
  for (const item of items)if ('string' == typeof item) fn(item, normalizeSimple(item, item));
@@ -69732,7 +69740,7 @@ class ModuleFederationPlugin {
69732
69740
  this._options = _options;
69733
69741
  }
69734
69742
  apply(compiler) {
69735
- const { webpack } = compiler;
69743
+ const { rspack } = compiler;
69736
69744
  const paths = getPaths(this._options, compiler);
69737
69745
  compiler.options.resolve.alias = {
69738
69746
  '@module-federation/runtime-tools': paths.runtimeTools,
@@ -69789,7 +69797,7 @@ class ModuleFederationPlugin {
69789
69797
  shared: this._options.shared,
69790
69798
  enhanced: true
69791
69799
  };
69792
- new webpack.container.ModuleFederationPluginV1(v1Options).apply(compiler);
69800
+ new rspack.container.ModuleFederationPluginV1(v1Options).apply(compiler);
69793
69801
  if (this._options.manifest) new ModuleFederationManifestPlugin(this._options).apply(compiler);
69794
69802
  }
69795
69803
  }
@@ -70064,7 +70072,7 @@ function transformSync(source, options) {
70064
70072
  const _options = JSON.stringify(options || {});
70065
70073
  return rspack_wasi_browser.transformSync(source, _options);
70066
70074
  }
70067
- const exports_rspackVersion = "2.0.0-rc.2";
70075
+ const exports_rspackVersion = "2.0.0-rc.3";
70068
70076
  const exports_version = "5.75.0";
70069
70077
  const exports_WebpackError = Error;
70070
70078
  const exports_config = {
@@ -70078,7 +70086,8 @@ const util = {
70078
70086
  cleverMerge: cachedCleverMerge
70079
70087
  };
70080
70088
  const web = {
70081
- FetchCompileAsyncWasmPlugin: FetchCompileAsyncWasmPlugin
70089
+ FetchCompileAsyncWasmPlugin: FetchCompileAsyncWasmPlugin,
70090
+ JsonpTemplatePlugin: JsonpTemplatePlugin
70082
70091
  };
70083
70092
  const exports_node = {
70084
70093
  NodeTargetPlugin: NodeTargetPlugin,
@@ -549,7 +549,6 @@ export declare enum BuiltinPluginName {
549
549
  HotModuleReplacementPlugin = 'HotModuleReplacementPlugin',
550
550
  LimitChunkCountPlugin = 'LimitChunkCountPlugin',
551
551
  WorkerPlugin = 'WorkerPlugin',
552
- WebWorkerTemplatePlugin = 'WebWorkerTemplatePlugin',
553
552
  MergeDuplicateChunksPlugin = 'MergeDuplicateChunksPlugin',
554
553
  SplitChunksPlugin = 'SplitChunksPlugin',
555
554
  RemoveDuplicateModulesPlugin = 'RemoveDuplicateModulesPlugin',
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The following code is modified based on
3
+ * https://github.com/webpack/webpack/blob/4b4ca3b/lib/web/JsonpTemplatePlugin.js
4
+ *
5
+ * MIT Licensed
6
+ * Author Tobias Koppers @sokra
7
+ * Copyright (c) JS Foundation and other contributors
8
+ * https://github.com/webpack/webpack/blob/main/LICENSE
9
+ */
10
+ import type { Compiler } from '../Compiler';
11
+ export default class JsonpTemplatePlugin {
12
+ apply(compiler: Compiler): void;
13
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The following code is modified based on
3
+ * https://github.com/webpack/webpack/blob/4b4ca3b/lib/webworker/WebWorkerTemplatePlugin.js
4
+ *
5
+ * MIT Licensed
6
+ * Author Tobias Koppers @sokra
7
+ * Copyright (c) JS Foundation and other contributors
8
+ * https://github.com/webpack/webpack/blob/main/LICENSE
9
+ */
10
+ import type { Compiler } from '../Compiler';
11
+ export default class WebWorkerTemplatePlugin {
12
+ apply(compiler: Compiler): void;
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack-debug/browser",
3
- "version": "2.0.0-rc.2",
3
+ "version": "2.0.0-rc.3",
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.",
@@ -1,7 +0,0 @@
1
- import { type BuiltinPlugin, BuiltinPluginName } from '../binding';
2
- import type { Compiler } from '../Compiler';
3
- import { RspackBuiltinPlugin } from './base';
4
- export declare class WebWorkerTemplatePlugin extends RspackBuiltinPlugin {
5
- name: BuiltinPluginName;
6
- raw(compiler: Compiler): BuiltinPlugin | undefined;
7
- }