Skip to content

Commit 807c120

Browse files
committed
Upgrade Guide: Proofreading complete
1 parent 627f7d9 commit 807c120

File tree

1 file changed

+42
-30
lines changed

1 file changed

+42
-30
lines changed

content/docs/en/getting-started/4-upgrade-guide.md

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,23 @@ outdated: false
88
99
If you scaffolded a NativeScript-Vue app using the 1.3.1 version of the Vue-CLI template, it's time to upgrade to the newest 2.0 version. This guide will help you do that.
1010

11-
The new template has a different folder structure from the older one:
11+
## Upgrade overivew
12+
13+
The new template has a different folder structure:
1214

1315
![New folder structure](/screenshots/old-new-folder-structure.png)
1416

15-
The upgrade process involves creating a new project from the updated template, copying files from your old app into the new one, and then rearranging and adding some files.
17+
The simplified upgrade process involves:
18+
19+
1. Creating a new project from the updated template.
20+
1. Copying files from your old app into the new one.
21+
1. Rearranging and adding some files.
1622

1723
## Step 1: Create new app
1824

19-
Start by creating a new app using the Vue-CLI template.
25+
Use the Vue-CLI template to create a new app. Make sure to run the same preinstallation commands that you used for the old version. For example, if you installed Vuex in the CLI the first time, do it again now.
2026

21-
> **TIP:** In your new project, use the same preinstallation commands that you used when creating the older version. For example, if you installed Vuex in the CLI the first time, do it again now.
27+
Run the following command to create a new project from the Vue-CLI template.
2228

2329
```shell
2430
$ npm install -g @vue/cli @vue/cli-init
@@ -30,30 +36,38 @@ $ # or
3036
$ tns run ios --bundle
3137
```
3238

33-
## Step 2: Replace the app resources
39+
## Step 2: Replace `App_Resources`
3440

3541
First, copy your old app's `App_Resources` folder from `./template/app/`. Next, paste it into the new app's `app` folder. Make sure that you're replacing the new `App_Resources` folder.
3642

3743
## Step 3: Merge the `src` and `app` folders
3844

3945
Copy all the folders in `src` from your old app and paste them into the `app` folder in the new app.
4046

41-
If you have custom fonts, move the `src/assets/fonts` folder to `app/fonts` to let NativeScript load them automatically.
47+
If you have custom fonts, move the contents of the `src/assets/fonts` folder to `app/fonts`. This ensures that NativeScript will load your custom fonts automatically.
4248

4349
## Step 4: Edit `main.js`
4450

45-
NativeScript 4.0 introduced two major improvements:
51+
Edit `main.js`'s Vue initialization block to resemble:
52+
53+
```js
54+
new Vue({
55+
render: h => h('frame', [h(HelloWorld)]),
56+
}).$start();
57+
```
58+
59+
NativeScript 4.0 brings two major improvements:
4660

4761
* a new `<Frame>` element
48-
* a way to change the root element of our applications that lets you share common view elements across pages (navigations).
62+
* a new way to change the root element of your app that lets you share common view elements across pages (navigations).
4963

50-
Prior to NativeScript 4.0, the root element was a `<Frame>` which was implicitly created by NativeScript when the application started.
64+
Before NativeScript 4.0, the root element was a `<Frame>` element which was implicitly created by NativeScript when the application started.
5165

5266
With the latest changes, `<Frame>` and `<Page>` elements are longer automatically created. So, in NativeScript-Vue 2.0.0, you need to explicitly add these elements to your template.
5367

5468
To keep the previous behavior of having a single root `<Frame>`, you can change your root Vue instance to have a `<Frame>` and a `<Page>` element.
5569

56-
**Example**
70+
**Example: Adding `<Frame>` and `<Page>` to the template**
5771

5872
```JavaScript
5973
// in older versions
@@ -77,7 +91,9 @@ new Vue({
7791
}).$start()
7892
```
7993

80-
This lets you use a shared element across different pages. For example, a `<SideDrawer>`:
94+
This lets you use a shared element across different pages.
95+
96+
**Example: Using a shared `<SideDrawer>` element**
8197

8298
```js
8399
new Vue({
@@ -94,39 +110,31 @@ new Vue({
94110
}).$start()
95111
```
96112

97-
In its simplest form, however, edit `main.js`'s Vue initialization block to resemble:
98-
99-
```js
100-
new Vue({
101-
render: h => h('frame', [h(HelloWorld)]),
102-
}).$start();
103-
```
104-
105113
## Step 5: Edit paths
106114

107115
Because the folder structure has changed, you need to edit the paths in your new app to point to your styles, fonts, and images.
108116

109-
**Example**
117+
**Example: Changing image references**
110118

111-
If you have images from your old app referenced like this:
119+
In your old app, you are likely to have referenced images like this.
112120

113121
```HTML
114122
<Image v-if="surprise" src="~/images/NativeScript-Vue.png"/>
115123
```
116124

117-
Change the path:
125+
To ensure that NativeScript loads the images, change the path reference to the following.
118126

119127
```HTML
120128
<Image v-if="surprise" src="~/assets/images/NativeScript-Vue.png"/>
121129
```
122130

123131
## (If needed) Step 6: Fix manual routing props
124132

125-
If your app uses manual routing, the syntax for passing props has changed.
133+
If your app uses manual routing, the syntax for passing props has changed. Note that this change might not be required in all projects.
126134

127-
Old syntax:
135+
Your old syntax is likely to look like this.
128136

129-
```js
137+
```JavaScript
130138
this.$navigateTo(NewPage, {
131139
transition: {},
132140
transitionIOS: {},
@@ -141,9 +149,9 @@ this.$navigateTo(NewPage, {
141149
});
142150
```
143151

144-
New syntax:
152+
To preserve the manual routing behavior in your new app, change your syntax to the following:
145153

146-
```js
154+
```JavaScript
147155
this.$navigateTo(NewPage, {
148156
transition: {},
149157
transitionIOS: {},
@@ -158,11 +166,13 @@ this.$navigateTo(NewPage, {
158166

159167
## Step 7: Align `package.json`
160168

161-
Copy the relevant values from your old app's root `package.json` file into the new app's root `package.json` file. This will most likely entail copying the `Dependencies:` block, but you might also need to realign the new app's app version and description at the top of `package.json`.
169+
Copy the relevant values from your old app's root `package.json` file into the new app's root `package.json` file.
170+
171+
You will likely need to copy the `Dependencies:` block and, in some cases, realign the new app's app version and description at the top of `package.json`.
162172

163173
## Step 8: Clean and run
164174

165-
At this point, it's a good idea to clean the new app's folders and reinstall any dependencies.
175+
Run the following command to clean the new app's folders and reinstall any dependencies.
166176

167177
```shell
168178
$ cd <project-name>
@@ -175,7 +185,9 @@ $ tns run ios --bundle
175185

176186
## (Optional) Step 8: Try HMR
177187

178-
Just recently NativeScript received support for HMR (Hot Module Replacement). The latest version of NativeScript-Vue supports it out-of-the-box but you will need to install the latest (and greatest) version of the NativeScript CLI.
188+
NativeScript now provides support for HMR (Hot Module Replacement). The latest version of NativeScript-Vue provides out-of-the-box HMR support as well but requires the NativeScript CLI.
189+
190+
Run the following command to get HMR support by installing the latest and greatest version of the NativeScript CLI.
179191

180192
```shell
181193
$ npm install -g nativescript@next

0 commit comments

Comments
 (0)