admin管理员组

文章数量:1325505

This question has puzzled me at several points when using Vue 2 and Vue CLI, and now again with starting a fresh Vue 3.0 beta project.

Even with the currently newest Vue CLI version 4.3.1, when choosing TypeScript option, the boilerplate code you are given has pilerOptions target set as esnext in tsconfig.json.

While Vue 2 TypeScript Guide is instructing:

# Remended Configuration
// tsconfig.json
{
  "pilerOptions": {
    // this aligns with Vue's browser support
    "target": "es5",
    // this enables stricter inference for data properties on `this`
    "strict": true,
    // if using webpack 2+ or rollup, to leverage tree shaking:
    "module": "es2015",
    "moduleResolution": "node"
  }
}

Currently Vue Next repo is using esnext, although at this point IE11 support is not ready yet (but might not affect this config anyhow)...

What will be the remended setting for this piler target when using Vue 3?

I'm needing to support legacy browsers down to IE11, but this particular app project has plenty of time until it's initial release to wait for Vue 3's full release.

This question has puzzled me at several points when using Vue 2 and Vue CLI, and now again with starting a fresh Vue 3.0 beta project.

Even with the currently newest Vue CLI version 4.3.1, when choosing TypeScript option, the boilerplate code you are given has pilerOptions target set as esnext in tsconfig.json.

While Vue 2 TypeScript Guide is instructing:

# Remended Configuration
// tsconfig.json
{
  "pilerOptions": {
    // this aligns with Vue's browser support
    "target": "es5",
    // this enables stricter inference for data properties on `this`
    "strict": true,
    // if using webpack 2+ or rollup, to leverage tree shaking:
    "module": "es2015",
    "moduleResolution": "node"
  }
}

Currently Vue Next repo is using esnext, although at this point IE11 support is not ready yet (but might not affect this config anyhow)...

What will be the remended setting for this piler target when using Vue 3?

I'm needing to support legacy browsers down to IE11, but this particular app project has plenty of time until it's initial release to wait for Vue 3's full release.

Share Improve this question edited Jul 14, 2022 at 2:21 tony19 139k23 gold badges277 silver badges347 bronze badges asked Apr 21, 2020 at 12:02 ux.engineerux.engineer 11.4k15 gold badges69 silver badges114 bronze badges 5
  • 3 The repo you linked explicitly states, In addition, the current implementation requires native ES2015+ in the runtime environment and does not support IE11 (yet). The IE11 patible build will be worked on after we have reached RC stage. – Estus Flask Commented May 3, 2020 at 9:39
  • Thanks for pointing out Estus, care to make an answer out of it? – ux.engineer Commented May 4, 2020 at 5:40
  • @EstusFlask care to make an answer here, so I can reward your bounty! – ux.engineer Commented May 7, 2020 at 8:43
  • Sure. The answer isn't exhaustive for now, this may change in future. But one thing's for sure, you need to pay attention to reactivity to not have problems with IE11 in future. – Estus Flask Commented May 7, 2020 at 14:42
  • Just keep tuning it better later on then :) – ux.engineer Commented May 7, 2020 at 20:15
Add a ment  | 

1 Answer 1

Reset to default 4 +50

As Vue 3 repository states,

the current implementation requires native ES2015+ in the runtime environment and does not support IE11 (yet). The IE11 patible build will be worked on after we have reached RC stage.

As it was noted, the target of Vue 3 is currently esnext, it relies on modern JS features and is currently aimed at the development in evergreen browsers and isn't supposed to be used in production. Vue 3 cannot be usable in legacy browsers even with lower target because it currently relies on proxies which are ES6 feature that cannot be polyfilled.

The project that uses existing Vue 3 build won't benefit from target lower than es2018 which is likely the least mon denominator, object spread is among most popular recent additions that is used in Vue 3 codebase and cannot be polyfilled. TypeScript target can be experimentally lowered to es5 with downlevelIteration option enabled for early detection of some patibility problems.

It's expected that separate versions of Vue 3 will be maintained for legacy (IE11) and modern browsers. The difference is how reactivity is handled because Proxy allows for advanced change detection but cannot be implemented in legacy browsers. The project should follow existing guidelines for Vue 2 reactivity in order to be patible with legacy Vue 3 build.

本文标签: javascriptVue 3 recommended TypeScript TSConfig compilerOptions TARGET settingStack Overflow