@ohos-ports/rspack-core 2.2.9-beta.0 → 2.3.2-beta.0

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.
Files changed (52) hide show
  1. package/README.md +5 -6
  2. package/compiled/http-proxy-middleware/index.d.ts +10 -10
  3. package/compiled/http-proxy-middleware/package.json +1 -1
  4. package/compiled/watchpack/index.js +276 -49
  5. package/compiled/watchpack/package.json +1 -1
  6. package/compiled/watchpack/types/DirectoryWatcher.d.ts +24 -0
  7. package/compiled/watchpack/types/index.d.ts +1 -1
  8. package/compiled/watchpack/types/watchEventSource.d.ts +9 -0
  9. package/dist/BuildInfo.d.ts +7 -0
  10. package/dist/Compilation.d.ts +3 -1
  11. package/dist/Compiler.d.ts +5 -6
  12. package/dist/ConcatenatedModule.d.ts +5 -1
  13. package/dist/ContextModule.d.ts +3 -1
  14. package/dist/ExternalModule.d.ts +7 -6
  15. package/dist/FileSystemInfo.d.ts +1 -0
  16. package/dist/Module.d.ts +12 -8
  17. package/dist/ModuleGraphConnection.d.ts +9 -3
  18. package/dist/NativeWatchFileSystem.d.ts +19 -7
  19. package/dist/NormalModule.d.ts +14 -6
  20. package/dist/RuntimeTemplate.d.ts +1 -0
  21. package/dist/Stats.d.ts +1 -1
  22. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +3 -2
  23. package/dist/builtin-plugin/ImportedByDeferModulesPlugin.d.ts +9 -0
  24. package/dist/builtin-plugin/SubresourceIntegrityPlugin.d.ts +1 -0
  25. package/dist/builtin-plugin/index.d.ts +1 -0
  26. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +2 -2
  27. package/dist/config/normalization.d.ts +2 -2
  28. package/dist/config/target.d.ts +2 -0
  29. package/dist/config/types.d.ts +57 -35
  30. package/dist/cssExtractHmr.js +1 -1
  31. package/dist/exports.d.ts +3 -3
  32. package/dist/index.js +1140 -842
  33. package/dist/loader-runner/codeFilter.d.ts +9 -0
  34. package/dist/loader-runner/dependencies.d.ts +1 -1
  35. package/dist/loader-runner/index.d.ts +2 -1
  36. package/dist/loader-runner/service.d.ts +0 -4
  37. package/dist/loader-runner/worker.d.ts +4 -1
  38. package/dist/node/NodeWatchFileSystem.d.ts +7 -4
  39. package/dist/sources.d.ts +3 -0
  40. package/dist/stats/statsFactoryUtils.d.ts +7 -0
  41. package/dist/util/bindingHelpers.d.ts +2 -0
  42. package/dist/util/createModule.d.ts +3 -0
  43. package/dist/util/fs.d.ts +13 -7
  44. package/dist/util/resolveLayerExternals.d.ts +1 -0
  45. package/dist/util/source.d.ts +12 -3
  46. package/dist/util/symbols.d.ts +10 -0
  47. package/dist/util/watchTimeInfo.d.ts +5 -1
  48. package/dist/worker.js +323 -325
  49. package/hot/lazy-compilation-node.js +1 -1
  50. package/hot/lazy-compilation-web.js +1 -1
  51. package/package.json +3 -3
  52. package/dist/loader-runner/cache.d.ts +0 -27
