From 9999d74a68ff8c3415086195667d72c2f038b8b1 Mon Sep 17 00:00:00 2001 From: Jinbao1001 Date: Wed, 16 Oct 2024 13:54:50 +0800 Subject: [PATCH 1/3] fix: reduce object assign --- src/templates/meta/exports.ts.tpl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/templates/meta/exports.ts.tpl b/src/templates/meta/exports.ts.tpl index bfb0e3702..cb87dcb87 100644 --- a/src/templates/meta/exports.ts.tpl +++ b/src/templates/meta/exports.ts.tpl @@ -184,10 +184,10 @@ export async function getFullRoutesMeta(): Promise> { })), ).then((ret) => ret.reduce( - (total, { id, meta }) => ({ - ...total, - [id]: meta, - }), + (total, { id, meta }) => { + total[id] = meta; + return total; + }, {}, ), ); From 3c25919c8a04046efc050badf458c259fe74d6db Mon Sep 17 00:00:00 2001 From: Jinbao1001 Date: Wed, 16 Oct 2024 14:17:12 +0800 Subject: [PATCH 2/3] fix: reduce object assign --- src/templates/meta/exports.ts.tpl | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/templates/meta/exports.ts.tpl b/src/templates/meta/exports.ts.tpl index cb87dcb87..5b04756ca 100644 --- a/src/templates/meta/exports.ts.tpl +++ b/src/templates/meta/exports.ts.tpl @@ -1,6 +1,5 @@ import { filesMeta, tabsMeta } from '.'; import type { IDemoData, IRouteMeta } from 'dumi/dist/client/theme-api/types'; - // Copy from React official demo. type ReactPromise = Promise & { status?: 'pending' | 'fulfilled' | 'rejected'; @@ -105,11 +104,8 @@ export async function getFullDemos() { // expand context for omit ext expandDemoContext(demo.context); }); - - return { - ...total, - ...demos, - }; + Object.assign(total, demos); + return total; }, {}), ); } From c58b99d2140edd76e726a1b20f689c7c70fb1e82 Mon Sep 17 00:00:00 2001 From: Jinbao1001 Date: Wed, 16 Oct 2024 14:21:44 +0800 Subject: [PATCH 3/3] fix: revert empty line --- src/templates/meta/exports.ts.tpl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/templates/meta/exports.ts.tpl b/src/templates/meta/exports.ts.tpl index 5b04756ca..e1fb45717 100644 --- a/src/templates/meta/exports.ts.tpl +++ b/src/templates/meta/exports.ts.tpl @@ -1,5 +1,6 @@ import { filesMeta, tabsMeta } from '.'; import type { IDemoData, IRouteMeta } from 'dumi/dist/client/theme-api/types'; + // Copy from React official demo. type ReactPromise = Promise & { status?: 'pending' | 'fulfilled' | 'rejected';