From 7a7718fdb5f9e21ada6d5c68fda1be229796af84 Mon Sep 17 00:00:00 2001 From: sis0k0 Date: Fri, 19 May 2017 17:17:36 +0300 Subject: [PATCH 1/2] chore: update webpack deps --- package.json | 4 +- tsconfig.json | 2 +- webpack.config.js | 190 ++++++++++++++++++++++++++++++++++++++++++++++ yarn.lock | 34 ++++----- 4 files changed, 210 insertions(+), 20 deletions(-) create mode 100644 webpack.config.js diff --git a/package.json b/package.json index 4eadfd1..aa613c1 100644 --- a/package.json +++ b/package.json @@ -39,11 +39,11 @@ "lazy": "1.0.11", "nativescript-css-loader": "~0.26.0", "nativescript-dev-typescript": "~0.4.2", - "nativescript-dev-webpack": "^0.4.1", + "nativescript-dev-webpack": "^0.5.0", "raw-loader": "~0.5.1", "resolve-url-loader": "~2.0.2", "typescript": "~2.3.2", - "webpack": "~2.4.1", + "webpack": "~2.5.1", "webpack-sources": "~0.2.3" }, "scripts": { diff --git a/tsconfig.json b/tsconfig.json index 8c73e88..17700d5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -24,4 +24,4 @@ "platforms", "**/*.aot.ts" ] -} +} \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..865f0c2 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,190 @@ +const { resolve, join } = require("path"); + +const webpack = require("webpack"); +const nsWebpack = require("nativescript-dev-webpack"); +const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target"); +const CopyWebpackPlugin = require("copy-webpack-plugin"); +const ExtractTextPlugin = require("extract-text-webpack-plugin"); + +const { AotPlugin } = require("@ngtools/webpack"); + +const mainSheet = `app.css`; + +module.exports = env => { + const platform = getPlatform(env); + + // Default destination inside platforms//... + const path = resolve(nsWebpack.getAppPath(platform)); + + const entry = { + // Discover entry module from package.json + bundle: `./${nsWebpack.getEntryModule()}`, + + // Vendor entry with third-party libraries + vendor: `./vendor`, + + // Entry for stylesheet with global application styles + [mainSheet]: `./${mainSheet}`, + }; + + const rules = getRules(); + const plugins = getPlugins(platform, env); + const extensions = getExtensions(platform); + + return { + context: resolve("./app"), + target: nativescriptTarget, + entry, + output: { + pathinfo: true, + path, + libraryTarget: "commonjs2", + filename: "[name].js", + }, + resolve: { + extensions, + + // Resolve {N} system modules from tns-core-modules + modules: [ + "node_modules/tns-core-modules", + "node_modules", + ] + }, + node: { + // Disable node shims that conflict with NativeScript + "http": false, + "timers": false, + "setImmediate": false, + "fs": "empty", + }, + module: { rules }, + plugins, + }; +}; + + +function getPlatform(env) { + return env.android ? "android" : + env.ios ? "ios" : + () => { throw new Error("You need to provide a target platform!") }; +} + +function getRules() { + return [ + { + test: /\.html$|\.xml$/, + use: [ + "raw-loader", + ] + }, + // Root stylesheet gets extracted with bundled dependencies + { + test: new RegExp(mainSheet), + use: ExtractTextPlugin.extract([ + { + loader: "resolve-url-loader", + options: { silent: true }, + }, + "nativescript-css-loader", + "nativescript-dev-webpack/platform-css-loader", + ]), + }, + // Other CSS files get bundled using the raw loader + { + test: /\.css$/, + exclude: new RegExp(mainSheet), + use: [ + "raw-loader", + ] + }, + // SASS support + { + test: /\.scss$/, + use: [ + "raw-loader", + "resolve-url-loader", + "sass-loader", + ] + }, + + + // Compile TypeScript files with ahead-of-time compiler. + { + test: /\.ts$/, + loaders: [ + "nativescript-dev-webpack/tns-aot-loader", + "@ngtools/webpack", + ] + } + + ]; +} + +function getPlugins(platform, env) { + let plugins = [ + new ExtractTextPlugin(mainSheet), + + // Vendor libs go to the vendor.js chunk + new webpack.optimize.CommonsChunkPlugin({ + name: ["vendor"], + }), + + // Define useful constants like TNS_WEBPACK + new webpack.DefinePlugin({ + "global.TNS_WEBPACK": "true", + }), + + // Copy assets to out dir. Add your own globs as needed. + new CopyWebpackPlugin([ + { from: mainSheet }, + { from: "css/**" }, + { from: "fonts/**" }, + { from: "**/*.jpg" }, + { from: "**/*.png" }, + { from: "**/*.xml" }, + ], { ignore: ["App_Resources/**"] }), + + // Generate a bundle starter script and activate it in package.json + new nsWebpack.GenerateBundleStarterPlugin([ + "./vendor", + "./bundle", + ]), + + // Angular AOT compiler + new AotPlugin({ + tsConfigPath: "tsconfig.aot.json", + entryModule: resolve(__dirname, "app/app.module#AppModule"), + typeChecking: false + }), + + // Resolve .ios.css and .android.css component stylesheets + new nsWebpack.StyleUrlResolvePlugin({platform}), + + ]; + + if (env.uglify) { + plugins.push(new webpack.LoaderOptionsPlugin({ minimize: true })); + + // Work around an Android issue by setting compress = false + const compress = platform !== "android"; + plugins.push(new webpack.optimize.UglifyJsPlugin({ + mangle: { except: nsWebpack.uglifyMangleExcludes }, + compress, + })); + } + + return plugins; +} + +// Resolve platform-specific modules like module.android.js +function getExtensions(platform) { + return Object.freeze([ + `.${platform}.ts`, + `.${platform}.js`, + ".aot.ts", + ".ts", + ".js", + ".css", + `.${platform}.css`, + ]); +} diff --git a/yarn.lock b/yarn.lock index 46ef9b2..2e4be4f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1614,9 +1614,9 @@ nan@^2.3.0: version "2.6.2" resolved "https://registry.yarnpkg.com/nan/-/nan-2.6.2.tgz#e4ff34e6c95fdfb5aecc08de6596f43605a7db45" -nativescript-angular@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/nativescript-angular/-/nativescript-angular-3.0.0.tgz#401c5eae895c22a44010c16f443910d2aa5af6ee" +nativescript-angular@next: + version "3.1.0-2017-05-10-1537" + resolved "https://registry.yarnpkg.com/nativescript-angular/-/nativescript-angular-3.1.0-2017-05-10-1537.tgz#ca40b1fbb2f5029960184db686b09815f40b24fb" dependencies: nativescript-intl "^3.0.0" reflect-metadata "^0.1.8" @@ -1644,9 +1644,9 @@ nativescript-dev-typescript@~0.4.2: dependencies: nativescript-hook "^0.2.0" -nativescript-dev-webpack@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/nativescript-dev-webpack/-/nativescript-dev-webpack-0.4.1.tgz#be1a96a866be21d245c1d7d8b2a3c23c4f08936f" +nativescript-dev-webpack@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/nativescript-dev-webpack/-/nativescript-dev-webpack-0.5.0.tgz#b439853be73f0776ff1b60b883dee4afbda551cd" nativescript-hook@^0.2.0: version "0.2.1" @@ -2628,15 +2628,15 @@ timers-browserify@^2.0.2: dependencies: setimmediate "^1.0.4" -tns-core-modules-widgets@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/tns-core-modules-widgets/-/tns-core-modules-widgets-3.0.0.tgz#503c762819c936ce51e0b6025c776ae42a4500fb" +tns-core-modules-widgets@next: + version "3.1.0-2017-05-17-291" + resolved "https://registry.yarnpkg.com/tns-core-modules-widgets/-/tns-core-modules-widgets-3.1.0-2017-05-17-291.tgz#d3d6df5c75b58ba4b8737aa4ee47ae7375fd26d3" -tns-core-modules@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/tns-core-modules/-/tns-core-modules-3.0.0.tgz#be0a538d3924a48320e9a875a1d351c664a3c9ab" +tns-core-modules@next: + version "3.1.0-2017-05-19-6648" + resolved "https://registry.yarnpkg.com/tns-core-modules/-/tns-core-modules-3.1.0-2017-05-19-6648.tgz#ce49b16419cb5695f7854a1a4d1ec6b7632002e5" dependencies: - tns-core-modules-widgets "3.0.0" + tns-core-modules-widgets next to-arraybuffer@^1.0.0: version "1.0.1" @@ -2675,7 +2675,7 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5" resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" -typescript@~2.3.1: +typescript@~2.3.2: version "2.3.2" resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.3.2.tgz#f0f045e196f69a72f06b25fd3bd39d01c3ce9984" @@ -2784,9 +2784,9 @@ webpack-sources@^0.2.3, webpack-sources@~0.2.3: source-list-map "^1.1.1" source-map "~0.5.3" -webpack@~2.4.1: - version "2.4.1" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-2.4.1.tgz#15a91dbe34966d8a4b99c7d656efd92a2e5a6f6a" +webpack@~2.5.1: + version "2.5.1" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-2.5.1.tgz#61742f0cf8af555b87460a9cd8bba2f1e3ee2fce" dependencies: acorn "^5.0.0" acorn-dynamic-import "^2.0.0" From 44892f1c27c526dbefce7dc85e2dd59464e66880 Mon Sep 17 00:00:00 2001 From: sis0k0 Date: Fri, 19 May 2017 17:39:47 +0300 Subject: [PATCH 2/2] feat: add lazy loaded modal and lazy routing tests --- app/app.css | 5 +- app/app.module.ts | 9 +- app/app.routes.ts | 22 ++- app/lazy/lazy.component.html | 18 ++ app/lazy/lazy.component.ts | 30 ++++ app/lazy/lazy.module.ts | 39 +++++ app/main/main-page-router-outlet.ts | 2 +- app/modal/lazy/lazy-load-modal.component.ts | 38 +++++ app/modal/modal-view-main-page.ts | 1 + .../lazy-navigation.component.ts | 7 + .../router-outlet}/first.component.ts | 0 .../navigation.component.css} | 0 .../navigation.component.ts} | 18 +- .../router-outlet}/second.component.ts | 0 app/vendor-platform.android.ts | 22 --- package.json | 3 +- webpack.android.js | 2 - webpack.common.js | 158 ------------------ webpack.ios.js | 2 - yarn.lock | 4 + 20 files changed, 178 insertions(+), 202 deletions(-) create mode 100644 app/lazy/lazy.component.html create mode 100644 app/lazy/lazy.component.ts create mode 100644 app/lazy/lazy.module.ts create mode 100644 app/modal/lazy/lazy-load-modal.component.ts create mode 100644 app/router/lazy-module-navigation/lazy-navigation.component.ts rename app/{components => router/router-outlet}/first.component.ts (100%) rename app/router/{router-outlet.css => router-outlet/navigation.component.css} (100%) rename app/router/{router-outlet.ts => router-outlet/navigation.component.ts} (51%) rename app/{components => router/router-outlet}/second.component.ts (100%) delete mode 100644 webpack.android.js delete mode 100644 webpack.common.js delete mode 100644 webpack.ios.js diff --git a/app/app.css b/app/app.css index 9cff34a..a78a644 100644 --- a/app/app.css +++ b/app/app.css @@ -1,4 +1,6 @@ -button { +@import '~/nativescript-theme-core/css/core.light.css'; + +button { font-size: 13; } @@ -10,3 +12,4 @@ label { font-family: 'Courier'; /* Enabling this results in the error and shows a blank TabView */ } + diff --git a/app/app.module.ts b/app/app.module.ts index f8eb715..d369fbe 100644 --- a/app/app.module.ts +++ b/app/app.module.ts @@ -1,5 +1,6 @@ -import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core"; +import { NgModule, NgModuleFactoryLoader, NO_ERRORS_SCHEMA } from "@angular/core"; import { NativeScriptModule } from "nativescript-angular/nativescript.module"; +import { NSModuleFactoryLoader } from "nativescript-angular/router"; import { NavigationMainPageRouter } from "./main/main-page-router-outlet"; import { routableComponents, routes } from "./app.routes"; @@ -22,6 +23,12 @@ import { CustomTemplate } from "./list-view/list-view-item-template"; NativeScriptRouterModule, NativeScriptRouterModule.forRoot(routes), ], + providers: [ + { + provide: NgModuleFactoryLoader, + useClass: NSModuleFactoryLoader + } + ], schemas: [NO_ERRORS_SCHEMA], }) export class AppModule { } diff --git a/app/app.routes.ts b/app/app.routes.ts index 4c4797b..079dbf6 100644 --- a/app/app.routes.ts +++ b/app/app.routes.ts @@ -5,9 +5,10 @@ import { SecondComponentActionBar } from "./action-bar/action-bar-second.compone import { AppComponent } from "./template/app.component"; -import { FirstComponent } from "./components/first.component"; -import { SecondComponent } from "./components/second.component"; -import { NavigationTestRouter, NavigationSubRoutes } from "./router/router-outlet"; +import { FirstComponent } from "./router/router-outlet/first.component"; +import { SecondComponent } from "./router/router-outlet/second.component"; +import { NavigationComponent, NavigationSubRoutes } from "./router/router-outlet/navigation.component"; +import { LazyNavigationComponent } from "./router/lazy-module-navigation/lazy-navigation.component"; import { BindingComponent } from "./binding/binding-page"; @@ -22,6 +23,7 @@ import { ListPickerComponent } from "./list-picker/list-picker"; import { ModalTest, ModalTestWithPushStrategy, ModalContent } from "./modal/modal-dialogs/modal-dialog.component"; import { ModalViewMainPageComponent } from "./modal/modal-view-main-page"; +import { LazyLoadModalComponent } from "./modal/lazy/lazy-load-modal.component"; import { TabViewComponent } from "./tab-view/tab-view.component"; @@ -34,7 +36,8 @@ export const routableComponents = [ ModalContent, AppComponent, - NavigationTestRouter, + NavigationComponent, + LazyNavigationComponent, FirstComponent, SecondComponent, @@ -56,6 +59,7 @@ export const routableComponents = [ ModalViewMainPageComponent, ModalTest, ModalTestWithPushStrategy, + LazyLoadModalComponent, TabViewComponent, @@ -69,7 +73,8 @@ export const routes = [ { path: '', component: ModalContent, data: { title: "" } }, { path: 'template', component: AppComponent, data: { title: "Template", isNavigatable: true} }, - { path: 'router', component: NavigationTestRouter, children: NavigationSubRoutes, data: { title: "Router", isNavigatable: true} }, + { path: 'router', component: NavigationComponent, children: NavigationSubRoutes, data: { title: "Router", isNavigatable: true} }, + { path: 'lazy-router', component: LazyNavigationComponent, data: { title: "Lazy Router", isNavigatable: true} }, { path: 'first', component: FirstComponent, data: { title: "First", isNavigatable: true} }, { path: 'second', component: SecondComponent, data: { title: "Second", isNavigatable: true} }, @@ -91,10 +96,17 @@ export const routes = [ { path: 'modal', component: ModalViewMainPageComponent, data: { title: "Modals", isNavigatable: true} }, { path: 'modal/modal-dialogs', component: ModalTest, data: { title: "modal" } }, { path: 'modal/modal-dialogs-push', component: ModalTestWithPushStrategy, data: { title: "modal(onPush)" } }, + { path: 'modal/lazy', component: LazyLoadModalComponent, data: { title: "modal(lazy)" } }, { path: 'tab-view', component: TabViewComponent, data: { title: "tab-view", isNavigatable: true } }, { path: 'nav-options', component: NavigationOptionsComponent, data: { title: "nav-options", isNavigatable: true} }, { path: 'nav-info', component: NavigationInfoComponent, data: { title: "nav-info" } }, + + // Needed for AoT compilation + { + path: "lazy", + loadChildren: "./lazy/lazy.module#LazyModule" + }, ]; diff --git a/app/lazy/lazy.component.html b/app/lazy/lazy.component.html new file mode 100644 index 0000000..6ffd7d2 --- /dev/null +++ b/app/lazy/lazy.component.html @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/app/lazy/lazy.component.ts b/app/lazy/lazy.component.ts new file mode 100644 index 0000000..da62e7b --- /dev/null +++ b/app/lazy/lazy.component.ts @@ -0,0 +1,30 @@ +import { Component } from "@angular/core"; + +import { RouterExtensions } from "nativescript-angular/router"; +import { ModalDialogParams } from "nativescript-angular/directives/dialogs"; + +@Component({ + selector: "ns-lazy", + moduleId: module.id, + templateUrl: "./lazy.component.html", +}) +export class LazyComponent { + public isModal: boolean; + + constructor( + private router: RouterExtensions, + private params: ModalDialogParams + ) { + if (params.context.isModal) { + this.isModal = true; + } + } + + public close() { + if (this.isModal) { + this.params.closeCallback(); + } else { + this.router.back(); + } + } +} diff --git a/app/lazy/lazy.module.ts b/app/lazy/lazy.module.ts new file mode 100644 index 0000000..5f08f6a --- /dev/null +++ b/app/lazy/lazy.module.ts @@ -0,0 +1,39 @@ +import { NativeScriptModule } from "nativescript-angular/nativescript.module"; +import { NativeScriptRouterModule } from "nativescript-angular/router"; +import { ModalDialogParams } from "nativescript-angular/directives/dialogs"; + +import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core"; +import { Routes } from "@angular/router"; + +import { LazyComponent } from "./lazy.component"; + +export function modalParamsFactory() { + return new ModalDialogParams({}, null); +} + +const routes: Routes = [ + { + path: "", + component: LazyComponent + } +]; + +@NgModule({ + imports: [ + NativeScriptModule, + NativeScriptRouterModule.forChild(routes), + ], + declarations: [ + LazyComponent + ], + entryComponents: [ + LazyComponent + ], + providers: [ + // allows same component to be routed to + // or lazily loaded via modal + { provide: ModalDialogParams, useFactory: modalParamsFactory } + ], + schemas: [NO_ERRORS_SCHEMA] +}) +export class LazyModule { } diff --git a/app/main/main-page-router-outlet.ts b/app/main/main-page-router-outlet.ts index 75ed2d0..15ef158 100644 --- a/app/main/main-page-router-outlet.ts +++ b/app/main/main-page-router-outlet.ts @@ -16,7 +16,7 @@ export class MainComponent { constructor() { let navigatableRoutes = this._routes.filter((item) => { - return item.data.isNavigatable == true && item.path != ''; + return item.data && item.data.isNavigatable && item.path; }); this._pages = navigatableRoutes; diff --git a/app/modal/lazy/lazy-load-modal.component.ts b/app/modal/lazy/lazy-load-modal.component.ts new file mode 100644 index 0000000..2c07a4d --- /dev/null +++ b/app/modal/lazy/lazy-load-modal.component.ts @@ -0,0 +1,38 @@ +import { + Component, + ComponentFactory, + NgModuleFactory, + NgModuleFactoryLoader, + ViewContainerRef, +} from "@angular/core"; + +import { NSModuleFactoryLoader } from "nativescript-angular/router"; +import { ModalDialogService } from "nativescript-angular/directives/dialogs"; + +import { LazyComponent } from "../../lazy/lazy.component"; + +@Component({ + template: ` + + ` +}) +export class LazyLoadModalComponent { + constructor( + private moduleLoader: NgModuleFactoryLoader, + private vcRef: ViewContainerRef, + private modalService: ModalDialogService + ) { } + + public openModal() { + this.moduleLoader.load('./lazy/lazy.module#LazyModule') + .then((module: NgModuleFactory) => { + const moduleRef = module.create(this.vcRef.parentInjector); + + this.modalService.showModal(LazyComponent, { + moduleRef, + viewContainerRef: this.vcRef, + context: { isModal: true } + }); + }); + } +} diff --git a/app/modal/modal-view-main-page.ts b/app/modal/modal-view-main-page.ts index 752bf43..824669c 100644 --- a/app/modal/modal-view-main-page.ts +++ b/app/modal/modal-view-main-page.ts @@ -6,6 +6,7 @@ import { Component } from "@angular/core"; + `, }) diff --git a/app/router/lazy-module-navigation/lazy-navigation.component.ts b/app/router/lazy-module-navigation/lazy-navigation.component.ts new file mode 100644 index 0000000..dde3378 --- /dev/null +++ b/app/router/lazy-module-navigation/lazy-navigation.component.ts @@ -0,0 +1,7 @@ +import { Component } from "@angular/core"; + +@Component({ + template: ``, +}) +export class LazyNavigationComponent { +} diff --git a/app/components/first.component.ts b/app/router/router-outlet/first.component.ts similarity index 100% rename from app/components/first.component.ts rename to app/router/router-outlet/first.component.ts diff --git a/app/router/router-outlet.css b/app/router/router-outlet/navigation.component.css similarity index 100% rename from app/router/router-outlet.css rename to app/router/router-outlet/navigation.component.css diff --git a/app/router/router-outlet.ts b/app/router/router-outlet/navigation.component.ts similarity index 51% rename from app/router/router-outlet.ts rename to app/router/router-outlet/navigation.component.ts index 457aca6..8dde663 100644 --- a/app/router/router-outlet.ts +++ b/app/router/router-outlet/navigation.component.ts @@ -1,11 +1,11 @@ -import {Component} from "@angular/core"; -import {FirstComponent} from "../components/first.component"; -import {SecondComponent} from "../components/second.component"; +import { Component } from "@angular/core"; +import { FirstComponent } from "./first.component"; +import { SecondComponent } from "./second.component"; @Component({ moduleId: module.id, - selector: 'navigation-test', - styleUrls: ['./router-outlet.css'], + selector: "navigation-test", + styleUrls: ["./navigation.component.css"], template: ` @@ -19,10 +19,10 @@ import {SecondComponent} from "../components/second.component"; ` }) -export class NavigationTestRouter { } +export class NavigationComponent { } export var NavigationSubRoutes = [ - { path: '', redirectTo: 'first', pathMatch: "full" }, - { path: 'first', component: FirstComponent }, - { path: 'second', component: SecondComponent }, + { path: "", redirectTo: "first", pathMatch: "full" }, + { path: "first", component: FirstComponent }, + { path: "second", component: SecondComponent }, ]; diff --git a/app/components/second.component.ts b/app/router/router-outlet/second.component.ts similarity index 100% rename from app/components/second.component.ts rename to app/router/router-outlet/second.component.ts diff --git a/app/vendor-platform.android.ts b/app/vendor-platform.android.ts index ba9742f..6fb10f0 100644 --- a/app/vendor-platform.android.ts +++ b/app/vendor-platform.android.ts @@ -1,25 +1,3 @@ -// Resolve JavaScript classes that extend a Java class, and need to resolve -// their JavaScript module from a bundled script. For example: -// NativeScriptApplication, NativeScriptActivity, etc. -// -// This module gets bundled together with the rest of the app code and the -// `require` calls get resolved to the correct bundling import call. -// -// At runtime the module gets loaded *before* the rest of the app code, so code -// placed here needs to be careful about its dependencies. - require("application"); require("ui/frame"); require("ui/frame/activity"); - -if (global.TNS_WEBPACK) { - global.__requireOverride = function (name, dir) { - if (name === "./tns_modules/application/application.js") { - return require("application"); - } else if (name === "./tns_modules/ui/frame/frame.js") { - return require("ui/frame"); - } else if (name === "./tns_modules/ui/frame/activity.js") { - return require("ui/frame/activity"); - } - }; -} diff --git a/package.json b/package.json index aa613c1..a076f4e 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "@angular/router": "~4.1.0", "nativescript-angular": "next", "nativescript-intl": "~3.0.0", + "nativescript-theme-core": "^1.0.4", "reflect-metadata": "~0.1.8", "rxjs": "^5.0.1", "tns-core-modules": "next", @@ -53,4 +54,4 @@ "build-android-bundle": "npm run ns-bundle --android --build-app", "build-ios-bundle": "npm run ns-bundle --ios --build-app" } -} +} \ No newline at end of file diff --git a/webpack.android.js b/webpack.android.js deleted file mode 100644 index 968e93b..0000000 --- a/webpack.android.js +++ /dev/null @@ -1,2 +0,0 @@ -var makeConfig = require("./webpack.common"); -module.exports = makeConfig("android"); diff --git a/webpack.common.js b/webpack.common.js deleted file mode 100644 index b9da5d8..0000000 --- a/webpack.common.js +++ /dev/null @@ -1,158 +0,0 @@ -var webpack = require("webpack"); -var nsWebpack = require("nativescript-dev-webpack"); -var nativescriptTarget = require("nativescript-dev-webpack/nativescript-target"); -var path = require("path"); -var CopyWebpackPlugin = require("copy-webpack-plugin"); -var ExtractTextPlugin = require("extract-text-webpack-plugin"); -var AotPlugin = require("@ngtools/webpack").AotPlugin; - -module.exports = function (platform, destinationApp) { - if (!destinationApp) { - //Default destination inside platforms//... - destinationApp = nsWebpack.getAppPath(platform); - } - var entry = {}; - // Discover entry module from package.json - entry.bundle = "./" + nsWebpack.getEntryModule(); - //Vendor entry with third party libraries. - entry.vendor = "./vendor"; - // app.css bundle - entry["app.css"] = "./app.css"; - - // Vendor libs go to the vendor.js chunk - var commonsChunkNames = ["vendor"]; - - // Compatibility workaround with NativeScript 2.5 Android runtime - // https://github.com/NativeScript/NativeScript/issues/3947 - if (platform === "android") { - commonsChunkNames.push("tns-java-classes"); - } - - var plugins = [ - new ExtractTextPlugin("app.css"), - new webpack.optimize.CommonsChunkPlugin({ - name: commonsChunkNames - }), - // Define useful constants like TNS_WEBPACK - new webpack.DefinePlugin({ - "global.TNS_WEBPACK": "true", - }), - // Copy assets to out dir. Add your own globs as needed. - new CopyWebpackPlugin([ - { from: "app.css" }, - { from: "css/**" }, - { from: "fonts/**" }, - { from: "**/*.jpg" }, - { from: "**/*.png" }, - { from: "**/*.xml" }, - ], { ignore: ["App_Resources/**"] }), - // Generate a bundle starter script and activate it in package.json - new nsWebpack.GenerateBundleStarterPlugin([ - "./vendor", - "./bundle", - ]), - - // Angular AOT compiler - new AotPlugin({ - tsConfigPath: "tsconfig.aot.json", - entryModule: path.resolve(__dirname, "app/app.module#AppModule"), - typeChecking: false - }), - ]; - - if (process.env.npm_config_uglify) { - plugins.push(new webpack.LoaderOptionsPlugin({ - minimize: true - })); - - // Work around an Android issue by setting compress = false - var compress = platform !== "android"; - plugins.push(new webpack.optimize.UglifyJsPlugin({ - mangle: { - except: nsWebpack.uglifyMangleExcludes, - }, - compress: compress, - })); - } - - return { - context: path.resolve("./app"), - target: nativescriptTarget, - entry: entry, - output: { - pathinfo: true, - path: path.resolve(destinationApp), - libraryTarget: "commonjs2", - filename: "[name].js", - }, - resolve: { - // Resolve platform-specific modules like module.android.js - extensions: [ - "." + platform + ".ts", - "." + platform + ".js", - "." + platform + ".css", - ".aot.ts", - ".ts", - ".js", - ".css", - ], - // Resolve {N} system modules from tns-core-modules - modules: [ - "node_modules/tns-core-modules", - "node_modules", - ] - }, - node: { - // Disable node shims that conflict with NativeScript - "http": false, - "timers": false, - "setImmediate": false, - "fs": "empty", - }, - module: { - loaders: [ - { - test: /\.html$|\.xml$/, - loaders: [ - "raw-loader", - ] - }, - // Root app.css file gets extracted with bundled dependencies - { - test: /app\.css$/, - loader: ExtractTextPlugin.extract([ - "resolve-url-loader", - "nativescript-css-loader", - "nativescript-dev-webpack/platform-css-loader", - ]), - }, - // Other CSS files get bundled using the raw loader - { - test: /\.css$/, - exclude: /app\.css$/, - loaders: [ - "raw-loader", - ] - }, - // Compile TypeScript files with ahead-of-time compiler. - { - test: /\.ts$/, - loaders: [ - "nativescript-dev-webpack/tns-aot-loader", - "@ngtools/webpack", - ] - }, - // SASS support - { - test: /\.scss$/, - loaders: [ - "raw-loader", - "resolve-url-loader", - "sass-loader", - ] - }, - ] - }, - plugins: plugins, - }; -}; diff --git a/webpack.ios.js b/webpack.ios.js deleted file mode 100644 index 806f3ef..0000000 --- a/webpack.ios.js +++ /dev/null @@ -1,2 +0,0 @@ -var makeConfig = require("./webpack.common"); -module.exports = makeConfig("ios"); diff --git a/yarn.lock b/yarn.lock index 2e4be4f..8fda57b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1659,6 +1659,10 @@ nativescript-intl@^3.0.0, nativescript-intl@~3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/nativescript-intl/-/nativescript-intl-3.0.0.tgz#82ee9be7d377172b3c4295734723037628e186a7" +nativescript-theme-core@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/nativescript-theme-core/-/nativescript-theme-core-1.0.4.tgz#cf2880c7fbf2fe5f43e2235d309750790803efe1" + node-dir@^0.1.10: version "0.1.16" resolved "https://registry.yarnpkg.com/node-dir/-/node-dir-0.1.16.tgz#d2ef583aa50b90d93db8cdd26fcea58353957fe4"