@@ -0,0 +1,9 @@
1
+ export type LoaderCodeFilter = string | RegExp;
2
+ export interface CodeFilterTextCache {
3
+ initialized: boolean;
4
+ content?: unknown;
5
+ text?: string | null;
6
+ }
7
+ export declare function createCodeFilterTextCache(): CodeFilterTextCache;
8
+ export declare function invalidateCodeFilterTextCache(cache: CodeFilterTextCache): void;
9
+ export declare function matchesCodeFilter(filter: LoaderCodeFilter, content: unknown, cache: CodeFilterTextCache): boolean | undefined;
@@ -3,7 +3,7 @@ export type LoaderDependencies = JsLoaderContext['dependencies'];
3
3
  export declare class LoaderDependenciesState {
4
4
  #private;
5
5
  readonly existing: LoaderDependencies;
6
- constructor(existing: LoaderDependencies);
6
+ constructor(existing: LoaderDependencies, added?: LoaderDependencies, removed?: LoaderDependencies);
7
7
  get added(): LoaderDependencies;
8
8
  get removed(): LoaderDependencies;
9
9
  resetChanges(): void;
@@ -1,5 +1,6 @@
1
1
  import { type JsLoaderContext, type JsLoaderItem } from '@rspack/binding';
2
2
  import type { Compiler } from '../Compiler.js';
3
+ import { createCodeFilterTextCache } from './codeFilter.js';
3
4
  type LoaderObjectOptions = string | (object & {
4
5
  ident?: unknown;
5
6
  }) | null;
@@ -27,7 +28,7 @@ export declare class LoaderObject {
27
28
  get normalExecuted(): boolean;
28
29
  set normalExecuted(value: boolean);
29
30
  set noPitch(value: boolean);
30
- shouldYield(): boolean;
31
+ shouldSkipNormal(content: unknown, cache: ReturnType<typeof createCodeFilterTextCache>): boolean;
31
32
  static __from_binding(loaderItem: JsLoaderItem, compiler: Compiler): LoaderObject;
32
33
  static __to_binding(loader: LoaderObject): JsLoaderItem;
33
34
  }
@@ -43,8 +43,6 @@ export declare enum RequestType {
43
43
  GetContextDependencies = "GetContextDependencies",
44
44
  GetMissingDependencies = "GetMissingDependencies",
45
45
  ClearDependencies = "ClearDependencies",
46
- BeginDependencyChanges = "BeginDependencyChanges",
47
- MergeDependencyChanges = "MergeDependencyChanges",
48
46
  Resolve = "Resolve",
49
47
  GetResolve = "GetResolve",
50
48
  GetLogger = "GetLogger",
@@ -56,8 +54,6 @@ export declare enum RequestType {
56
54
  ImportModule = "ImportModule",
57
55
  UpdateLoaderObjects = "UpdateLoaderObjects",
58
56
  UpdateBuildInfo = "UpdateBuildInfo",
59
- LoaderCacheGet = "LoaderCacheGet",
60
- LoaderCacheStore = "LoaderCacheStore",
61
57
  CompilationGetPath = "CompilationGetPath",
62
58
  CompilationGetPathWithInfo = "CompilationGetPathWithInfo",
63
59
  CompilationGetAssetPath = "CompilationGetAssetPath",
@@ -2,7 +2,10 @@ import { type MessagePort } from 'node:worker_threads';
2
2
  import { JsLoaderState } from '@rspack/binding';
3
3
  import type { LoaderContext } from '../config/index.js';
4
4
  interface WorkerOptions {
5
- loaderContext: LoaderContext;
5
+ loaderContext: LoaderContext & {
6
+ loaderChainStart: number;
7
+ loaderChainEnd: number;
8
+ };
6
9
  loaderState: JsLoaderState;
7
10
  args: any[];
8
11
  workerData?: {
@@ -8,7 +8,7 @@
8
8
  * https://github.com/webpack/webpack/blob/main/LICENSE
9
9
  */
10
10
  import type Watchpack from '../../compiled/watchpack/index.js';
11
- import type { FileSystemInfoEntry, InputFileSystem, Watcher, WatchFileSystem } from '../util/fs.js';
11
+ import type { InputFileSystem, TimeInfoEntries, Watcher, WatchFileSystem } from '../util/fs.js';
12
12
  type WatchpackInstance = InstanceType<typeof Watchpack>;
13
13
  export default class NodeWatchFileSystem implements WatchFileSystem {
14
14
  #private;
@@ -16,11 +16,14 @@ export default class NodeWatchFileSystem implements WatchFileSystem {
16
16
  watcherOptions: Watchpack.WatchOptions;
17
17
  watcher?: WatchpackInstance;
18
18
  constructor(inputFileSystem: InputFileSystem);
19
- watch(files: Iterable<string>, directories: Iterable<string>, missing: Iterable<string>, 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;
20
- on(event: 'change', listener: (filename: string, mtime: number) => void): this;
19
+ watch(files: Iterable<string>, directories: Iterable<string>, missing: Iterable<string>, startTime: number, options: Watchpack.WatchOptions, callback: (error: Error | null, fileTimeInfoEntries: TimeInfoEntries, contextTimeInfoEntries: TimeInfoEntries, changedFiles: Set<string>, removedFiles: Set<string>) => void, callbackUndelayed: (fileName: string, changeTime: number) => void): Watcher;
20
+ getTimes(): Record<string, number | null>;
21
+ getTimeInfoEntries(): TimeInfoEntries;
22
+ collectTimeInfoEntries(fileTimestamps: TimeInfoEntries, directoryTimestamps: TimeInfoEntries): void;
23
+ on(event: 'change', listener: (filename: string, mtime: number | null) => void): this;
21
24
  on(event: 'remove', listener: (filename: string) => void): this;
22
25
  on(event: 'aggregated', listener: (changes: Set<string>, removals: Set<string>) => void): this;
23
- once(event: 'change', listener: (filename: string, mtime: number) => void): this;
26
+ once(event: 'change', listener: (filename: string, mtime: number | null) => void): this;
24
27
  once(event: 'remove', listener: (filename: string) => void): this;
25
28
  once(event: 'aggregated', listener: (changes: Set<string>, removals: Set<string>) => void): this;
26
29
  emit(event: 'change', filename: string, mtime: number): boolean;
@@ -0,0 +1,3 @@
1
+ export { CachedSource, CompatSource, OriginalSource, PrefixSource, RawSource, SizeOnlySource, Source, SourceMapSource, util, } from '../compiled/webpack-sources/index.js';
2
+ export type * from '../compiled/webpack-sources/index.js';
3
+ export { RspackConcatSource as ConcatSource, RspackReplaceSource as ReplaceSource, } from './util/source.js';
@@ -229,6 +229,12 @@ export type KnownStatsChunkOrigin = {
229
229
  moduleId?: string | number | null;
230
230
  };
231
231
  export type StatsChunkOrigin = KnownStatsChunkOrigin & Record<string, any>;
232
+ export type StatsCacheInfo = {
233
+ hits: number;
234
+ misses: number;
235
+ reused: number;
236
+ stores: number;
237
+ };
232
238
  export type KnownStatsCompilation = {
233
239
  /**
234
240
  * webpack version.
@@ -239,6 +245,7 @@ export type KnownStatsCompilation = {
239
245
  rspackVersion?: string;
240
246
  name?: string;
241
247
  hash?: string;
248
+ cacheInfo?: Record<string, StatsCacheInfo>;
242
249
  env?: any;
243
250
  time?: number;
244
251
  builtAt?: number;
@@ -1,6 +1,8 @@
1
+ import { createModule } from './createModule.js';
1
2
  declare function applyIndexedArrayUpdates<T>(source: readonly T[], target: T[], commands: Uint32Array): void;
2
3
  declare function swapRemoveArrayElements<T>(array: T[], removedIndices: Uint32Array): void;
3
4
  export declare const bindingHelpers: {
5
+ createModule: typeof createModule;
4
6
  applyIndexedArrayUpdates: typeof applyIndexedArrayUpdates;
5
7
  swapRemoveArrayElements: typeof swapRemoveArrayElements;
6
8
  };
@@ -0,0 +1,3 @@
1
+ import { ModuleKind } from '@rspack/binding';
2
+ import { Module } from '../Module.js';
3
+ export declare function createModule(kind: ModuleKind): Module;
package/dist/util/fs.d.ts CHANGED
@@ -9,20 +9,22 @@
9
9
  */
10
10
  import type { Abortable } from 'node:events';
11
11
  import type { WatchOptions } from '../config/index.js';
12
+ export type ExistenceOnlyTimeEntry = Record<string, never>;
13
+ export type TimeInfoEntries = Map<string, FileSystemInfoEntry | ExistenceOnlyTimeEntry | 'ignore' | null>;
12
14
  export interface Watcher {
13
15
  close(): void;
14
16
  pause(): void;
15
17
  getAggregatedChanges?(): Set<string>;
16
18
  getAggregatedRemovals?(): Set<string>;
17
- getFileTimeInfoEntries?(): Map<string, FileSystemInfoEntry | 'ignore'>;
18
- getContextTimeInfoEntries?(): Map<string, FileSystemInfoEntry | 'ignore'>;
19
+ getFileTimeInfoEntries?(): TimeInfoEntries;
20
+ getContextTimeInfoEntries?(): TimeInfoEntries;
19
21
  getInfo(): WatcherInfo;
20
22
  }
21
23
  export interface WatcherInfo {
22
24
  changes: Set<string>;
23
25
  removals: Set<string>;
24
- fileTimeInfoEntries: Map<string, FileSystemInfoEntry | 'ignore'>;
25
- contextTimeInfoEntries: Map<string, FileSystemInfoEntry | 'ignore'>;
26
+ fileTimeInfoEntries: TimeInfoEntries;
27
+ contextTimeInfoEntries: TimeInfoEntries;
26
28
  }
27
29
  export type IStatsBase<T> = {
28
30
  isFile: () => boolean;
@@ -351,6 +353,7 @@ export declare const mkdirp: (fs: OutputFileSystem, p: string, callback: (error?
351
353
  export interface FileSystemInfoEntry {
352
354
  safeTime: number;
353
355
  timestamp?: number;
356
+ accuracy?: number;
354
357
  }
355
358
  export interface WatchFileSystem {
356
359
  watch(files: Iterable<string> & {
@@ -362,11 +365,14 @@ export interface WatchFileSystem {
362
365
  }, missing: Iterable<string> & {
363
366
  added?: Iterable<String>;
364
367
  removed?: Iterable<String>;
365
- }, startTime: number, options: 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;
366
- on?(event: 'change', listener: (filename: string, mtime: number) => void): this;
368
+ }, startTime: number, options: WatchOptions, callback: (error: Error | null, fileTimeInfoEntries: TimeInfoEntries, contextTimeInfoEntries: TimeInfoEntries, changedFiles: Set<string>, removedFiles: Set<string>) => void, callbackUndelayed: (fileName: string, changeTime: number) => void): Watcher;
369
+ getTimes?(): Record<string, number | null>;
370
+ getTimeInfoEntries?(): TimeInfoEntries;
371
+ collectTimeInfoEntries?(fileTimestamps: TimeInfoEntries, directoryTimestamps: TimeInfoEntries): void;
372
+ on?(event: 'change', listener: (filename: string, mtime: number | null) => void): this;
367
373
  on?(event: 'remove', listener: (filename: string) => void): this;
368
374
  on?(event: 'aggregated', listener: (changes: Set<string>, removals: Set<string>) => void): this;
369
- once?(event: 'change', listener: (filename: string, mtime: number) => void): this;
375
+ once?(event: 'change', listener: (filename: string, mtime: number | null) => void): this;
370
376
  once?(event: 'remove', listener: (filename: string) => void): this;
371
377
  once?(event: 'aggregated', listener: (changes: Set<string>, removals: Set<string>) => void): this;
372
378
  emit?(event: 'change', filename: string, mtime: number): boolean;
@@ -0,0 +1 @@
1
+ export declare const resolveLayerExternals: <T>(item: T, layer: string | null) => T;
@@ -1,6 +1,15 @@
1
- import type { JsSource, JsSourceWithLazyMap } from '@rspack/binding';
1
+ import type { JsNativeSource, JsSource, JsSourceFromJs, JsSourceWithLazyMap } from '@rspack/binding';
2
+ import * as webpackSources from '../../compiled/webpack-sources/index.js';
2
3
  import { type Source } from '../../compiled/webpack-sources/index.js';
4
+ declare const toBindingSource: unique symbol;
5
+ export declare class RspackConcatSource extends webpackSources.ConcatSource {
6
+ [toBindingSource](): JsSourceFromJs | null;
7
+ }
8
+ export declare class RspackReplaceSource extends webpackSources.ReplaceSource {
9
+ [toBindingSource](): JsSourceFromJs | null;
10
+ }
3
11
  export declare class SourceAdapter {
4
- static fromBinding(cache: JsSource | JsSourceWithLazyMap): Source;
5
- static toBinding(source: Source): JsSource;
12
+ static fromBinding(cache: JsSource | JsSourceWithLazyMap, nativeSource?: JsNativeSource | null): Source;
13
+ static toBinding(source: Source): JsSourceFromJs;
6
14
  }
15
+ export {};
@@ -0,0 +1,10 @@
1
+ export declare const MODULE_BUILD_INFO_SYMBOL: unique symbol;
2
+ export declare const COMPILATION_HOOKS_MAP_SYMBOL: unique symbol;
3
+ export declare const BUILD_INFO_ASSETS_SYMBOL: unique symbol;
4
+ export declare const BUILD_INFO_FILE_DEPENDENCIES_SYMBOL: unique symbol;
5
+ export declare const BUILD_INFO_CONTEXT_DEPENDENCIES_SYMBOL: unique symbol;
6
+ export declare const BUILD_INFO_MISSING_DEPENDENCIES_SYMBOL: unique symbol;
7
+ export declare const BUILD_INFO_BUILD_DEPENDENCIES_SYMBOL: unique symbol;
8
+ export declare const COMMIT_CUSTOM_FIELDS_SYMBOL: unique symbol;
9
+ export declare const CIRCULAR_CONNECTION_SYMBOL: unique symbol;
10
+ export declare const TRANSITIVE_ONLY_SYMBOL: unique symbol;
@@ -1,7 +1,11 @@
1
- import type { WatchFileSystem } from './fs.js';
1
+ import type { Watcher, WatchFileSystem, WatcherInfo } from './fs.js';
2
2
  type WatchCallback = Parameters<WatchFileSystem['watch']>[5];
3
3
  type WatchCallbackArgs = Parameters<WatchCallback>;
4
4
  type OptionalTimeInfoWatchCallback = (error: WatchCallbackArgs[0], fileTimeInfoEntries: WatchCallbackArgs[1] | undefined, contextTimeInfoEntries: WatchCallbackArgs[2] | undefined, changedFiles: WatchCallbackArgs[3], removedFiles: WatchCallbackArgs[4]) => void;
5
5
  export declare function markInternalCallback(callback: OptionalTimeInfoWatchCallback): OptionalTimeInfoWatchCallback;
6
+ export declare const consumeWatcherInfo: unique symbol;
7
+ export type ConsumableWatcher = Watcher & {
8
+ [consumeWatcherInfo]?: () => WatcherInfo;
9
+ };
6
10
  export declare function isInternalCallback(callback: WatchCallback): callback is OptionalTimeInfoWatchCallback;
7
11
  export {};