@rspack-canary/browser 1.5.3-canary-21e07ae4-20250903090509 → 1.5.4-canary-4bf6f74a-20250909153137

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.
@@ -13,7 +13,7 @@ export default class NativeWatchFileSystem implements WatchFileSystem {
13
13
  }, missing: Iterable<string> & {
14
14
  added?: Iterable<string>;
15
15
  removed?: Iterable<string>;
16
- }, _startTime: number, options: Watchpack.WatchOptions, callback: (error: Error | null, fileTimeInfoEntries: Map<string, FileSystemInfoEntry | "ignore">, contextTimeInfoEntries: Map<string, FileSystemInfoEntry | "ignore">, changedFiles: Set<string>, removedFiles: Set<string>) => void, callbackUndelayed: (fileName: string, changeTime: number) => void): Watcher;
16
+ }, startTime: number, options: Watchpack.WatchOptions, callback: (error: Error | null, fileTimeInfoEntries: Map<string, FileSystemInfoEntry | "ignore">, contextTimeInfoEntries: Map<string, FileSystemInfoEntry | "ignore">, changedFiles: Set<string>, removedFiles: Set<string>) => void, callbackUndelayed: (fileName: string, changeTime: number) => void): Watcher;
17
17
  getNativeWatcher(options: Watchpack.WatchOptions): binding.NativeWatcher;
18
18
  triggerEvent(kind: "change" | "remove" | "create", path: string): void;
