Skip to content

Commit

Permalink
Revert "chore: isGTEReact16 > shouldUseAutomaticRuntime"
Browse files Browse the repository at this point in the history
This reverts commit 90e5c9d.
  • Loading branch information
Wu-kung committed Mar 21, 2024
1 parent 90e5c9d commit 52baa94
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/preset-umi/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ umi build --clean
umi: join(api.paths.absTmpPath, 'umi.ts'),
},
});
const shouldUseAutomaticRuntime =
const isGTEReact16 =
api.appData.react?.version &&
semver.gte(api.appData.react.version, '16.14.0');
const opts = {
react: {
runtime: shouldUseAutomaticRuntime ? 'automatic' : 'classic',
runtime: isGTEReact16 ? 'automatic' : 'classic',
},
config: api.config,
cwd: api.cwd,
Expand Down
4 changes: 2 additions & 2 deletions packages/preset-umi/src/commands/dev/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,12 @@ PORT=8888 umi dev
},
});

const shouldUseAutomaticRuntime =
const isGTEReact16 =
api.appData.react?.version &&
semver.gte(api.appData.react.version, '16.14.0');
const opts: any = {
react: {
runtime: shouldUseAutomaticRuntime ? 'automatic' : 'classic',
runtime: isGTEReact16 ? 'automatic' : 'classic',
},
config: api.config,
pkg: api.pkg,
Expand Down
6 changes: 3 additions & 3 deletions packages/preset-umi/src/commands/dev/getBabelOpts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { IApi } from '../../types';

export async function getBabelOpts(opts: { api: IApi }) {
// TODO: 支持用户自定义
const shouldUseAutomaticRuntime = semver.gte(opts.api.appData.react.version, '16.14.0');
const isGTEReact16 = semver.gte(opts.api.appData.react.version, '16.14.0');
const babelPresetOpts = await opts.api.applyPlugins({
key: 'modifyBabelPresetOpts',
initialValue: {
presetEnv: {},
presetReact: {
runtime: shouldUseAutomaticRuntime ? 'automatic' : 'classic',
runtime: isGTEReact16 ? 'automatic' : 'classic',
// importSource cannot be set when runtime is classic
...(shouldUseAutomaticRuntime ? {} : { importSource: undefined }),
...(isGTEReact16 ? {} : { importSource: undefined }),
},
presetTypeScript: {},
pluginTransformRuntime: {},
Expand Down

0 comments on commit 52baa94

Please sign in to comment.