@rspack-canary/browser 1.5.0-canary-1b8c8525-20250820061915 → 1.5.0-canary-e5e47098-20250820070851

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,5 +1,4 @@
1
1
  export * from "../index";
2
- export { BrowserHttpImportPlugin } from "./BrowserHttpImportPlugin";
3
2
  export declare const builtinMemFs: {
4
3
  fs: import("memfs").IFs;
5
4
  volume: import("memfs").Volume;
@@ -5,7 +5,8 @@ export declare class ExternalsPlugin extends RspackBuiltinPlugin {
5
5
  #private;
6
6
  private type;
7
7
  private externals;
8
+ private placeInInitial?;
8
9
  name: BuiltinPluginName;
9
- constructor(type: string, externals: Externals);
10
+ constructor(type: string, externals: Externals, placeInInitial?: boolean | undefined);
10
11
  raw(): BuiltinPlugin | undefined;
11
12
  }
package/dist/index.mjs CHANGED
@@ -40613,12 +40613,13 @@ class ExternalsPlugin extends RspackBuiltinPlugin {
40613
40613
  type,
40614
40614
  externals: (Array.isArray(externals) ? externals : [
40615
40615
  externals
40616
- ]).filter(Boolean).map((item)=>ExternalsPlugin_class_private_field_get(this, _getRawExternalItem).call(this, item))
40616
+ ]).filter(Boolean).map((item)=>ExternalsPlugin_class_private_field_get(this, _getRawExternalItem).call(this, item)),
40617
+ placeInInitial: this.placeInInitial ?? false
40617
40618
  };
40618
40619
  return createBuiltinPlugin(this.name, raw);
40619
40620
  }
