Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: 🔥 remove deep clone #12324

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading