Skip to content

Commit

Permalink
fix: use default {} instead of chrome 40
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinbao1001 committed Jul 26, 2024
1 parent 4d313fe commit d6d76d0
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/docs/blog/legacy-browser.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ group:

## 默认兼容说明

Umi 4 默认不支持 IE ,编译兼容目标 `targets``chrome: 40` ,如需调整,请指定明确的 [targets](../docs/api/config#targets)
Umi 4 默认不支持 IE ,编译兼容目标 `targets``{}` ,如需调整,请指定明确的 [targets](../docs/api/config#targets)

```ts
// .umirc.ts
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/blog/legacy-browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ group:

## 默认兼容说明

Umi 4 默认不支持 IE ,编译兼容目标 `targets``chrome: 40` ,如需调整,请指定明确的 [targets](../docs/api/config#targets)
Umi 4 默认不支持 IE ,编译兼容目标 `targets``{}` ,如需调整,请指定明确的 [targets](../docs/api/config#targets)

```ts
// .umirc.ts
Expand Down
4 changes: 3 additions & 1 deletion docs/docs/docs/api/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -1467,10 +1467,12 @@ import SmileUrl, { ReactComponent as SvgSmile } from './smile.svg';
## targets

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

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

如果你不需要兼容早期浏览器,减少产物构建尺寸, 请将 `targets` 配置为 `{chrome: "80"}`

示例,

```js
Expand Down
4 changes: 1 addition & 3 deletions packages/bundler-webpack/client/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ var MESSAGE_TYPE = /* @__PURE__ */ ((MESSAGE_TYPE2) => {
MESSAGE_TYPE2["invalid"] = "invalid";
return MESSAGE_TYPE2;
})(MESSAGE_TYPE || {});
var DEFAULT_BROWSER_TARGETS = {
chrome: 40
};
var DEFAULT_BROWSER_TARGETS = {};
var DEFAULT_ESBUILD_TARGET_KEYS = [
"chrome",
"firefox",
Expand Down
2 changes: 1 addition & 1 deletion packages/bundler-webpack/src/config/compressPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function addCompressPlugin(opts: IOpts) {

// esbuild transform only allow `string[]` as target
const esbuildTarget = getEsBuildTarget({
targets: { chrome: '80' },
targets: userConfig.targets || {},
jsMinifier,
});
// 提升 esbuild 压缩产物的兼容性,比如不出现 ?? 这种语法
Expand Down
4 changes: 1 addition & 3 deletions packages/bundler-webpack/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ export enum MESSAGE_TYPE {
invalid = 'invalid',
}

export const DEFAULT_BROWSER_TARGETS = {
chrome: 40,
};
export const DEFAULT_BROWSER_TARGETS = {};

export const DEFAULT_ESBUILD_TARGET_KEYS = [
'chrome',
Expand Down

0 comments on commit d6d76d0

Please sign in to comment.