From 6f398720657eed95e679177903a26f642e8e6ff9 Mon Sep 17 00:00:00 2001 From: Cong-Cong Date: Thu, 12 Dec 2024 14:12:29 +0800 Subject: [PATCH] fix --- crates/node_binding/binding.d.ts | 1 + packages/rspack/etc/core.api.md | 92 ++++++++++++++++--------------- packages/rspack/src/ChunkGraph.ts | 4 ++ 3 files changed, 52 insertions(+), 45 deletions(-) diff --git a/crates/node_binding/binding.d.ts b/crates/node_binding/binding.d.ts index 858babfee276..fd03e22580e7 100644 --- a/crates/node_binding/binding.d.ts +++ b/crates/node_binding/binding.d.ts @@ -75,6 +75,7 @@ export declare class JsChunkGraph { getChunkEntryDependentChunksIterable(chunk: JsChunk): JsChunk[] getChunkModulesIterableBySourceType(chunk: JsChunk, sourceType: string): JsModule[] getModuleChunks(module: JsModule): JsChunk[] + getModuleId(jsModule: JsModule): string | null } export declare class JsChunkGroup { diff --git a/packages/rspack/etc/core.api.md b/packages/rspack/etc/core.api.md index 12a3cd6e2d81..a647a144accb 100644 --- a/packages/rspack/etc/core.api.md +++ b/packages/rspack/etc/core.api.md @@ -280,27 +280,27 @@ interface BaseModuleConfig { // @public (undocumented) interface BaseResolveRequest { - // (undocumented) + // (undocumented) __innerRequest?: string; - // (undocumented) + // (undocumented) __innerRequest_relativePath?: string; - // (undocumented) + // (undocumented) __innerRequest_request?: string; - // (undocumented) + // (undocumented) context?: object; - // (undocumented) + // (undocumented) descriptionFileData?: JsonObject; - // (undocumented) + // (undocumented) descriptionFilePath?: string; - // (undocumented) + // (undocumented) descriptionFileRoot?: string; - // (undocumented) + // (undocumented) fullySpecified?: boolean; - // (undocumented) + // (undocumented) ignoreSymlinks?: boolean; - // (undocumented) + // (undocumented) path: string | false; - // (undocumented) + // (undocumented) relativePath?: string; } @@ -491,6 +491,8 @@ class ChunkGraph { getModuleChunks(module: Module): Chunk[]; // (undocumented) getModuleChunksIterable(module: Module): Iterable; + // (undocumented) + getModuleId(module: Module): string | null; } // @public (undocumented) @@ -2181,11 +2183,11 @@ type GroupOptions = { // @public (undocumented) class Hash { - constructor(); + constructor(); - digest(encoding?: string): string | Buffer; + digest(encoding?: string): string | Buffer; - update(data: string | Buffer, inputEncoding?: string): Hash; + update(data: string | Buffer, inputEncoding?: string): Hash; } // @public (undocumented) @@ -2678,14 +2680,14 @@ type JsonArray = JsonValue_2[]; // @public (undocumented) type JsonObject = { [index: string]: JsonValue } & { - [index: string]: - | undefined - | null - | string - | number - | boolean - | JsonObject - | JsonValue[]; + [index: string]: + | undefined + | null + | string + | number + | boolean + | JsonObject + | JsonValue[]; }; // @public (undocumented) @@ -4343,19 +4345,19 @@ interface ParseContext { // @public (undocumented) interface ParsedIdentifier { - // (undocumented) + // (undocumented) directory: boolean; - // (undocumented) + // (undocumented) file: boolean; - // (undocumented) + // (undocumented) fragment: string; - // (undocumented) + // (undocumented) internal: boolean; - // (undocumented) + // (undocumented) module: boolean; - // (undocumented) + // (undocumented) query: string; - // (undocumented) + // (undocumented) request: string; } @@ -4625,13 +4627,13 @@ type RawCreateParams = { // @public (undocumented) type RawSourceMap = { - version: number; - sources: string[]; - names: string[]; - sourceRoot?: string; - sourcesContent?: string[]; - mappings: string; - file: string; + version: number; + sources: string[]; + names: string[]; + sourceRoot?: string; + sourcesContent?: string[]; + mappings: string; + file: string; }; // @public (undocumented) @@ -9866,25 +9868,25 @@ export type SnapshotOptions = {}; // @public (undocumented) abstract class Source { - // (undocumented) + // (undocumented) buffer(): Buffer; - // (undocumented) + // (undocumented) map(options?: MapOptions): RawSourceMap | null; - // (undocumented) + // (undocumented) size(): number; - // (undocumented) + // (undocumented) source(): string | Buffer; - // (undocumented) + // (undocumented) sourceAndMap(options?: MapOptions): { - source: string | Buffer; - map: Object; - }; + source: string | Buffer; + map: Object; + }; - // (undocumented) + // (undocumented) updateHash(hash: Hash): void; } diff --git a/packages/rspack/src/ChunkGraph.ts b/packages/rspack/src/ChunkGraph.ts index b46803a9bfb3..9a43f0b5d7d7 100644 --- a/packages/rspack/src/ChunkGraph.ts +++ b/packages/rspack/src/ChunkGraph.ts @@ -61,4 +61,8 @@ export class ChunkGraph { .getModuleChunks(Module.__to_binding(module)) .map(binding => Chunk.__from_binding(binding)); } + + getModuleId(module: Module): string | null { + return this.#inner.getModuleId(Module.__to_binding(module)); + } }