Skip to content

Commit

Permalink
chore: add opts.react for bundler (#12069)
Browse files Browse the repository at this point in the history
  • Loading branch information
sorrycc authored Jan 16, 2024
1 parent a1f72da commit bb78833
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/preset-umi/src/commands/build.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getMarkup } from '@umijs/server';
import { chalk, fsExtra, logger, rimraf } from '@umijs/utils';
import { chalk, fsExtra, logger, rimraf, semver } from '@umijs/utils';
import { writeFileSync } from 'fs';
import { dirname, join, resolve } from 'path';
import type { IApi, IOnGenerateFiles } from '../types';
Expand Down Expand Up @@ -97,7 +97,13 @@ umi build --clean
umi: join(api.paths.absTmpPath, 'umi.ts'),
},
});
const isGTEReact17 =
api.appData.react?.version &&
semver.gte(api.appData.react.version, '17.0.0');
const opts = {
react: {
runtime: isGTEReact17 ? 'automatic' : 'classic',
},
config: api.config,
cwd: api.cwd,
entry,
Expand Down
7 changes: 7 additions & 0 deletions packages/preset-umi/src/commands/dev/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
logger,
portfinder,
rimraf,
semver,
winPath,
} from '@umijs/utils';
import { existsSync, readdirSync, readFileSync } from 'fs';
Expand Down Expand Up @@ -347,7 +348,13 @@ PORT=8888 umi dev
},
});

const isGTEReact17 =
api.appData.react?.version &&
semver.gte(api.appData.react.version, '17.0.0');
const opts: any = {
react: {
runtime: isGTEReact17 ? 'automatic' : 'classic',
},
config: api.config,
pkg: api.pkg,
cwd: api.cwd,
Expand Down

0 comments on commit bb78833

Please sign in to comment.