Skip to content

Commit

Permalink
fix: asset source can not be undefined (#5509)
Browse files Browse the repository at this point in the history
  • Loading branch information
jerrykingxyz authored Jan 29, 2024
1 parent 28024f7 commit 5d04f6c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/rspack/src/Compilation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export type AssetInfo = Partial<JsAssetInfo> & Record<string, any>;
export type Assets = Record<string, Source>;
export interface Asset {
name: string;
source?: Source;
source: Source;
info: JsAssetInfo;
}
export interface LogEntry {
Expand Down Expand Up @@ -467,18 +467,18 @@ export class Compilation {
return assets.map(asset => {
return Object.defineProperty(asset, "source", {
get: () => this.__internal__getAssetSource(asset.name)
});
}) as Asset;
});
}

getAsset(name: string): Asset | undefined {
getAsset(name: string): Asset | void {
const asset = this.#inner.getAsset(name);
if (!asset) {
return;
}
return Object.defineProperty(asset, "source", {
get: () => this.__internal__getAssetSource(asset.name)
});
}) as Asset;
}

pushDiagnostic(
Expand Down Expand Up @@ -865,7 +865,7 @@ export class Compilation {
*
* @internal
*/
__internal__getAssetSource(filename: string): Source | undefined {
__internal__getAssetSource(filename: string): Source | void {
const rawSource = this.#inner.getAssetSource(filename);
if (!rawSource) {
return;
Expand Down

1 comment on commit 5d04f6c

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

Name Base (2024-01-29 d22f049) Current Change
10000_development-mode + exec 1.78 s ± 27 ms 1.7 s ± 12 ms -4.69 %
10000_development-mode_hmr + exec 959 ms ± 10 ms 945 ms ± 13 ms -1.42 %
10000_production-mode + exec 2.69 s ± 19 ms 2.69 s ± 43 ms -0.04 %
threejs_development-mode_10x + exec 2.04 s ± 29 ms 2.03 s ± 30 ms -0.74 %
threejs_development-mode_10x_hmr + exec 1.25 s ± 11 ms 1.24 s ± 19 ms -1.22 %
threejs_production-mode_10x + exec 6.19 s ± 38 ms 6.02 s ± 66 ms -2.83 %

Please sign in to comment.