Skip to content

Commit

Permalink
refactor: πŸ”₯ remove deep clone (#12324)
Browse files Browse the repository at this point in the history
* refactor: πŸ”₯ remove deep clone

* refactor: πŸ”₯ remove outputfiles in defination
  • Loading branch information
stormslowly committed Apr 29, 2024
1 parent 575590e commit 3e291e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/service/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class Service {
>;
framework?: IFrameworkType;
prepare?: {
buildResult: BuildResult;
buildResult: Omit<BuildResult, 'outputFiles'>;
fileImports?: Record<string, Declaration[]>;
};
mpa?: {
Expand Down
19 changes: 7 additions & 12 deletions packages/preset-umi/src/features/prepare/prepare.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import type { BuildResult } from '@umijs/bundler-utils/compiled/esbuild';
import type { Declaration } from '@umijs/es-module-parser';
import {
aliasUtils,
importLazy,
isJavaScriptFile,
lodash,
logger,
} from '@umijs/utils';
import { aliasUtils, importLazy, isJavaScriptFile, logger } from '@umijs/utils';
import path from 'path';
import { addUnWatch } from '../../commands/dev/watch';
import { IApi, IOnGenerateFiles } from '../../types';
Expand All @@ -20,11 +14,12 @@ export default (api: IApi) => {
buildResult: BuildResult;
fileImports?: Record<string, Declaration[]>;
}) {
const buildResult: BuildResult = lodash.cloneDeep(prepareData.buildResult);
(buildResult.outputFiles || []).forEach((file) => {
// @ts-ignore
delete file?.contents;
});
const buildResult: BuildResult = {
...prepareData.buildResult,
// we don't need output file in prepare stage
outputFiles: undefined,
};

const nextFileImports =
prepareData.fileImports ?? api.appData.prepare?.fileImports;
api.appData.prepare = {
Expand Down

0 comments on commit 3e291e5

Please sign in to comment.