diff --git a/crates/node_binding/binding.d.ts b/crates/node_binding/binding.d.ts index 5a2505ec2e0..6dacc676f72 100644 --- a/crates/node_binding/binding.d.ts +++ b/crates/node_binding/binding.d.ts @@ -27,6 +27,7 @@ export class JsCompilation { getModules(): Array getOptimizationBailout(): Array getChunks(): Array + getNamedChunkKeys(): Array getNamedChunk(name: string): JsChunk | null setAssetSource(name: string, source: JsCompatSource): void deleteAssetSource(name: string): void diff --git a/crates/rspack_binding_values/src/compilation.rs b/crates/rspack_binding_values/src/compilation.rs index ea4af705591..f38f15a7417 100644 --- a/crates/rspack_binding_values/src/compilation.rs +++ b/crates/rspack_binding_values/src/compilation.rs @@ -175,6 +175,11 @@ impl JsCompilation { .collect::>() } + #[napi] + pub fn get_named_chunk_keys(&self) -> Vec { + self.0.named_chunks.keys().cloned().collect::>() + } + #[napi] pub fn get_named_chunk(&self, name: String) -> Option { self diff --git a/crates/rspack_core/src/options/target.rs b/crates/rspack_core/src/options/target.rs index be27bea4d6c..8682f4e1984 100644 --- a/crates/rspack_core/src/options/target.rs +++ b/crates/rspack_core/src/options/target.rs @@ -38,6 +38,7 @@ impl Target { "browserslist" => TargetEsVersion::BrowsersList, "es3" => TargetEsVersion::Esx(EsVersion::Es3), "es5" => TargetEsVersion::Esx(EsVersion::Es5), + "es6" => TargetEsVersion::Esx(EsVersion::Es2015), "es2015" => TargetEsVersion::Esx(EsVersion::Es2015), "es2016" => TargetEsVersion::Esx(EsVersion::Es2016), "es2017" => TargetEsVersion::Esx(EsVersion::Es2017), diff --git a/packages/rspack/etc/api.md b/packages/rspack/etc/api.md index 9f10f3968b6..26a5d2ea749 100644 --- a/packages/rspack/etc/api.md +++ b/packages/rspack/etc/api.md @@ -12382,12 +12382,16 @@ export class Stats { // (undocumented) compilation: Compilation; // (undocumented) + get endTime(): number | undefined; + // (undocumented) hasErrors(): boolean; // (undocumented) get hash(): Readonly; // (undocumented) hasWarnings(): boolean; // (undocumented) + get startTime(): number | undefined; + // (undocumented) toJson(opts?: StatsValue, forToString?: boolean): StatsCompilation; // (undocumented) toString(opts?: StatsValue): string; diff --git a/packages/rspack/src/Compilation.ts b/packages/rspack/src/Compilation.ts index ece9b1d74e4..e524a5774d4 100644 --- a/packages/rspack/src/Compilation.ts +++ b/packages/rspack/src/Compilation.ts @@ -15,8 +15,7 @@ import { type JsModule, type JsPathData, JsRspackSeverity, - type JsRuntimeModule, - type JsStatsError + type JsRuntimeModule } from "@rspack/binding"; import * as liteTapable from "@rspack/lite-tapable"; import { Source } from "webpack-sources"; @@ -376,10 +375,14 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si /** * Get the named chunks. * - * Note: This is a proxy for webpack internal API, only method `get` is supported now. + * Note: This is a proxy for webpack internal API, only method `get` and `keys` is supported now. */ get namedChunks(): ReadonlyMap> { return { + keys: (): IterableIterator => { + const names = this.#inner.getNamedChunkKeys(); + return names[Symbol.iterator](); + }, get: (property: unknown) => { if (typeof property === "string") { const chunk = this.#inner.getNamedChunk(property) || undefined; diff --git a/packages/rspack/src/Stats.ts b/packages/rspack/src/Stats.ts index 27336c350d2..2ab9c8ff8eb 100644 --- a/packages/rspack/src/Stats.ts +++ b/packages/rspack/src/Stats.ts @@ -47,6 +47,14 @@ export class Stats { return this.compilation.hash; } + get startTime() { + return this.compilation.startTime; + } + + get endTime() { + return this.compilation.endTime; + } + hasErrors() { return this.#inner.getErrors().length > 0; }