refactor: HMR and webpack improvements (#7462)

* chore: update project

* refactor: clear module-name cache on orientation

* feat: add custom component in qualifiers app

* feat: enable HMR for custom components

* refactor: remove redundant check

* chore: clean console.log
This commit is contained in:
Alexander Vakrilov
2019-07-08 11:11:14 +03:00
committed by GitHub
parent d8ef044469
commit 8756b3da16
77 changed files with 349 additions and 168 deletions

View File

@@ -2,15 +2,19 @@
// Uncomment to add recyclerview-v7 dependency
//dependencies {
// compile 'com.android.support:recyclerview-v7:+'
// implementation 'com.android.support:recyclerview-v7:+'
//}
android {
defaultConfig {
// If you want to add something to be applied before applying plugins' include.gradle files
// e.g. project.ext.googlePlayServicesVersion = "15.0.1"
// create a file named before-plugins.gradle in the current directory and place it there
android {
defaultConfig {
minSdkVersion 17
generatedDensities = []
applicationId = "org.nativescript.animation"
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}

View File

@@ -10,10 +10,6 @@
android:largeScreens="true"
android:xlargeScreens="true"/>
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="__APILEVEL__"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
@@ -28,7 +24,7 @@
<activity
android:name="com.tns.NativeScriptActivity"
android:label="@string/title_activity_kimera"
android:configChanges="keyboardHidden|orientation|screenSize"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|locale|uiMode"
android:theme="@style/LaunchScreenTheme">
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 915 B

View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 669 B

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 116 KiB

After

Width:  |  Height:  |  Size: 116 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 74 KiB

View File

Before

Width:  |  Height:  |  Size: 193 KiB

After

Width:  |  Height:  |  Size: 193 KiB

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">TestApp</string>
<string name="title_activity_kimera">TestApp</string>
</resources>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="."/>
</paths>

View File

@@ -1,5 +1,4 @@
.root-footer {
horizontal-align: middle;
color: black;
background-color: lightgreen
}

View File

@@ -1,5 +1,4 @@
.root-footer {
horizontal-align: middle;
color: black;
background-color: lightpink;
}

View File

@@ -1,3 +1,7 @@
import * as application from "tns-core-modules/application";
import { setCategories, categories, enable } from "tns-core-modules/trace";
setCategories(categories.Livesync);
enable();
application.run({ moduleName: "app-root" });

View File

@@ -0,0 +1,5 @@
.custom-component {
color: navy;
font-weight: bold;
font-size: 20;
}

View File

@@ -0,0 +1,5 @@
.custom-component {
color: darkolivegreen;
font-weight: bold;
font-size: 20;
}

View File

@@ -0,0 +1,3 @@
export function onLoaded() {
console.log("---> Custom component LANDSCAPE loaded");
}

View File

@@ -0,0 +1,3 @@
<StackLayout class="p-20" loaded="onLoaded">
<Label text="CUSTOM COMPONENT - LANDSCAPE" class="custom-component" />
</StackLayout>

View File

@@ -0,0 +1,3 @@
export function onLoaded() {
console.log("---> Custom component DEFAULT loaded");
}

View File

@@ -0,0 +1,3 @@
<StackLayout class="p-20" loaded="onLoaded">
<Label text="CUSTOM COMPONENT - DEFAULT" class="custom-component" />
</StackLayout>

View File

@@ -0,0 +1,3 @@
import { fromObject } from "tns-core-modules/data/observable";
export const vm = fromObject({ prop: "property from VM" });

View File

@@ -1,7 +1,17 @@
export function onNavigatedTo(args) {
console.log("---> [LANDSCAPE] onNavigatedTo");
import { topmost } from "tns-core-modules/ui/frame";
import { vm } from "./main-page-vm";
export function onNavigatingTo(args) {
console.log("---> [LANDSCAPE] onNavigatingTo");
args.object.page.bindingContext = vm;
}
export function tap(args) {
console.log("---> [LANDSCAPE] tap");
}
export function navigate(args) {
console.log("---> [LANDSCAPE] navigate");
}
topmost().navigate("other/other-page");
}

View File

@@ -1,7 +1,13 @@
<Page navigatedTo="onNavigatedTo">
<Page navigatingTo="onNavigatingTo" xmlns:cc="components">
<StackLayout class="page-content">
<Label text="This is LANDSACPE page" />
<Button text="hey there" tap="navigate" />
<Button text="tap" tap="tap" />
<Button text="navigate" tap="navigate" />
<Label text="{{ prop }}" />
<cc:my-component />
</StackLayout>
</Page>

View File

@@ -1,7 +1,17 @@
export function onNavigatedTo(args) {
console.log("---> [DEFAULT] onNavigatedTo");
import { topmost } from "tns-core-modules/ui/frame";
import { vm } from "./main-page-vm";
export function onNavigatingTo(args) {
console.log("---> [DEFAULT] onNavigatingTo");
args.object.page.bindingContext = vm;
}
export function tap(args) {
console.log("---> [DEFAULT] tap");
}
export function navigate(args) {
console.log("---> [DEFAULT] navigate");
topmost().navigate("other/other-page");
}

View File

@@ -1,7 +1,13 @@
<Page navigatedTo="onNavigatedTo">
<Page navigatingTo="onNavigatingTo" xmlns:cc="components">
<StackLayout class="page-content">
<Label text="This is DEFAULT page" />
<Button text="hey there" tap="navigate" />
<Button text="tap" tap="tap" />
<Button text="navigate" tap="navigate" />
<Label text="{{ prop }}" />
<cc:my-component />
</StackLayout>
</Page>

View File

@@ -0,0 +1,4 @@
.page-content {
padding: 20;
background-color: lightblue;
}

View File

@@ -0,0 +1,4 @@
.page-content {
padding: 20;
background-color: lightcoral;
}

View File

@@ -0,0 +1,15 @@
import { topmost } from "tns-core-modules/ui/frame";
export function onNavigatedTo(args) {
console.log("---> [LANDSCAPE other] onNavigatedTo");
}
export function tap(args) {
console.log("---> [LANDSCAPE other] tap");
}
export function navigate(args) {
console.log("---> [LANDSCAPE other] navigate");
topmost().navigate("main/main-page");
}

View File

@@ -0,0 +1,12 @@
<Page navigatedTo="onNavigatedTo" xmlns:cc="components">
<StackLayout class="page-content">
<Label text="This is LANDSACPE other page" />
<Button text="tap" tap="tap" />
<Button text="navigate" tap="navigate" />
<cc:my-component />
</StackLayout>
</Page>

View File

@@ -0,0 +1,15 @@
import { topmost } from "tns-core-modules/ui/frame";
export function onNavigatedTo(args) {
console.log("---> [DEFAULT other] onNavigatedTo");
}
export function tap(args) {
console.log("---> [DEFAULT other] tap");
}
export function navigate(args) {
console.log("---> [DEFAULT other] navigate");
topmost().navigate("main/main-page");
}

View File

@@ -0,0 +1,11 @@
<Page navigatedTo="onNavigatedTo" xmlns:cc="components">
<StackLayout class="page-content">
<Label text="This is DEFAULT other page" />
<Button text="tap" tap="tap" />
<Button text="navigate" tap="navigate" />
<cc:my-component />
</StackLayout>
</Page>

View File

@@ -2,7 +2,5 @@
"android": {
"v8Flags": "--expose_gc"
},
"main": "app.js",
"name": "tns-template-hello-world-ts",
"version": "3.4.0"
"main": "app.js"
}

View File

@@ -179,25 +179,14 @@ module.exports = env => {
unitTesting,
appFullPath,
projectRoot,
registerModules: /(root|page|app)(\.(land|port|phone|tablet|minH\d+|minW\d+|minWH\d+))?\.(xml|css|js|ts|scss)$/ // NB: MODIFIED
}
},
].filter(loader => !!loader)
},
{
test: /(page|app)(\.(land|port|phone|tablet|minH\d+|minW\d+|minWH\d+))?\.ts$/,
use: "nativescript-dev-webpack/script-hot-loader"
},
{
test: /\.(css|scss)$/,
use: "nativescript-dev-webpack/style-hot-loader"
},
{
test: /\.(html|xml)$/,
use: "nativescript-dev-webpack/markup-hot-loader"
test: /\.(ts|css|scss|less|html|xml)$/,
use: "nativescript-dev-webpack/hmr/hot-loader"
},
{ test: /\.(html|xml)$/, use: "nativescript-dev-webpack/xml-namespace-loader" },