You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 17, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: docs/core-concepts/accessing-native-apis-with-javascript.md
-2Lines changed: 0 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -231,8 +231,6 @@ Steps to install and enable
231
231
232
232
> **Note:** Always install the plugin as a `devDependency` (`npm i tns-platform-declarations --save-dev` flag) to avoid bringing the enormously big declaration files in the output built file.
233
233
234
-
- As of version 3.0.0 of NativeScript the newly created projects are shipped without `reference.d.ts` file.
235
-
236
234
Create `reference.d.ts` in the root project directory and add the following:
Copy file name to clipboardExpand all lines: docs/core-concepts/android-runtime/advanced-topics/debug-android-runtime.md
-2Lines changed: 0 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -39,8 +39,6 @@ NativeScript with plain JavaScript:
39
39
40
40
`tns prepare android`
41
41
42
-
> After you have prepared the project, make sure the `tns-android` version is at least 3.4.0, because that's the version the Android Studio support is introduced. You can check the version by running `tns info` inside the project folder.
@@ -174,25 +173,16 @@ Here is an example of a basic main `package.json` file:
174
173
175
174
The `hooks` folder exists only when the project depends on plugins that require a hook to function properly. Hooks are executable pieces of code or Node.js scripts that are used to alter or augment the behavior of an extendable NativeScript CLI command. For more information about hooks and how to use them in NativeScript, see [Extending the CLI](https://github.com/NativeScript/nativescript-cli/blob/master/extending-cli.md).
176
175
177
-
Some of the more common plugins that have hooks are `nativescript-dev-webpack`, `nativescript-dev-typescript` and `nativescript-dev-sass`.
178
-
179
176
## The **tsconfig.json** File
180
177
181
178
The `tsconfig.json` file is present only in projects that use TypeScript. The file works as a guide during the [transpilation]({% slug transpilers %}) of TypeScript to JavaScript. You can fine-tune the transpilation process by configuring the various [compiler options](https://www.typescriptlang.org/docs/handbook/compiler-options.html). For more information about `tsconfig.json`, see the official [TypeScript documentation](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html).
182
179
183
180
## The **nsconfig.json** File
184
181
185
-
The `nsconfig.json` is an optional configuration file, located at the root project directory on the same level as the main `package.json` file. This file makes it possible for users to modify the structure of their application and to enable/disable the HMR developer experience. The available configurations are `appPath`, `appResourcesPath`, and `useLegacyWorkflow`.
182
+
The `nsconfig.json` is an optional configuration file, located at the root project directory on the same level as the main `package.json` file. This file makes it possible for users to modify the structure of their application and to enable/disable the HMR developer experience. The available configurations are `appPath`and `appResourcesPath`.
186
183
187
184
The paths (`appPath` and `appResourcesPath`) must be relative to the project root (where the `package.json` file and `platforms` directory are located) in order everything to work as expected. If `appPath` is omitted, the CLI will assume the application files are located inside a folder called {% nativescript %}`app`{% endnativescript %}{% angular %}`src`{% endangular%} inside the project folder. If `appResourcesPath` is omitted, the CLI will assume that they are at their default location - a folder called `App_Resources` inside the folder containing the rest of the app files.
188
185
189
-
> **Important:** To use an `nsconfig.json` file in your project, you must ensure that it meets the following requirements:
190
-
* NativeScript CLI >= 4.0.0
191
-
* The `useLegacyWorkflow` option requires NativeScript CLI >= 5.3.0
192
-
* Android Runtime >= 4.0.0
193
-
* nativescript-dev-sass >= 1.3.6 (if used in the application)
194
-
* nativescript-dev-webpack >= 0.10.1 (if used in the application)
195
-
196
186
### **nsconfig.json** Path examples
197
187
198
188
Let's assume the project is located at `/d/work/myApplication`.
@@ -220,12 +210,3 @@ Let's assume the project is located at `/d/work/myApplication`.
220
210
"appResourcesPath": "resources"
221
211
}
222
212
```
223
-
224
-
### **nsconfig.json** enabling HMR example
225
-
226
-
Enable the HMR developer experience by default. By setting `useLegacyWorkflow` to `false`, you will enable the HMR by default (no need to pass additional flags to have HMR). When omitted, the default value is `true` (default livesync experience without the enhanced HMR).
Copy file name to clipboardExpand all lines: docs/guides/integration-with-existing-ios-and-android-apps/extend-existing-android-app.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ This article will walk you through setting up an already existing Android Studio
32
32
33
33
2. You can either use the NativeScriptActivity which is part of the NativeScript framework or you can do the following if you want to override or add new functionality to the NativeScriptActivity:
34
34
1. Copy the corresponding MyNativeScriptActivity file (.ts or .js depending on your NativeScript application type) from [the following location](https://github.com/NativeScript/sample-extend-android-app/tree/master/common) to your NativeScript application **app** folder. Change the Android Activity referenced in JavaProxy to match that of your actual project.
35
-
2.If you are using webpack build add the MyNativeScriptActivity file to the **appComponents** array in your **webpack.config.js** file:
35
+
2.Add the MyNativeScriptActivity file to the **appComponents** array in your **webpack.config.js** file:
Copy file name to clipboardExpand all lines: docs/performance-optimizations/bundling-with-webpack.md
+27-19Lines changed: 27 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ Why bundle scripts in a mobile app though? Aren't all files stored on the local
16
16
* Smaller code size. Bundlers traverse the module import graph and do not bundle unused modules. Not using that obscure feature in module X? Don't make your users pay for it then.
17
17
* Tree-shaking. With the advent of ECMAScript 2015 modules, we have new tools that allow stripping unused parts of big modules and further reduce our application size.
18
18
19
-
NativeScript 6 and aboveis enabling Webpack by default.
19
+
With NativeScript 6 and above, Webpack is the primary developer workflow and can't be disabled.
* No iOS support. Heap snapshot is a V8 feature which is the engine used in the Android Runtime. Providing `--env.snapshot` flag on the iOS bundling commands will not affect.
143
-
* No Windows support. Providing `--env.snapshot` flag on the Android bundling command will not affect Windows machines.
144
-
* Only one Webpack bundle can be snapshotted. By default, this is the `vendor.js` chunk. It contains all external packages used by the application.
143
+
144
+
145
+
<h3id="snapshot-per-architecture">V8 Heap Snapshot per architecture</h3>
146
+
147
+
The Android app size can be reduced by splitting the app per device architecture. However, the `blob` files generated by the `--env.snapshot` are just assets which cannot be split.
148
+
149
+
In order to get a maximum app size reduction, you can to pass an additional `--env.compileSnapshot` flag which compiles the static assets produced by `--env.snapshot` into `.so` files allowing the native build to split them per architecture. The snapshot compilation requires the Android NDK installed on your system. It is strongly recommended that the same version of the NDK is used to produce the snapshot file as the one used to compile the {N} runtime itself. The current NDK version used in the runtime can be found in [it's settings.json file](https://github.com/NativeScript/android-runtime/blob/master/build-artifacts/project-template-gradle/settings.json#L3).
150
+
151
+
> **NOTE**: Read more about reducing the Android app size in the [Android App Bundle article]({% slug android-app-bundle %})
145
152
146
153
#### NativeScriptSnapshotPlugin configuration
147
154
148
155
The `NativeScriptSnapshotPlugin` by default comes with the following configuration:
useLibs:true, // set to true to produce *.so and to false (default) to produce *.blob
159
-
targetArchs: ["arm64", "arm"]
160
-
projectRoot,
161
-
webpackConfig: config,
162
-
}));
164
+
projectRoot,
165
+
webpackConfig: config,
166
+
snapshotInDocker,
167
+
skipSnapshotTools,
168
+
useLibs
169
+
}));
163
170
}
164
171
```
165
172
@@ -168,15 +175,16 @@ if (snapshot) {
168
175
*`projectRoot` - path to the app root folder.
169
176
*`webpackConfig` - Webpack configurations object. The snapshot generation modifies the Webpack config object to ensure that the specified bundle will be snapshotted successfully.
170
177
171
-
#### Other options:
172
-
*`targetArchs` - Since the serialization format of the V8 heap is architecture-specific, we need a different blob file for each V8 library target architecture. The Android Runtime library contains 3 architecture slices - `ia32` (for emulators), `arm` and `arm64` (for devices). However, [if not explicitly specified](https://github.com/NativeScript/android-runtime/issues/614), the `arm` slice is used even on `arm64` devices. In other words, generating a heap snapshot for all supported architectures (`arm`, `arm64`, `ia32`) will guarantee that the snapshotted heap is available on every device/emulator. However, when building for the release, you can leave only `arm`and `arm64` in the `targetArchs` array, which decreases the size of the produced APK file.
173
-
*`v8Version` - Specify the v8 engine version that should be used. By default, the value is determined based on the Android runtime version that the project is using.
*`targetArchs` - Since the serialization format of the V8 heap is architecture-specific, we need a different blob file for each V8 library target architecture. The Android Runtime library contains 4 architecture slices - `ia32` (`x86`), `ia64` (`x86_64`), `arm` (`armeabi-v7a`) and `arm64` (`arm64-v8a`).
180
+
181
+
#### Snapshot compilation options:
182
+
*`useLibs` - the option is configurable through `--env.compileSnapshot` and compiles the static assets produced by `--env.snapshot` into `.so` files allowing the native build to split them per architecture. This will reduce the app size when using the `--aab` option.
183
+
*`androidNdkPath` - Path to a local installation of Android NDK. If not set, the plugin is looking for it in ANDROID_NDK_HOME, the global PATH or downloaded from Android Studio.
*`useLibs` - Instructs the plugin to produce `.so` instead of `.blob` files.
177
-
*`androidNdkPath` - Path to a local installation of Android NDK.
185
+
> **Note:** The snapshot compilation is the recommended way of reducing the app size along with the [Android App bundle](../tooling/publishing/android-app-bundle.md).
178
186
179
-
#### Checking if the snapshot is enabled
187
+
#### Advanced debugging - checking if the snapshot is enabled
180
188
If you want to toggle whether specific logic is executed only in the snapshotted context you can use the `global.__snapshot` flag. Its value is `true` only if the current execution happens in the snapshotted context. Once the app is deployed on the device, the value of the flag is changed to `false`. There is also `global.__snapshotEnabled` flag. Its only difference compared to `global.__snapshot` is that its value is `true` in both snapshotted and runtime contexts, given that snapshot generation is enabled.
181
189
182
190
```JavaScript
@@ -254,7 +262,7 @@ The TypeScript compiler implements class inheritance, decorators and other featu
254
262
## Bundling Background Workers
255
263
256
264
When the application is implementing workers, some additional steps are required to make the project Webpack compatible.
257
-
Check out the [`nativescript-worker-loader`](https://github.com/nativescript/worker-loader) and the [detailed documentation article about using workers](./core-concepts/multithreading-model).
265
+
Check out the [`nativescript-worker-loader`](https://github.com/nativescript/worker-loader) and the [detailed documentation article about using workers](../core-concepts/multithreading-model).
0 commit comments