40620
- constructor(type, externals){
40621
- super(), ExternalsPlugin_class_private_method_init(this, _processRequest), ExternalsPlugin_define_property(this, "type", void 0), ExternalsPlugin_define_property(this, "externals", void 0), ExternalsPlugin_define_property(this, "name", void 0), ExternalsPlugin_class_private_field_init(this, _resolveRequestCache, {
40621
+ constructor(type, externals, placeInInitial){
40622
+ super(), ExternalsPlugin_class_private_method_init(this, _processRequest), ExternalsPlugin_define_property(this, "type", void 0), ExternalsPlugin_define_property(this, "externals", void 0), ExternalsPlugin_define_property(this, "placeInInitial", void 0), ExternalsPlugin_define_property(this, "name", void 0), ExternalsPlugin_class_private_field_init(this, _resolveRequestCache, {
40622
40623
  writable: true,
40623
40624
  value: void 0
40624
40625
  }), ExternalsPlugin_class_private_field_init(this, _processResolveResult, {
@@ -40627,7 +40628,7 @@ class ExternalsPlugin extends RspackBuiltinPlugin {
40627
40628
  }), ExternalsPlugin_class_private_field_init(this, _getRawExternalItem, {
40628
40629
  writable: true,
40629
40630
  value: void 0
40630
- }), this.type = type, this.externals = externals, this.name = external_rspack_wasi_browser_js_.BuiltinPluginName.ExternalsPlugin, ExternalsPlugin_class_private_field_set(this, _resolveRequestCache, new Map()), ExternalsPlugin_class_private_field_set(this, _processResolveResult, (text)=>{
40631
+ }), this.type = type, this.externals = externals, this.placeInInitial = placeInInitial, this.name = external_rspack_wasi_browser_js_.BuiltinPluginName.ExternalsPlugin, ExternalsPlugin_class_private_field_set(this, _resolveRequestCache, new Map()), ExternalsPlugin_class_private_field_set(this, _processResolveResult, (text)=>{
40631
40632
  if (!text) return;
40632
40633
  let resolveRequest = ExternalsPlugin_class_private_field_get(this, _resolveRequestCache).get(text);
40633
40634
  if (!resolveRequest) {
@@ -40765,19 +40766,45 @@ function HttpUriPlugin_define_property(obj, key, value) {
40765
40766
  else obj[key] = value;
40766
40767
  return obj;
40767
40768
  }
40768
- memoize(()=>__webpack_require__("../../node_modules/.pnpm/stream-http@3.2.0/node_modules/stream-http/index.js"));
40769
- memoize(()=>__webpack_require__("../../node_modules/.pnpm/https-browserify@1.0.0/node_modules/https-browserify/index.js"));
40770
- const defaultHttpClientForBrowser = async (url, headers)=>{
40771
- const res = await fetch(url, {
40769
+ const getHttp = memoize(()=>__webpack_require__("../../node_modules/.pnpm/stream-http@3.2.0/node_modules/stream-http/index.js"));
40770
+ const getHttps = memoize(()=>__webpack_require__("../../node_modules/.pnpm/https-browserify@1.0.0/node_modules/https-browserify/index.js"));
40771
+ function fetch(url, options) {
40772
+ const parsedURL = new URL(url);
40773
+ const send = "https:" === parsedURL.protocol ? getHttps() : getHttp();
40774
+ const { createBrotliDecompress, createGunzip, createInflate } = __webpack_require__("../../node_modules/.pnpm/browserify-zlib@0.2.0/node_modules/browserify-zlib/lib/index.js");
40775
+ return new Promise((resolve, reject)=>{
40776
+ send.get(url, options, (res)=>{
40777
+ const contentEncoding = res.headers["content-encoding"];
40778
+ let stream = res;
40779
+ if ("gzip" === contentEncoding) stream = stream.pipe(createGunzip());
40780
+ else if ("br" === contentEncoding) stream = stream.pipe(createBrotliDecompress());
40781
+ else if ("deflate" === contentEncoding) stream = stream.pipe(createInflate());
40782
+ const chunks = [];
40783
+ stream.on("data", (chunk)=>{
40784
+ chunks.push(chunk);
40785
+ });
40786
+ stream.on("end", ()=>{
40787
+ const bodyBuffer = Buffer.concat(chunks);
40788
+ if (!res.complete) return void reject(new Error(`${url} request was terminated early`));
40789
+ resolve({
40790
+ res,
40791
+ body: bodyBuffer
40792
+ });
40793
+ });
40794
+ }).on("error", reject);
40795
+ });
40796
+ }
40797
+ const defaultHttpClient = async (url, headers)=>{
40798
+ const { res, body } = await fetch(url, {
40772
40799
  headers
40773
40800
  });
40774
40801
  const responseHeaders = {};
40775
40802
  for (const [key, value] of Object.entries(res.headers))if (Array.isArray(value)) responseHeaders[key] = value.join(", ");
40776
40803
  else responseHeaders[key] = value;
40777
40804
  return {
40778
- status: res.status,
40805
+ status: res.statusCode,
40779
40806
  headers: responseHeaders,
40780
- body: Buffer.from(await res.arrayBuffer())
40807
+ body: Buffer.from(body)
40781
40808
  };
40782
40809
  };
40783
40810
  class HttpUriPlugin extends RspackBuiltinPlugin {
@@ -40785,7 +40812,6 @@ class HttpUriPlugin extends RspackBuiltinPlugin {
40785
40812
  const options = this.options;
40786
40813
  const lockfileLocation = options.lockfileLocation ?? path_browserify_default().join(compiler.context, compiler.name ? `${compiler.name}.rspack.lock` : "rspack.lock");
40787
40814
  const cacheLocation = false === options.cacheLocation ? void 0 : options.cacheLocation ?? `${lockfileLocation}.data`;
40788
- const defaultHttpClient = defaultHttpClientForBrowser;
40789
40815
  const raw = {
40790
40816
  allowedUris: options.allowedUris,
40791
40817
  lockfileLocation,
@@ -47076,7 +47102,7 @@ const applybundlerInfoDefaults = (rspackFuture, library)=>{
47076
47102
  if ("object" == typeof rspackFuture) {
47077
47103
  D(rspackFuture, "bundlerInfo", {});
47078
47104
  if ("object" == typeof rspackFuture.bundlerInfo) {
47079
- D(rspackFuture.bundlerInfo, "version", "1.5.0-canary-1b8c8525-20250820061915");
47105
+ D(rspackFuture.bundlerInfo, "version", "1.5.0-canary-e5e47098-20250820070851");
47080
47106
  D(rspackFuture.bundlerInfo, "bundler", "rspack");
47081
47107
  D(rspackFuture.bundlerInfo, "force", !library);
47082
47108
  }
@@ -51161,7 +51187,7 @@ class MultiStats {
51161
51187
  return obj;
51162
51188
  });
51163
51189
  if (childOptions.version) {
51164
- obj.rspackVersion = "1.5.0-canary-1b8c8525-20250820061915";
51190
+ obj.rspackVersion = "1.5.0-canary-e5e47098-20250820070851";
51165
51191
  obj.version = "5.75.0";
51166
51192
  }
51167
51193
  if (childOptions.hash) obj.hash = obj.children.map((j)=>j.hash).join("");
@@ -52471,7 +52497,7 @@ const SIMPLE_EXTRACTORS = {
52471
52497
  },
52472
52498
  version: (object)=>{
52473
52499
  object.version = "5.75.0";
52474
- object.rspackVersion = "1.5.0-canary-1b8c8525-20250820061915";
52500
+ object.rspackVersion = "1.5.0-canary-e5e47098-20250820070851";
52475
52501
  },
52476
52502
  env: (object, _compilation, _context, { _env })=>{
52477
52503
  object.env = _env;
@@ -54082,14 +54108,14 @@ class RspackOptionsApply {
54082
54108
  compiler.outputFileSystem = browser_fs["default"];
54083
54109
  if (options.externals) {
54084
54110
  assert_default()(options.externalsType, "options.externalsType should have value after `applyRspackOptionsDefaults`");
54085
- new ExternalsPlugin(options.externalsType, options.externals).apply(compiler);
54111
+ new ExternalsPlugin(options.externalsType, options.externals, false).apply(compiler);
54086
54112
  }
54087
54113
  if (options.externalsPresets.node) new NodeTargetPlugin().apply(compiler);
54088
54114
  if (options.externalsPresets.electronMain) new ElectronTargetPlugin("main").apply(compiler);
54089
54115
  if (options.externalsPresets.electronPreload) new ElectronTargetPlugin("preload").apply(compiler);
54090
54116
  if (options.externalsPresets.electronRenderer) new ElectronTargetPlugin("renderer").apply(compiler);
54091
54117
  if (options.externalsPresets.electron && !options.externalsPresets.electronMain && !options.externalsPresets.electronPreload && !options.externalsPresets.electronRenderer) new ElectronTargetPlugin().apply(compiler);
54092
- if (options.externalsPresets.nwjs) new ExternalsPlugin("node-commonjs", "nw.gui").apply(compiler);
54118
+ if (options.externalsPresets.nwjs) new ExternalsPlugin("node-commonjs", "nw.gui", false).apply(compiler);
54093
54119
  if (options.externalsPresets.web || options.externalsPresets.webAsync || options.externalsPresets.node && options.experiments.css) new HttpExternalsRspackPlugin(!!options.experiments.css, !!options.externalsPresets.webAsync).apply(compiler);
54094
54120
  new ChunkPrefetchPreloadPlugin().apply(compiler);
54095
54121
  if (options.output.pathinfo) new ModuleInfoHeaderPlugin("verbose" === options.output.pathinfo).apply(compiler);
@@ -56837,7 +56863,7 @@ class ContainerReferencePlugin extends RspackBuiltinPlugin {
56837
56863
  i++;
56838
56864
  }
56839
56865
  }
56840
- new ExternalsPlugin(remoteType, remoteExternals).apply(compiler);
56866
+ new ExternalsPlugin(remoteType, remoteExternals, true).apply(compiler);
56841
56867
  new ShareRuntimePlugin(this._options.enhanced).apply(compiler);
56842
56868
  const rawOptions = {
56843
56869
  remoteType: this._options.remoteType,
@@ -56933,7 +56959,7 @@ function transformSync(source, options) {
56933
56959
  const _options = JSON.stringify(options || {});
56934
56960
  return external_rspack_wasi_browser_js_["default"].transformSync(source, _options);
56935
56961
  }
56936
- const exports_rspackVersion = "1.5.0-canary-1b8c8525-20250820061915";
56962
+ const exports_rspackVersion = "1.5.0-canary-e5e47098-20250820070851";
56937
56963
  const exports_version = "5.75.0";
56938
56964
  const exports_WebpackError = Error;
56939
56965
  const sources = __webpack_require__("../../node_modules/.pnpm/webpack-sources@3.3.3_patch_hash=b2a26650f08a2359d0a3cd81fa6fa272aa7441a28dd7e601792da5ed5d2b4aee/node_modules/webpack-sources/lib/index.js");
@@ -57104,106 +57130,6 @@ const src_fn = Object.assign(rspack_rspack, exports_namespaceObject);
57104
57130
  src_fn.rspack = src_fn;
57105
57131
  src_fn.webpack = src_fn;
57106
57132
  const src_rspack = src_fn;
57107
- function BrowserHttpImportPlugin_define_property(obj, key, value) {
57108
- if (key in obj) Object.defineProperty(obj, key, {
57109
- value: value,
57110
- enumerable: true,
57111
- configurable: true,
57112
- writable: true
57113
- });
57114
- else obj[key] = value;
57115
- return obj;
57116
- }
57117
- const DOMAIN_ESM_SH = "https://esm.sh";
57118
- class BrowserHttpImportPlugin {
57119
- apply(compiler) {
57120
- compiler.hooks.normalModuleFactory.tap("BrowserHttpImportPlugin", (nmf)=>{
57121
- nmf.hooks.resolve.tap("BrowserHttpImportPlugin", (resolveData)=>{
57122
- const request = resolveData.request;
57123
- const packageName = getPackageName(request);
57124
- if (this.options.dependencyUrl) {
57125
- if ("function" == typeof this.options.dependencyUrl) {
57126
- const url = this.options.dependencyUrl(packageName);
57127
- if (url) {
57128
- resolveData.request = url;
57129
- return;
57130
- }
57131
- } else if ("object" == typeof this.options.dependencyUrl) {
57132
- const url = this.options.dependencyUrl[packageName];
57133
- if (url) {
57134
- resolveData.request = url;
57135
- return;
57136
- }
57137
- }
57138
- }
57139
- const issuerUrl = toUrl(resolveData.contextInfo.issuer);
57140
- if (issuerUrl) {
57141
- resolveData.request = this.resolveWithUrlIssuer(request, issuerUrl);
57142
- return;
57143
- }
57144
- if (this.isNodeModule(request)) {
57145
- resolveData.request = this.resolveNodeModule(request, packageName);
57146
- return;
57147
- }
57148
- });
57149
- });
57150
- }
57151
- resolveWithUrlIssuer(request, issuer) {
57152
- return new URL(request, issuer).href;
57153
- }
57154
- resolveNodeModule(request, packageName) {
57155
- var _this_options_dependencyVersions;
57156
- let domain = DOMAIN_ESM_SH;
57157
- if ("function" == typeof this.options.domain) domain = this.options.domain(request, packageName);
57158
- else if ("string" == typeof this.options.domain) domain = this.options.domain;
57159
- const version = (null == (_this_options_dependencyVersions = this.options.dependencyVersions) ? void 0 : _this_options_dependencyVersions[packageName]) || "latest";
57160
- const versionedRequest = getRequestWithVersion(request, version);
57161
- return `${domain}/${versionedRequest}`;
57162
- }
57163
- isNodeModule(request) {
57164
- if (toUrl(request)) return false;
57165
- return !request.startsWith(".") && !request.startsWith("/") && !request.startsWith("!");
57166
- }
57167
- constructor(options = {}){
57168
- BrowserHttpImportPlugin_define_property(this, "options", void 0);
57169
- this.options = options;
57170
- }
57171
- }
57172
- function getPackageName(request) {
57173
- if (request.startsWith("@")) {
57174
- const parts = request.split("/");
57175
- return `${parts[0]}/${parts[1]}`;
57176
- }
57177
- return request.split("/")[0];
57178
- }
57179
- function getRequestWithVersion(request, version) {
57180
- if (request.startsWith("@")) {
57181
- const secondSlashIndex = request.indexOf("/", request.indexOf("/") + 1);
57182
- if (-1 === secondSlashIndex) return `${request}@${version}`;
57183
- {
57184
- const scopedPackage = request.substring(0, secondSlashIndex);
57185
- const restPath = request.substring(secondSlashIndex);
57186
- return `${scopedPackage}@${version}${restPath}`;
57187
- }
57188
- }
57189
- {
57190
- const firstSlashIndex = request.indexOf("/");
57191
- if (-1 === firstSlashIndex) return `${request}@${version}`;
57192
- {
57193
- const packageName = request.substring(0, firstSlashIndex);
57194
- const restPath = request.substring(firstSlashIndex);
57195
- return `${packageName}@${version}${restPath}`;
57196
- }
57197
- }
57198
- }
57199
- function toUrl(request) {
57200
- try {
57201
- const url = new URL(request);
57202
- return url;
57203
- } catch {
57204
- return;
57205
- }
57206
- }
57207
57133
  const builtinMemFs = {
57208
57134
  fs: browser_fs.fs,
57209
57135
  volume: browser_fs.volume
@@ -57216,4 +57142,4 @@ var __webpack_exports__EntryDependency = external_rspack_wasi_browser_js_.EntryD
57216
57142
  var __webpack_exports__ExternalModule = external_rspack_wasi_browser_js_.ExternalModule;
57217
57143
  var __webpack_exports__Module = external_rspack_wasi_browser_js_.Module;
57218
57144
  var __webpack_exports__NormalModule = external_rspack_wasi_browser_js_.NormalModule;
57219
- export { BannerPlugin, BrowserHttpImportPlugin, CircularDependencyRspackPlugin, Compilation, Compiler, ContextReplacementPlugin, CopyRspackPlugin, CssExtractRspackPlugin, DefinePlugin, DllPlugin, DllReferencePlugin, DynamicEntryPlugin, lib_EntryOptionPlugin as EntryOptionPlugin, EntryPlugin, EnvironmentPlugin, EvalDevToolModulePlugin, EvalSourceMapDevToolPlugin, ExternalsPlugin, HotModuleReplacementPlugin, HtmlRspackPlugin, IgnorePlugin, LightningCssMinimizerRspackPlugin, LoaderOptionsPlugin, LoaderTargetPlugin, ModuleFilenameHelpers_namespaceObject as ModuleFilenameHelpers, MultiCompiler, MultiStats, NoEmitOnErrorsPlugin, NormalModuleReplacementPlugin, ProgressPlugin, ProvidePlugin, RspackOptionsApply, RuntimeGlobals, RuntimeModule, RuntimePlugin, SourceMapDevToolPlugin, Stats, statsFactoryUtils_StatsErrorCode as StatsErrorCode, SwcJsMinimizerRspackPlugin, Template, validate_ValidationError as ValidationError, WarnCaseSensitiveModulesPlugin, exports_WebpackError as WebpackError, RspackOptionsApply as WebpackOptionsApply, builtinMemFs, exports_config as config, container, electron, exports_experiments as experiments, javascript, exports_library as library, exports_node as node, optimize, src_rspack as rspack, exports_rspackVersion as rspackVersion, sharing, sources, exports_util as util, exports_version as version, exports_wasm as wasm, web, webworker, __webpack_exports__AsyncDependenciesBlock as AsyncDependenciesBlock, __webpack_exports__ConcatenatedModule as ConcatenatedModule, __webpack_exports__ContextModule as ContextModule, __webpack_exports__Dependency as Dependency, __webpack_exports__EntryDependency as EntryDependency, __webpack_exports__ExternalModule as ExternalModule, __webpack_exports__Module as Module, __webpack_exports__NormalModule as NormalModule };
57145
+ export { BannerPlugin, CircularDependencyRspackPlugin, Compilation, Compiler, ContextReplacementPlugin, CopyRspackPlugin, CssExtractRspackPlugin, DefinePlugin, DllPlugin, DllReferencePlugin, DynamicEntryPlugin, lib_EntryOptionPlugin as EntryOptionPlugin, EntryPlugin, EnvironmentPlugin, EvalDevToolModulePlugin, EvalSourceMapDevToolPlugin, ExternalsPlugin, HotModuleReplacementPlugin, HtmlRspackPlugin, IgnorePlugin, LightningCssMinimizerRspackPlugin, LoaderOptionsPlugin, LoaderTargetPlugin, ModuleFilenameHelpers_namespaceObject as ModuleFilenameHelpers, MultiCompiler, MultiStats, NoEmitOnErrorsPlugin, NormalModuleReplacementPlugin, ProgressPlugin, ProvidePlugin, RspackOptionsApply, RuntimeGlobals, RuntimeModule, RuntimePlugin, SourceMapDevToolPlugin, Stats, statsFactoryUtils_StatsErrorCode as StatsErrorCode, SwcJsMinimizerRspackPlugin, Template, validate_ValidationError as ValidationError, WarnCaseSensitiveModulesPlugin, exports_WebpackError as WebpackError, RspackOptionsApply as WebpackOptionsApply, builtinMemFs, exports_config as config, container, electron, exports_experiments as experiments, javascript, exports_library as library, exports_node as node, optimize, src_rspack as rspack, exports_rspackVersion as rspackVersion, sharing, sources, exports_util as util, exports_version as version, exports_wasm as wasm, web, webworker, __webpack_exports__AsyncDependenciesBlock as AsyncDependenciesBlock, __webpack_exports__ConcatenatedModule as ConcatenatedModule, __webpack_exports__ContextModule as ContextModule, __webpack_exports__Dependency as Dependency, __webpack_exports__EntryDependency as EntryDependency, __webpack_exports__ExternalModule as ExternalModule, __webpack_exports__Module as Module, __webpack_exports__NormalModule as NormalModule };
@@ -2144,6 +2144,7 @@ export interface RawExternalItemFnResult {
2144
2144
  export interface RawExternalsPluginOptions {
2145
2145
  type: string
2146
2146
  externals: (string | RegExp | Record<string, string | boolean | string[] | Record<string, string[]>> | ((...args: any[]) => any))[]
2147
+ placeInInitial: boolean
2147
2148
  }
2148
2149
 
2149
2150
  export interface RawExternalsPresets {
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack-canary/browser",
3
- "version": "1.5.0-canary-1b8c8525-20250820061915",
3
+ "version": "1.5.0-canary-e5e47098-20250820070851",
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.",
@@ -31,7 +31,7 @@
31
31
  "dependencies": {
32
32
  "@napi-rs/wasm-runtime": "^1.0.1",
33
33
  "@rspack/lite-tapable": "1.0.1",
34
- "@swc/types": "0.1.23",
34
+ "@swc/types": "0.1.24",
35
35
  "@types/watchpack": "^2.4.4",
36
36
  "memfs": "4.36.0",
37
37
  "webpack-sources": "3.3.3"
@@ -1,26 +0,0 @@
1
- import type { Compiler } from ".";
2
- interface BrowserHttpImportPluginOptions {
3
- /**
4
- * ESM CDN domain
5
- * @default "https://esm.sh"
6
- */
7
- domain?: string | ((request: string, packageName: string) => string);
8
- /**
9
- * Specify ESM CDN URL for dependencies.
10
- */
11
- dependencyUrl?: Record<string, string | undefined> | ((packageName: string) => string | undefined);
12
- /**
13
- * Specify versions for dependencies.
14
- * Default to "latest" if not specified.
15
- */
16
- dependencyVersions?: Record<string, string | undefined>;
17
- }
18
- export declare class BrowserHttpImportPlugin {
19
- private options;
20
- constructor(options?: BrowserHttpImportPluginOptions);
21
- apply(compiler: Compiler): void;
22
- resolveWithUrlIssuer(request: string, issuer: URL): string;
23
- resolveNodeModule(request: string, packageName: string): string;
24
- isNodeModule(request: string): boolean;
25
- }
26
- export {};