19
19
  formatWatchDependencies(dependencies: Iterable<string> & {
@@ -4,6 +4,9 @@ interface ResolvedRequest {
4
4
  issuer: string;
5
5
  packageName: string;
6
6
  }
7
+ interface ProcessedRequest extends ResolvedRequest {
8
+ url: URL;
9
+ }
7
10
  interface BrowserHttpImportPluginOptions {
8
11
  /**
9
12
  * ESM CDN domain
@@ -22,37 +25,13 @@ interface BrowserHttpImportPluginOptions {
22
25
  */
23
26
  dependencyVersions?: Record<string, string | undefined>;
24
27
  /**
25
- * Specify whether to bundle the dependencies. This option will attach `?bundle=<value>` query to the final URL.
28
+ * You can attach additional queries supported by the CDN to the `request.url`.
26
29
  *
27
- * You should make sure your cdn domain supports this behavior.
28
- * @see https://esm.sh/#bundling-strategy
29
- */
30
- bundle?: (resolvedRequest: ResolvedRequest) => boolean;
31
- /**
32
- * Specify which exported members to include from the dependency if you want to import only a specific set of members.
33
- * This option will attach `?exports=<value>` query to the final URL.
34
- *
35
- * You should make sure your cdn domain supports this behavior.
36
- * @see https://esm.sh/#tree-shaking
37
- */
38
- exports?: (resolvedRequest: ResolvedRequest) => string[];
39
- /**
40
- * Specify which packages to be bundled under development mode.
41
- * This option will attach `?dev` query to the final URL if true.
42
- *
43
- * You should make sure your cdn domain supports this behavior.
44
- * @see https://esm.sh/#development-build
45
- */
46
- dev?: string[] | ((resolvedRequest: ResolvedRequest) => boolean);
47
- /**
48
- * Specify external dependencies.
49
- * This is useful if you don't want to include multiple instances of a package introduced by different dependencies.
50
- * This option will attach `?external=<value>` query to the final URL.
30
+ * For example, to specify the external dependencies under esm.sh, you can do:
51
31
  *
52
- * You should make sure your cdn domain supports this behavior.
53
- * @see https://esm.sh/#using-import-maps
32
+ * `request.url.searchParams.set("external", "react,react-dom")`
54
33
  */
55
- externals?: string[];
34
+ postprocess?: (request: ProcessedRequest) => void;
56
35
  }
57
36
  /**
58
37
  * Convert imports of dependencies in node modules to http imports from esm cdn.
@@ -15,19 +15,50 @@ export interface ComposeJsUseOptions {
15
15
  experiments: RawOptions["experiments"];
16
16
  compiler: Compiler;
17
17
  }
18
- export interface SourceMap {
18
+ export interface RawSourceMap {
19
+ /**
20
+ * The version of the source map format, always 3
21
+ */
19
22
  version: number;
23
+ /**
24
+ * A list of original sources used by the mappings field
25
+ */
20
26
  sources: string[];
27
+ /**
28
+ * A string with the encoded mapping data
29
+ */
21
30
  mappings: string;
22
- file?: string;
31
+ /**
32
+ * The filename of the generated code that this source map is associated with
33
+ */
34
+ file: string;
35
+ /**
36
+ * An optional source root string, used for relocating source files on a server
37
+ * or removing repeated values in the sources entry.
38
+ */
23
39
  sourceRoot?: string;
40
+ /**
41
+ * An array containing the actual content of the original source files
42
+ */
24
43
  sourcesContent?: string[];
25
- names?: string[];
44
+ /**
45
+ * A list of symbol names which may be used by the mappings field.
46
+ */
47
+ names: string[];
48
+ /**
49
+ * A unique identifier for debugging purposes
50
+ */
51
+ debugId?: string;
52
+ /**
53
+ * An array of indices into the sources array, indicating which sources
54
+ * should be ignored by debuggers
55
+ */
56
+ ignoreList?: number[];
26
57
  }
27
58
  export interface AdditionalData {
28
59
  [index: string]: any;
29
60
  }
30
- export type LoaderContextCallback = (err?: Error | null, content?: string | Buffer, sourceMap?: string | SourceMap, additionalData?: AdditionalData) => void;
61
+ export type LoaderContextCallback = (err?: Error | null, content?: string | Buffer, sourceMap?: string | RawSourceMap, additionalData?: AdditionalData) => void;
31
62
  export type ErrorWithDetails = Error & {
32
63
  details?: string;
33
64
  };
@@ -322,7 +353,7 @@ export interface LoaderContext<OptionsType = {}> {
322
353
  */
323
354
  __internal__setParseMeta: (key: string, value: string) => void;
324
355
  }
325
- export type LoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> = (this: LoaderContext<OptionsType> & ContextAdditions, content: string, sourceMap?: string | SourceMap, additionalData?: AdditionalData) => string | void | Buffer | Promise<string | Buffer | void>;
356
+ export type LoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> = (this: LoaderContext<OptionsType> & ContextAdditions, content: string, sourceMap?: string | RawSourceMap, additionalData?: AdditionalData) => string | void | Buffer | Promise<string | Buffer | void>;
326
357
  export type PitchLoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> = (this: LoaderContext<OptionsType> & ContextAdditions, remainingRequest: string, previousRequest: string, data: object) => string | void | Buffer | Promise<string | Buffer | void>;
327
358
  /**
328
359
  * Defines a loader for Rspack.
@@ -1,4 +1,5 @@
1
1
  export * from "./adapter";
2
+ export type { RawSourceMap } from "./adapterRuleUse";
2
3
  export * from "./defaults";
3
4
  export * from "./normalization";
4
5
  export type * from "./types";
package/dist/index.mjs CHANGED
@@ -46960,11 +46960,16 @@ const applyRspackOptionsDefaults = (options)=>{
46960
46960
  D(options, "lazyCompilation", false);
46961
46961
  D(options, "bail", false);
46962
46962
  defaults_F(options, "cache", ()=>development);
46963
+ if (false === options.cache) options.experiments.cache = false;
46963
46964
  applyExperimentsDefaults(options.experiments, {
46964
46965
  production,
46965
46966
  development
46966
46967
  });
46967
- if (false === options.cache) options.experiments.cache = false;
46968
+ applyOptimizationDefaults(options.optimization, {
46969
+ production,
46970
+ development,
46971
+ css: options.experiments.css
46972
+ });
46968
46973
  applySnapshotDefaults(options.snapshot, {
46969
46974
  production
46970
46975
  });
@@ -46974,6 +46979,7 @@ const applyRspackOptionsDefaults = (options)=>{
46974
46979
  targetProperties,
46975
46980
  mode: options.mode,
46976
46981
  uniqueName: options.output.uniqueName,
46982
+ usedExports: !!options.optimization.usedExports,
46977
46983
  inlineConst: options.experiments.inlineConst
46978
46984
  });
46979
46985
  applyOutputDefaults(options.output, {
@@ -47003,11 +47009,6 @@ const applyRspackOptionsDefaults = (options)=>{
47003
47009
  applyPerformanceDefaults(options.performance, {
47004
47010
  production
47005
47011
  });
47006
- applyOptimizationDefaults(options.optimization, {
47007
- production,
47008
- development,
47009
- css: options.experiments.css
47010
- });
47011
47012
  options.resolve = cleverMerge(getResolveDefaults({
47012
47013
  context: options.context,
47013
47014
  targetProperties,
@@ -47072,14 +47073,14 @@ const applybundlerInfoDefaults = (rspackFuture, library)=>{
47072
47073
  if ("object" == typeof rspackFuture) {
47073
47074
  D(rspackFuture, "bundlerInfo", {});
47074
47075
  if ("object" == typeof rspackFuture.bundlerInfo) {
47075
- D(rspackFuture.bundlerInfo, "version", "1.5.3-canary-21e07ae4-20250903090509");
47076
+ D(rspackFuture.bundlerInfo, "version", "1.5.4-canary-4bf6f74a-20250909153137");
47076
47077
  D(rspackFuture.bundlerInfo, "bundler", "rspack");
47077
47078
  D(rspackFuture.bundlerInfo, "force", !library);
47078
47079
  }
47079
47080
  }
47080
47081
  };
47081
47082
  const applySnapshotDefaults = (_snapshot, _env)=>{};
47082
- const applyJavascriptParserOptionsDefaults = (parserOptions, { inlineConst })=>{
47083
+ const applyJavascriptParserOptionsDefaults = (parserOptions, { usedExports, inlineConst })=>{
47083
47084
  D(parserOptions, "dynamicImportMode", "lazy");
47084
47085
  D(parserOptions, "dynamicImportPrefetch", false);
47085
47086
  D(parserOptions, "dynamicImportPreload", false);
@@ -47097,13 +47098,13 @@ const applyJavascriptParserOptionsDefaults = (parserOptions, { inlineConst })=>{
47097
47098
  "..."
47098
47099
  ]);
47099
47100
  D(parserOptions, "importMeta", true);
47100
- D(parserOptions, "inlineConst", inlineConst);
47101
+ D(parserOptions, "inlineConst", usedExports && inlineConst);
47101
47102
  D(parserOptions, "typeReexportsPresence", "no-tolerant");
47102
47103
  };
47103
47104
  const applyJsonGeneratorOptionsDefaults = (generatorOptions)=>{
47104
47105
  D(generatorOptions, "JSONParse", true);
47105
47106
  };
47106
- const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties, mode, uniqueName, inlineConst })=>{
47107
+ const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties, mode, uniqueName, usedExports, inlineConst })=>{
47107
47108
  assertNotNill(module.parser);
47108
47109
  assertNotNill(module.generator);
47109
47110
  defaults_F(module.parser, ASSET_MODULE_TYPE, ()=>({}));
@@ -47113,6 +47114,7 @@ const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties,
47113
47114
  defaults_F(module.parser, "javascript", ()=>({}));
47114
47115
  assertNotNill(module.parser.javascript);
47115
47116
  applyJavascriptParserOptionsDefaults(module.parser.javascript, {
47117
+ usedExports,
47116
47118
  inlineConst
47117
47119
  });
47118
47120
  defaults_F(module.parser, JSON_MODULE_TYPE, ()=>({}));
@@ -49943,14 +49945,14 @@ const toJsWatcherIgnored = (ignored)=>{
49943
49945
  };
49944
49946
  var NativeWatchFileSystem_inner = /*#__PURE__*/ new WeakMap(), _isFirstWatch = /*#__PURE__*/ new WeakMap(), _inputFileSystem = /*#__PURE__*/ new WeakMap();
49945
49947
  class NativeWatchFileSystem {
49946
- watch(files, directories, missing, _startTime, options, callback, callbackUndelayed) {
49948
+ watch(files, directories, missing, startTime, options, callback, callbackUndelayed) {
49947
49949
  if ((!files.added || "function" != typeof files.added[Symbol.iterator]) && (!files.removed || "function" != typeof files.removed[Symbol.iterator])) throw new Error("Invalid arguments: 'files'");
49948
49950
  if ((!directories.added || "function" != typeof directories.added[Symbol.iterator]) && (!directories.removed || "function" != typeof directories.removed[Symbol.iterator])) throw new Error("Invalid arguments: 'directories'");
49949
49951
  if ("function" != typeof callback) throw new Error("Invalid arguments: 'callback'");
49950
49952
  if ("object" != typeof options) throw new Error("Invalid arguments: 'options'");
49951
49953
  if ("function" != typeof callbackUndelayed && callbackUndelayed) throw new Error("Invalid arguments: 'callbackUndelayed'");
49952
49954
  const nativeWatcher = this.getNativeWatcher(options);
49953
- nativeWatcher.watch(this.formatWatchDependencies(files), this.formatWatchDependencies(directories), this.formatWatchDependencies(missing), (err, result)=>{
49955
+ nativeWatcher.watch(this.formatWatchDependencies(files), this.formatWatchDependencies(directories), this.formatWatchDependencies(missing), BigInt(startTime), (err, result)=>{
49954
49956
  var _class_private_field_get1;
49955
49957
  if (err) return void callback(err, new Map(), new Map(), new Set(), new Set());
49956
49958
  nativeWatcher.pause();
@@ -51167,7 +51169,7 @@ class MultiStats {
51167
51169
  return obj;
51168
51170
  });
51169
51171
  if (childOptions.version) {
51170
- obj.rspackVersion = "1.5.3-canary-21e07ae4-20250903090509";
51172
+ obj.rspackVersion = "1.5.4-canary-4bf6f74a-20250909153137";
51171
51173
  obj.version = "5.75.0";
51172
51174
  }
51173
51175
  if (childOptions.hash) obj.hash = obj.children.map((j)=>j.hash).join("");
@@ -52477,7 +52479,7 @@ const SIMPLE_EXTRACTORS = {
52477
52479
  },
52478
52480
  version: (object)=>{
52479
52481
  object.version = "5.75.0";
52480
- object.rspackVersion = "1.5.3-canary-21e07ae4-20250903090509";
52482
+ object.rspackVersion = "1.5.4-canary-4bf6f74a-20250909153137";
52481
52483
  },
52482
52484
  env: (object, _compilation, _context, { _env })=>{
52483
52485
  object.env = _env;
@@ -56926,7 +56928,7 @@ function transformSync(source, options) {
56926
56928
  const _options = JSON.stringify(options || {});
56927
56929
  return external_rspack_wasi_browser_js_["default"].transformSync(source, _options);
56928
56930
  }
56929
- const exports_rspackVersion = "1.5.3-canary-21e07ae4-20250903090509";
56931
+ const exports_rspackVersion = "1.5.4-canary-4bf6f74a-20250909153137";
56930
56932
  const exports_version = "5.75.0";
56931
56933
  const exports_WebpackError = Error;
56932
56934
  const sources = __webpack_require__("../../node_modules/.pnpm/webpack-sources@3.3.3_patch_hash=b2a26650f08a2359d0a3cd81fa6fa272aa7441a28dd7e601792da5ed5d2b4aee/node_modules/webpack-sources/lib/index.js");
@@ -57155,23 +57157,12 @@ class BrowserHttpImportEsmPlugin {
57155
57157
  return `${domain}/${versionedRequest}`;
57156
57158
  }
57157
57159
  parameterize(requestUrl, resolvedRequest) {
57160
+ if (!this.options.postprocess) return requestUrl;
57158
57161
  const url = new URL(requestUrl);
57159
- if (this.options.bundle) {
57160
- const bundle = this.options.bundle(resolvedRequest);
57161
- url.searchParams.set("bundle", bundle.toString());
57162
- }
57163
- if (this.options.exports) {
57164
- const exports = this.options.exports(resolvedRequest);
57165
- if (exports.length > 0) url.searchParams.set("exports", exports.join(","));
57166
- }
57167
- if (this.options.dev) if ("function" == typeof this.options.dev) {
57168
- const dev = this.options.dev(resolvedRequest);
57169
- if (dev) url.searchParams.set("dev", "");
57170
- } else {
57171
- const dev = this.options.dev.includes(resolvedRequest.packageName);
57172
- if (dev) url.searchParams.set("dev", "");
57173
- }
57174
- if (this.options.externals && this.options.externals.length > 0) url.searchParams.set("external", this.options.externals.join(","));
57162
+ this.options.postprocess({
57163
+ url,
57164
+ ...resolvedRequest
57165
+ });
57175
57166
  return url.toString();
57176
57167
  }
57177
57168
  isNodeModule(request) {
@@ -443,7 +443,7 @@ export declare class ModuleGraphConnection {
443
443
 
444
444
  export declare class NativeWatcher {
445
445
  constructor(options: NativeWatcherOptions)
446
- watch(files: [Array<string>, Array<string>], directories: [Array<string>, Array<string>], missing: [Array<string>, Array<string>], callback: (err: Error | null, result: NativeWatchResult) => void, callbackUndelayed: (path: string) => void): void
446
+ watch(files: [Array<string>, Array<string>], directories: [Array<string>, Array<string>], missing: [Array<string>, Array<string>], startTime: bigint, callback: (err: Error | null, result: NativeWatchResult) => void, callbackUndelayed: (path: string) => void): void
447
447
  triggerEvent(kind: 'change' | 'remove' | 'create', path: string): void
448
448
  /**
449
449
  * # Safety
@@ -2111,6 +2111,7 @@ parallelCodeSplitting: boolean
2111
2111
  rspackFuture?: RawRspackFuture
2112
2112
  cache: boolean | { type: "persistent" } & RawExperimentCacheOptionsPersistent | { type: "memory" }
2113
2113
  useInputFileSystem?: false | Array<RegExp>
2114
+ css?: boolean
2114
2115
  inlineConst: boolean
2115
2116
  inlineEnum: boolean
2116
2117
  typeReexportsPresence: boolean
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack-canary/browser",
3
- "version": "1.5.3-canary-21e07ae4-20250903090509",
3
+ "version": "1.5.4-canary-4bf6f74a-20250909153137",
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.",
@@ -33,7 +33,7 @@
33
33
  "@rspack/lite-tapable": "1.0.1",
34
34
  "@swc/types": "0.1.24",
35
35
  "@types/watchpack": "^2.4.4",
36
- "memfs": "4.36.0",
36
+ "memfs": "4.38.2",
37
37
  "webpack-sources": "3.3.3"
38
38
  },
39
39
  "peerDependencies": {