@rspack/browser 1.5.2 → 1.5.4

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> & {
@@ -1,18 +1,37 @@
1
1
  import type { Compiler } from ".";
2
+ interface ResolvedRequest {
3
+ request: string;
4
+ issuer: string;
5
+ packageName: string;
6
+ }
7
+ interface ProcessedRequest extends ResolvedRequest {
8
+ url: URL;
9
+ }
2
10
  interface BrowserHttpImportPluginOptions {
3
11
  /**
4
12
  * ESM CDN domain
5
13
  */
6
- domain: string | ((request: string, packageName: string) => string);
14
+ domain: string | ((resolvedRequest: ResolvedRequest) => string);
7
15
  /**
8
16
  * Specify ESM CDN URL for dependencies.
17
+ * If a record is provided, it will be used to map package names to their CDN URLs.
18
+ *
19
+ * Once this function resolves a dependency, other options are ignored.
9
20
  */
10
- dependencyUrl?: Record<string, string | undefined> | ((packageName: string) => string | undefined);
21
+ dependencyUrl?: Record<string, string | undefined> | ((resolvedRequest: ResolvedRequest) => string | undefined);
11
22
  /**
12
23
  * Specify versions for dependencies.
13
24
  * Default to "latest" if not specified.
14
25
  */
15
26
  dependencyVersions?: Record<string, string | undefined>;
27
+ /**
28
+ * You can attach additional queries supported by the CDN to the `request.url`.
29
+ *
30
+ * For example, to specify the external dependencies under esm.sh, you can do:
31
+ *
32
+ * `request.url.searchParams.set("external", "react,react-dom")`
33
+ */
34
+ postprocess?: (request: ProcessedRequest) => void;
16
35
  }
17
36
  /**
18
37
  * Convert imports of dependencies in node modules to http imports from esm cdn.
@@ -21,8 +40,9 @@ export declare class BrowserHttpImportEsmPlugin {
21
40
  private options;
22
41
  constructor(options: BrowserHttpImportPluginOptions);
23
42
  apply(compiler: Compiler): void;
24
- resolveWithUrlIssuer(request: string, issuer: URL): string;
25
- resolveNodeModule(request: string, packageName: string): string;
26
- isNodeModule(request: string): boolean;
43
+ private resolveWithUrlIssuer;
44
+ private resolveNodeModule;
45
+ private parameterize;
46
+ private isNodeModule;
27
47
  }
28
48
  export {};
@@ -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";