From 7e8b4d62dfaf4f35b24cb20d567060336617a47d Mon Sep 17 00:00:00 2001 From: Nikolay Iliev Date: Tue, 26 Mar 2019 09:16:18 +0200 Subject: [PATCH] chore: version bump + minor info.plist update --- app/App_Resources/iOS/Info.plist | 2 ++ package.json | 43 ++++++++++++------------- webpack.config.js | 55 ++++++++++++++++++++++++-------- 3 files changed, 65 insertions(+), 35 deletions(-) diff --git a/app/App_Resources/iOS/Info.plist b/app/App_Resources/iOS/Info.plist index c683b2a1..2b135c6a 100644 --- a/app/App_Resources/iOS/Info.plist +++ b/app/App_Resources/iOS/Info.plist @@ -72,6 +72,8 @@ CFBundleURLName + CFBundleTypeRole + None CFBundleURLSchemes examplesgo diff --git a/package.json b/package.json index ca772594..4ff4a7ef 100644 --- a/package.json +++ b/package.json @@ -21,46 +21,43 @@ "license": "Apache-2.0", "nativescript": { "id": "org.nativescript.nativescriptsdkexamplesng", - "tns-android": { - "version": "5.1.0" - }, "tns-ios": { - "version": "5.1.0" + "version": "5.3.0-rc-2019-03-25-101854-01" } }, "dependencies": { - "@angular/common": "~7.1.0", - "@angular/compiler": "~7.1.0", - "@angular/core": "~7.1.0", - "@angular/forms": "~7.1.0", - "@angular/http": "~7.1.0", - "@angular/platform-browser": "~7.1.0", - "@angular/platform-browser-dynamic": "~7.1.0", - "@angular/router": "~7.1.0", - "nativescript-angular": "^7.1.0", - "nativescript-camera": "^4.1.1", - "nativescript-geolocation": "^4.3.1", + "@angular/common": "~7.2.0", + "@angular/compiler": "~7.2.0", + "@angular/core": "~7.2.0", + "@angular/forms": "~7.2.0", + "@angular/http": "~7.2.0", + "@angular/platform-browser": "~7.2.0", + "@angular/platform-browser-dynamic": "~7.2.0", + "@angular/router": "~7.2.0", + "nativescript-angular": "^7.2.3", + "nativescript-camera": "^4.4.0", + "nativescript-geolocation": "^5.0.0", "nativescript-intl": "~3.0.0", "nativescript-theme-core": "^1.0.4", "reflect-metadata": "~0.1.12", "rxjs": "^6.3.3", - "tns-core-modules": "^5.1.1", + "tns-core-modules": "^5.2.2", "zone.js": "^0.8.4" }, "devDependencies": { - "@angular/compiler-cli": "~7.1.0", - "@ngtools/webpack": "~7.1.0", + "@angular/compiler-cli": "~7.2.0", + "@ngtools/webpack": "~7.2.0", "codelyzer": "^3.0.1", "fs-extra": "^0.30.0", "glob": "^7.1.3", "lazy": "1.0.11", "markdown-snippet-injector": "^0.2.2", - "nativescript-dev-typescript": "^0.7.8", - "nativescript-dev-webpack": "^0.18.5", + "nativescript-dev-typescript": "^0.9.0", + "nativescript-dev-webpack": "^0.20.3", "opener": "^1.4.1", "rimraf": "^2.5.3", "tar.gz": "^1.0.5", - "tns-platform-declarations": "^5.1.1", + "tns-platform-declarations": "^5.2.2", "tslint": "^5.11.0", "typescript": "~3.1.1" }, @@ -73,6 +70,8 @@ "build": "node scripts/build.js", "postbuild": "npm run inject && npm run archive", "inject": "mdinject --root=app --docsroot=dist/code-samples --sourceext=\".ts|.css|.html\" --snippettitles=\"TypeScript|CSS|HTML\"", - "archive": "node scripts/archive.js" + "archive": "node scripts/archive.js", + "update-webpack": "./node_modules/.bin/update-ns-webpack --deps --configs", + "update-angular": "./node_modules/.bin/update-app-ng-deps" } } diff --git a/webpack.config.js b/webpack.config.js index 070cec49..d2174876 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,15 +1,19 @@ -const { join, relative, resolve, sep } = require("path"); +const { join, relative, resolve, sep, dirname } = require("path"); const webpack = require("webpack"); const nsWebpack = require("nativescript-dev-webpack"); const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target"); const { nsReplaceBootstrap } = require("nativescript-dev-webpack/transformers/ns-replace-bootstrap"); +const { nsReplaceLazyLoader } = require("nativescript-dev-webpack/transformers/ns-replace-lazy-loader"); +const { nsSupportHmrNg } = require("nativescript-dev-webpack/transformers/ns-support-hmr-ng"); +const { getMainModulePath } = require("nativescript-dev-webpack/utils/ast-utils"); const CleanWebpackPlugin = require("clean-webpack-plugin"); const CopyWebpackPlugin = require("copy-webpack-plugin"); const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer"); const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin"); const UglifyJsPlugin = require("uglifyjs-webpack-plugin"); const { AngularCompilerPlugin } = require("@ngtools/webpack"); +const hashSalt = Date.now().toString(); module.exports = env => { // Add your custom Activities, Services and other Android app components here. @@ -33,8 +37,8 @@ module.exports = env => { // The 'appPath' and 'appResourcesPath' values are fetched from // the nsconfig.json configuration file // when bundling with `tns run android|ios --bundle`. - appPath = "app", - appResourcesPath = "app/App_Resources", + appPath = "src", + appResourcesPath = "App_Resources", // You can provide the following flags when running 'tns run android|ios' aot, // --env.aot @@ -44,23 +48,45 @@ module.exports = env => { sourceMap, // --env.sourceMap hmr, // --env.hmr, } = env; - const externals = (env.externals || []).map((e) => { // --env.externals - return new RegExp(e + ".*"); - }); + const externals = nsWebpack.getConvertedExternals(env.externals); const appFullPath = resolve(projectRoot, appPath); const appResourcesFullPath = resolve(projectRoot, appResourcesPath); - + const tsConfigName = "tsconfig.tns.json"; const entryModule = `${nsWebpack.getEntryModule(appFullPath)}.ts`; const entryPath = `.${sep}${entryModule}`; + const ngCompilerTransformers = []; + const additionalLazyModuleResources = []; + if (aot) { + ngCompilerTransformers.push(nsReplaceBootstrap); + } + + if (hmr) { + ngCompilerTransformers.push(nsSupportHmrNg); + } + + // when "@angular/core" is external, it's not included in the bundles. In this way, it will be used + // directly from node_modules and the Angular modules loader won't be able to resolve the lazy routes + // fixes https://github.com/NativeScript/nativescript-cli/issues/4024 + if (env.externals && env.externals.indexOf("@angular/core") > -1) { + const appModuleRelativePath = getMainModulePath(resolve(appFullPath, entryModule), tsConfigName); + if (appModuleRelativePath) { + const appModuleFolderPath = dirname(resolve(appFullPath, appModuleRelativePath)); + // include the lazy loader inside app module + ngCompilerTransformers.push(nsReplaceLazyLoader); + // include the new lazy loader path in the allowed ones + additionalLazyModuleResources.push(appModuleFolderPath); + } + } const ngCompilerPlugin = new AngularCompilerPlugin({ hostReplacementPaths: nsWebpack.getResolver([platform, "tns"]), - platformTransformers: aot ? [nsReplaceBootstrap(() => ngCompilerPlugin)] : null, + platformTransformers: ngCompilerTransformers.map(t => t(() => ngCompilerPlugin, resolve(appFullPath, entryModule))), mainPath: resolve(appPath, entryModule), - tsConfigPath: join(__dirname, "tsconfig.tns.json"), + tsConfigPath: join(__dirname, tsConfigName), skipCodeGeneration: !aot, sourceMap: !!sourceMap, + additionalLazyModuleResources: additionalLazyModuleResources }); const config = { @@ -84,6 +110,7 @@ module.exports = env => { libraryTarget: "commonjs2", filename: "[name].js", globalObject: "global", + hashSalt }, resolve: { extensions: [".ts", ".js", ".scss", ".css"], @@ -171,14 +198,15 @@ module.exports = env => { // tns-core-modules reads the app.css and its imports using css-loader { test: /[\/|\\]app\.css$/, - use: { - loader: "css-loader", - options: { minimize: false, url: false }, - } + use: [ + "nativescript-dev-webpack/style-hot-loader", + { loader: "css-loader", options: { minimize: false, url: false } } + ] }, { test: /[\/|\\]app\.scss$/, use: [ + "nativescript-dev-webpack/style-hot-loader", { loader: "css-loader", options: { minimize: false, url: false } }, "sass-loader" ] @@ -192,6 +220,7 @@ module.exports = env => { test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/, use: [ "nativescript-dev-webpack/moduleid-compat-loader", + "nativescript-dev-webpack/lazy-ngmodule-hot-loader", "@ngtools/webpack", ] },