Skip to content

Commit

Permalink
Fix preset umi polyfill targets (#9298)
Browse files Browse the repository at this point in the history
* fix: polyfill targets undefined at the dev command

* docs: fix default targets

* fix: use DEFAULT_BROWSER_TARGETS from @umijs/bundler-webpack

* import DEFAULT_BROWSER_TARGETS from bundler-webpack

Co-authored-by: Yingci <59400654+fz6m@users.noreply.github.com>

Co-authored-by: Yingci <59400654+fz6m@users.noreply.github.com>
  • Loading branch information
2239559319 and fz6m authored Nov 3, 2022
1 parent c6a9a50 commit 7f2230c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/docs/api/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ import SmileUrl, { ReactComponent as SvgSmile } from './smile.svg';
## targets

- 类型:`object`
- 默认值:`{ chrome: 87 }`
- 默认值:`{ chrome: 80 }`

配置需要兼容的浏览器最低版本。Umi 会根据这个自定引入 polyfill、配置 autoprefixer 和做语法转换等。

Expand Down
3 changes: 3 additions & 0 deletions packages/preset-umi/src/features/polyfill/polyfill.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { transform } from '@umijs/bundler-utils/compiled/babel/core';
import { getCorejsVersion, winPath } from '@umijs/utils';
import { dirname, join } from 'path';
import { DEFAULT_BROWSER_TARGETS } from '@umijs/bundler-webpack/dist/constants';
import { IApi } from '../../types';

export default (api: IApi) => {
Expand Down Expand Up @@ -60,6 +61,8 @@ export {};
api.addPolyfillImports(() => [{ source: `./core/polyfill` }]);

api.modifyConfig((memo) => {
memo.targets ||= DEFAULT_BROWSER_TARGETS;

memo.alias['regenerator-runtime'] = dirname(
require.resolve('regenerator-runtime/package'),
);
Expand Down

1 comment on commit 7f2230c

@vercel
Copy link

@vercel vercel bot commented on 7f2230c Nov 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.