Skip to content

Commit 2cb2d87

Browse files
Migration build (#1033)
1 parent b47a7e8 commit 2cb2d87

29 files changed

+479
-6
lines changed

src/.vuepress/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ const sidebar = {
172172
],
173173
migration: [
174174
'/guide/migration/introduction',
175+
'/guide/migration/migration-build',
175176
{
176177
title: 'Details',
177178
collapsable: false,

src/guide/migration/array-refs.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,10 @@ Note that:
7070
- `itemRefs` doesn't have to be an array: it can also be an object where the refs are set by their iteration keys.
7171

7272
- This also allows `itemRefs` to be made reactive and watched, if needed.
73+
74+
## Migration Strategy
75+
76+
[Migration build flags:](migration-build.html#compat-configuration)
77+
78+
- `V_FOR_REF`
79+
- `COMPILER_V_FOR_REF`

src/guide/migration/async-components.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,4 @@ const asyncComponent = defineAsyncComponent(
9595
For more information on the usage of async components, see:
9696

9797
- [Guide: Dynamic & Async Components](/guide/component-dynamic-async.html#dynamic-components-with-keep-alive)
98+
- [Migration build flag: `COMPONENT_ASYNC`](migration-build.html#compat-configuration)

src/guide/migration/attribute-coercion.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,8 @@ In 3.x, `null` or `undefined` should be used to explicitly remove an attribute.
137137
</tr>
138138
</tbody>
139139
</table>
140+
141+
[Migration build flags:](migration-build.html#compat-configuration)
142+
143+
- `ATTR_FALSE_VALUE`
144+
- `ATTR_ENUMERATED_COERSION`

src/guide/migration/attrs-includes-class-style.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ when used like this:
6060

6161
In components that use `inheritAttrs: false`, make sure that styling still works as intended. If you previously relied on the special behavior of `class` and `style`, some visuals might be broken as these attributes might now be applied to another element.
6262

63+
[Migration build flag: `INSTANCE_ATTRS_CLASS_STYLE`](migration-build.html#compat-configuration)
64+
6365
## See also
6466

6567
- [Relevant RFC](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0031-attr-fallthrough.md)

src/guide/migration/children.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,7 @@ export default {
3838
## 3.x Update
3939

4040
In 3.x, the `$children` property is removed and no longer supported. Instead, if you need to access a child component instance, we recommend using [$refs](/guide/component-template-refs.html#template-refs).
41+
42+
## Migration Strategy
43+
44+
[Migration build flag: `INSTANCE_CHILDREN`](migration-build.html#compat-configuration)

src/guide/migration/custom-directives.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,7 @@ mounted(el, binding, vnode) {
103103
:::warning
104104
With [fragments](/guide/migration/fragments.html#overview) support, components can potentially have more than one root node. When applied to a multi-root component, a custom directive will be ignored and a warning will be logged.
105105
:::
106+
107+
## Migration Strategy
108+
109+
[Migration build flag: `CUSTOM_DIR`](migration-build.html#compat-configuration)

src/guide/migration/custom-elements-interop.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ In 3.0, we are limiting Vue's special treatment of the `is` prop to the `<compon
9696
document.createElement('button', { is: 'plastic-button' })
9797
```
9898

99+
[Migration build flag: `COMPILER_IS_ON_ELEMENT`](migration-build.html#compat-configuration)
100+
99101
## `v-is` for In-DOM Template Parsing Workarounds
100102

101103
> Note: this section only affects cases where Vue templates are directly written in the page's HTML.

src/guide/migration/data-option.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ In 3.0, the result will be:
111111
}
112112
```
113113

114+
[Migration build flag: `OPTIONS_DATA_FN`](migration-build.html#compat-configuration)
115+
114116
## Migration Strategy
115117

116118
For users relying on the object declaration, we recommend:
@@ -119,3 +121,8 @@ For users relying on the object declaration, we recommend:
119121
- Rewrite references to the shared data to point to a new shared object
120122

121123
For users relying on the deep merge behavior from mixins, we recommend refactoring your code to avoid such reliance altogether, since deep merges from mixins are very implicit and can make the code logic more difficult to understand and debug.
124+
125+
[Migration build flags:](migration-build.html#compat-configuration)
126+
127+
- `OPTIONS_DATA_FN`
128+
- `OPTIONS_DATA_MERGE`

src/guide/migration/events-api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,5 @@ export default {
7979
This provides the same event emitter API as in Vue 2.
8080

8181
These methods may also be supported in a future compatibility build of Vue 3.
82+
83+
[Migration build flag: `INSTANCE_EVENT_EMITTER`](migration-build.html#compat-configuration)

src/guide/migration/filters.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ Using the example above, here is one example of how it could be implemented.
7373

7474
Instead of using filters, we recommend replacing them with computed properties or methods.
7575

76+
[Migration build flags:](migration-build.html#compat-configuration)
77+
78+
- `FILTERS`
79+
- `COMPILER_FILTERS`
80+
7681
### Global Filters
7782

7883
If you are using filters that were globally registered and then used throughout your app, it's likely not convenient to replace them with computed properties or methods in each individual component.

src/guide/migration/functional-components.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,4 @@ For more information on the usage of the new functional components and the chang
117117

118118
- [Migration: Render Functions](/guide/migration/render-function-api.html)
119119
- [Guide: Render Functions](/guide/render-function.html)
120+
- [Migration build flag: `COMPONENT_FUNCTIONAL`](migration-build.html#compat-configuration)

src/guide/migration/global-api.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ An app instance exposes a subset of the Vue 2 global APIs. The rule of thumb is
8585
| Vue.mixin | app.mixin |
8686
| Vue.use | app.use ([see below](#a-note-for-plugin-authors)) |
8787
| Vue.prototype | app.config.globalProperties ([see below](#vue-prototype-replaced-by-config-globalproperties)) |
88+
| Vue.extend | _removed_ ([see below](#vue-extend-replaced-by-definecomponent)) |
8889

8990
All other global APIs that do not globally mutate behavior are now named exports, as documented in [Global API Treeshaking](./global-api-treeshaking.html).
9091

@@ -94,6 +95,8 @@ In Vue 3.x, the "use production build" tip will only show up when using the "dev
9495

9596
For ES modules builds, since they are used with bundlers, and in most cases a CLI or boilerplate would have configured the production env properly, this tip will no longer show up.
9697

98+
[Migration build flag: `CONFIG_PRODUCTION_TIP`](migration-build.html#compat-configuration)
99+
97100
### `config.ignoredElements` Is Now `config.isCustomElement`
98101

99102
This config option was introduced with the intention to support native custom elements, so the renaming better conveys what it does. The new option also expects a function which provides more flexibility than the old string / RegExp approach:
@@ -115,6 +118,8 @@ In Vue 3, the check of whether an element is a component or not has been moved t
115118
- This will be a new top-level option in the Vue CLI config.
116119
:::
117120

121+
[Migration build flag: `CONFIG_IGNORED_ELEMENTS`](migration-build.html#compat-configuration)
122+
118123
### `Vue.prototype` Replaced by `config.globalProperties`
119124

120125
In Vue 2, `Vue.prototype` was commonly used to add properties that would be accessible in all components.
@@ -134,6 +139,58 @@ app.config.globalProperties.$http = () => {}
134139

135140
Using `provide` (discussed [below](#provide-inject)) should also be considered as an alternative to `globalProperties`.
136141

142+
[Migration build flag: `GLOBAL_PROTOTYPE`](migration-build.html#compat-configuration)
143+
144+
### `Vue.extend` Removed
145+
146+
In Vue 2.x, `Vue.extend` was used to create a "subclass" of the base Vue constructor with the argument that should be an object containing component options. In Vue 3.x, we don't have the concept of component constructors anymore. Mounting a component should always use the `createApp` global API:
147+
148+
```js
149+
// before - Vue 2
150+
151+
// create constructor
152+
const Profile = Vue.extend({
153+
template: '<p>{{firstName}} {{lastName}} aka {{alias}}</p>',
154+
data() {
155+
return {
156+
firstName: 'Walter',
157+
lastName: 'White',
158+
alias: 'Heisenberg'
159+
}
160+
}
161+
})
162+
// create an instance of Profile and mount it on an element
163+
new Profile().$mount('#mount-point')
164+
```
165+
166+
```js
167+
// after - Vue 3
168+
const Profile = {
169+
template: '<p>{{firstName}} {{lastName}} aka {{alias}}</p>',
170+
data() {
171+
return {
172+
firstName: 'Walter',
173+
lastName: 'White',
174+
alias: 'Heisenberg'
175+
}
176+
}
177+
}
178+
179+
Vue.createApp(Profile).mount('#mount-point')
180+
```
181+
182+
#### Type Inference
183+
184+
In Vue 2, `Vue.extend` was also used for providing TypeScript type inference for the component options. In Vue 3, the `defineComponent` global API can be used in place of `Vue.extend` for the same purpose.
185+
186+
Note that although the return type of `defineComponent` is a constructor-like type, it is only used for TSX inference. At runtime `defineComponent` is largely a noop and will return the options object as-is.
187+
188+
#### Component Inheritance
189+
190+
In Vue 3, we strongly recommend favoring composition via [Composition API](/api/composition-api.html) over inheritance and mixins. If for some reason you still need component inheritance, you can use the [`extends` option](/api/options-composition.html#extends) instead of `Vue.extend`.
191+
192+
[Migration build flag: `GLOBAL_EXTEND`](migration-build.html#compat-configuration)
193+
137194
### A Note for Plugin Authors
138195

139196
It is a common practice for plugin authors to install the plugins automatically in their UMD builds using `Vue.use`. For instance, this is how the official `vue-router` plugin installs itself in a browser environment:
@@ -187,6 +244,8 @@ app.directive('focus', {
187244
app.mount('#app')
188245
```
189246

247+
[Migration build flag: `GLOBAL_MOUNT`](migration-build.html#compat-configuration)
248+
190249
## Provide / Inject
191250

192251
Similar to using the `provide` option in a 2.x root instance, a Vue 3 app instance can also provide dependencies that can be injected by any component inside the app:

src/guide/migration/inline-template-attribute.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ This feature will no longer be supported.
3030

3131
Most of the use cases for `inline-template` assumes a no-build-tool setup, where all templates are written directly inside the HTML page.
3232

33+
[Migration build flag: `COMPILER_INLINE_TEMPLATE`](migration-build.html#compat-configuration)
34+
3335
### Option #1: Use `<script>` tag
3436

3537
The most straightforward workaround in such cases is using `<script>` with an alternative type:

src/guide/migration/introduction.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ New to Vue.js? Check out our [Essentials Guide](/guide/introduction.html) to get
77
This guide is primarily for users with prior Vue 2 experience who want to learn about the new features and changes in Vue 3. **This is not something you have to read from top to bottom before trying out Vue 3.** While it looks like a lot has changed, a lot of what you know and love about Vue is still the same; but we wanted to be as thorough as possible and provide detailed explanations and examples for every documented change.
88

99
- [Quickstart](#quickstart)
10+
- [Migration Build](#migration-build)
1011
- [Notable New Features](#notable-new-features)
1112
- [Breaking Changes](#breaking-changes)
1213
- [Supporting Libraries](#supporting-libraries)
@@ -20,6 +21,8 @@ Start learning Vue 3 at [Vue Mastery](https://www.vuemastery.com/courses-path/vu
2021

2122
## Quickstart
2223

24+
If you want to quickly try out Vue 3 in a new project:
25+
2326
- Via CDN: `<script src="https://unpkg.com/vue@next"></script>`
2427
- In-browser playground on [Codepen](https://codepen.io/yyx990803/pen/OJNoaZL)
2528
- In-browser Sandbox on [CodeSandbox](https://v3.vue.new)
@@ -37,6 +40,10 @@ Start learning Vue 3 at [Vue Mastery](https://www.vuemastery.com/courses-path/vu
3740
# select vue 3 preset
3841
```
3942

43+
## Migration Build
44+
45+
If you have an existing Vue 2 project or library that you intend to upgrade to Vue 3, we provide a build of Vue 3 that offers Vue 2 compatible APIs. Check out the [Migration Build](./migration-build.html) page for more details.
46+
4047
## Notable New Features
4148

4249
Some of the new features to keep an eye on in Vue 3 include:
@@ -53,10 +60,6 @@ Some of the new features to keep an eye on in Vue 3 include:
5360

5461
## Breaking Changes
5562

56-
::: info INFO
57-
We are still working on a dedicated Migration Build of Vue 3 with Vue 2 compatible behavior and runtime warnings of incompatible usage. If you are planning to migrate a non-trivial Vue 2 app, we strongly recommend waiting for the Migration Build for a smoother experience.
58-
:::
59-
6063
The following consists a list of breaking changes from 2.x:
6164

6265
### Global API

src/guide/migration/keycode-modifiers.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,8 @@ As a result, this means that `config.keyCodes` is now also deprecated and will n
5454
## Migration Strategy
5555

5656
For those using `keyCode` in their codebase, we recommend converting them to their kebab-cased named equivalents.
57+
58+
[Migration build flags:](migration-build.html#compat-configuration)
59+
60+
- `CONFIG_KEY_CODES`
61+
- `V_ON_KEYCODE_MODIFIER`

src/guide/migration/listeners-removed.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ If this component received an `id` attribute and a `v-on:close` listener, the `$
6565

6666
Remove all usages of `$listeners`.
6767

68+
[Migration build flag: `INSTANCE_LISTENERS`](migration-build.html#compat-configuration)
69+
6870
## See also
6971

7072
- [Relevant RFC](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0031-attr-fallthrough.md)

0 commit comments

Comments
 (0)