From ec586d145d71f7a06f3b66b1fad6de87e2a611ac Mon Sep 17 00:00:00 2001 From: VladimirAmiorkov Date: Mon, 10 Jun 2019 15:24:23 +0300 Subject: [PATCH 01/14] chore: upgrade app to latest versions and webpack --- tests/app/snippets/gestures.component.ts | 3 ++- tests/app/snippets/icon-font.component.ts | 5 +++-- tests/app/snippets/layouts.component.ts | 3 ++- .../nativescript-unit-test-runner.js | 2 +- tests/nsconfig.json | 5 +++++ tests/package.json | 20 +++++++++++-------- tests/tsconfig.json | 6 ++++++ 7 files changed, 31 insertions(+), 13 deletions(-) create mode 100644 tests/nsconfig.json diff --git a/tests/app/snippets/gestures.component.ts b/tests/app/snippets/gestures.component.ts index 50f6cd9ce..a60502b11 100644 --- a/tests/app/snippets/gestures.component.ts +++ b/tests/app/snippets/gestures.component.ts @@ -9,7 +9,8 @@ import { @Component({ selector: "gestures", - templateUrl: "snippets/gestures.component.html", + moduleId: module.id, + templateUrl: "gestures.component.html", styles: ["label { font-size: 32; margin: 2; background-color: lightgreen;}"] }) export class GestureComponent { diff --git a/tests/app/snippets/icon-font.component.ts b/tests/app/snippets/icon-font.component.ts index 64fdc5e7f..8b66ad36a 100644 --- a/tests/app/snippets/icon-font.component.ts +++ b/tests/app/snippets/icon-font.component.ts @@ -4,8 +4,9 @@ import {Component} from "@angular/core"; @Component({ // >> (hide) selector: "icon-font", - templateUrl: "snippets/icon-font.component.html", - styleUrls: ["snippets/icon-font.component.css"] + moduleId: module.id, + templateUrl: "icon-font.component.html", + styleUrls: ["icon-font.component.css"] // << (hide) // ... }) diff --git a/tests/app/snippets/layouts.component.ts b/tests/app/snippets/layouts.component.ts index 5892c0492..0e148b70a 100644 --- a/tests/app/snippets/layouts.component.ts +++ b/tests/app/snippets/layouts.component.ts @@ -2,7 +2,8 @@ import {Component} from "@angular/core"; @Component({ selector: "gestures", - templateUrl: "snippets/layouts.component.html", + moduleId: module.id, + templateUrl: "layouts.component.html", styles: [ "Image { background-color: coral }", ".title { margin: 10; horizontal-align: center; font-size: 32 }", diff --git a/tests/hooks/after-prepare/nativescript-unit-test-runner.js b/tests/hooks/after-prepare/nativescript-unit-test-runner.js index 45ca49f8a..67bdf40a7 100644 --- a/tests/hooks/after-prepare/nativescript-unit-test-runner.js +++ b/tests/hooks/after-prepare/nativescript-unit-test-runner.js @@ -1 +1 @@ -module.exports = require("nativescript-unit-test-runner/lib/after-prepare"); +module.exports = require("nativescript-unit-test-runner/./lib/after-prepare.js"); diff --git a/tests/nsconfig.json b/tests/nsconfig.json new file mode 100644 index 000000000..c1ec5f483 --- /dev/null +++ b/tests/nsconfig.json @@ -0,0 +1,5 @@ +{ + "useLegacyWorkflow": false, + "appPath": "app", + "appResourcesPath": "app/App_Resources" +} \ No newline at end of file diff --git a/tests/package.json b/tests/package.json index 97e308db3..95e241f1c 100644 --- a/tests/package.json +++ b/tests/package.json @@ -2,14 +2,13 @@ "nativescript": { "id": "org.nativescript.ngtests", "tns-ios": { - "version": "next" + "version": "6.0.0-2019-06-06-144931-01" }, "tns-android": { - "version": "next" + "version": "6.0.0-2019-06-10-092203-01" } }, "name": "ngtests", - "main": "app.js", "version": "1.0.0", "author": "Telerik ", "description": "Angular tests", @@ -36,28 +35,33 @@ "@angular/platform-browser-dynamic": "8.0.0", "@angular/router": "8.0.0", "nativescript-angular": "../nativescript-angular", - "nativescript-unit-test-runner": "^0.3.4", + "nativescript-unit-test-runner": "~0.6.3", "rxjs": "~6.3.3", "tns-core-modules": "next", "zone.js": "^0.8.4" }, "devDependencies": { + "@angular/compiler-cli": "8.0.0", + "@ngtools/webpack": "8.0.0", "@types/chai": "^4.1.4", - "@types/mocha": "^5.2.4", + "@types/karma-chai": "0.1.1", + "@types/mocha": "5.2.6", "@types/sinon": "^7.0.11", "babel-traverse": "6.8.0", "babel-types": "6.8.1", "babylon": "6.8.0", - "chai": "4.1.2", - "karma": "2.0.4", + "chai": "4.2.0", + "karma": "4.1.0", "karma-chai": "0.1.0", "karma-mocha": "1.3.0", "karma-mocha-reporter": "2.2.5", "karma-nativescript-launcher": "0.4.0", "karma-sinon": "^1.0.5", + "karma-webpack": "3.0.5", "lazy": "1.0.11", - "mocha": "5.2.0", + "mocha": "6.1.4", "nativescript-dev-typescript": "next", + "nativescript-dev-webpack": "~0.25.0-webpack-2019-06-06-120047-02", "sinon": "^7.3.2", "tslint": "^4.5.1", "typescript": "~3.4.5" diff --git a/tests/tsconfig.json b/tests/tsconfig.json index 67688d919..d24fffdf3 100644 --- a/tests/tsconfig.json +++ b/tests/tsconfig.json @@ -22,7 +22,13 @@ ] } }, + "include": [ + "../nativescript-angular", + "**/*" + ], "exclude": [ + "../nativescript-angular/node_modules", + "../nativescript-angular/**/*.d.ts", "node_modules", "platforms", "**/*.aot", From 99bc7ed089929b4bb5c00cf88622fb05a2796faa Mon Sep 17 00:00:00 2001 From: VladimirAmiorkov Date: Wed, 12 Jun 2019 09:37:27 +0300 Subject: [PATCH 02/14] chore: fix incorrect temlateUrl in component chore: update karma config for latest CLI beta 6.0.0 --- .../snippets/navigation/router-extensions.ts | 3 +- tests/karma.conf.js | 49 ++++++++++++++++--- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/tests/app/snippets/navigation/router-extensions.ts b/tests/app/snippets/navigation/router-extensions.ts index bb72a6d2a..ae8c8c206 100644 --- a/tests/app/snippets/navigation/router-extensions.ts +++ b/tests/app/snippets/navigation/router-extensions.ts @@ -4,8 +4,9 @@ import { RouterExtensions } from "nativescript-angular/router"; @Component({ // ... // >> (hide) + moduleId: module.id, selector: "router-extensions-import", - templateUrl: "snippets/navigation/router-extensions.html" + templateUrl: "router-extensions.html" // << (hide) }) export class MyComponent { diff --git a/tests/karma.conf.js b/tests/karma.conf.js index a02f0287a..a18a79a09 100644 --- a/tests/karma.conf.js +++ b/tests/karma.conf.js @@ -1,6 +1,5 @@ -module.exports = function(config) { - config.set({ - browserNoActivityTimeout: 40000, +module.exports = function (config) { + const options = { // base path that will be used to resolve all patterns (eg. files, exclude) basePath: '', @@ -12,6 +11,8 @@ module.exports = function(config) { // list of files / patterns to load in the browser + // files: ['app/tests/**/*.ts'], + files: [ 'app/tests/test-main.js', 'app/**/*.js', @@ -32,7 +33,7 @@ module.exports = function(config) { // test results reporter to use // possible values: 'dots', 'progress' // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ['mocha'], + reporters: ['progress'], // web server port @@ -49,7 +50,7 @@ module.exports = function(config) { // enable / disable watching file and executing tests whenever any file changes - autoWatch: false, + autoWatch: true, // start these browsers @@ -74,6 +75,40 @@ module.exports = function(config) { // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits - singleRun: true - }) + singleRun: false + }; + + setWebpackPreprocessor(config, options); + setWebpack(config, options); + + config.set(options); +} + +function setWebpackPreprocessor(config, options) { + if (config && config.bundle) { + if (!options.preprocessors) { + options.preprocessors = {}; + } + + options.files.forEach(file => { + if (!options.preprocessors[file]) { + options.preprocessors[file] = []; + } + options.preprocessors[file].push('webpack'); + }); + } +} + +function setWebpack(config, options) { + if (config && config.bundle) { + const env = {}; + env[config.platform] = true; + env.sourceMap = config.debugBrk; + options.webpack = require('./webpack.config')(env); + delete options.webpack.entry; + delete options.webpack.output.libraryTarget; + + const invalidPluginsForUnitTesting = ["GenerateBundleStarterPlugin", "GenerateNativeScriptEntryPointsPlugin"]; + options.webpack.plugins = options.webpack.plugins.filter(p => !invalidPluginsForUnitTesting.includes(p.constructor.name)); + } } From 78d9c3a92d88310c90d9bd52de0e7469530a4c70 Mon Sep 17 00:00:00 2001 From: VladimirAmiorkov Date: Wed, 12 Jun 2019 13:59:27 +0300 Subject: [PATCH 03/14] chore: make `router-tab-view` example webpack compatible --- e2e/router-tab-view/package.json | 5 ++++- e2e/router-tab-view/tsconfig.json | 13 ++++++++++++- tests/package.json | 6 +++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/e2e/router-tab-view/package.json b/e2e/router-tab-view/package.json index 2a8e7bad8..058f05293 100644 --- a/e2e/router-tab-view/package.json +++ b/e2e/router-tab-view/package.json @@ -23,6 +23,7 @@ "@angular/platform-browser-dynamic": "8.0.0", "@angular/router": "8.0.0", "nativescript-angular": "file:../../nativescript-angular", + "nativescript-dev-webpack": "webpack", "nativescript-theme-core": "~1.0.4", "reflect-metadata": "~0.1.8", "rxjs": "~6.3.3", @@ -41,7 +42,9 @@ "mochawesome": "~3.1.2", "nativescript-dev-appium": "next", "nativescript-dev-typescript": "next", - "typescript": "~3.4.5" + "typescript": "~3.4.5", + "@angular/compiler-cli": "8.0.0", + "@ngtools/webpack": "8.0.0" }, "scripts": { "e2e": "tsc -p e2e && mocha --opts ../config/mocha.opts --recursive e2e --appiumCapsLocation ../config/appium.capabilities.json", diff --git a/e2e/router-tab-view/tsconfig.json b/e2e/router-tab-view/tsconfig.json index 357c35626..d93d819b4 100644 --- a/e2e/router-tab-view/tsconfig.json +++ b/e2e/router-tab-view/tsconfig.json @@ -16,11 +16,22 @@ "*": [ "./node_modules/tns-core-modules/*", "./node_modules/*" + ], + "~/*": [ + "app/*" ] } }, + "include": [ + "../../nativescript-angular", + "**/*" + ], "exclude": [ + "../../nativescript-angular/node_modules", + "../../nativescript-angular/**/*.d.ts", "node_modules", - "platforms" + "platforms", + "**/*.aot", + "e2e" ] } \ No newline at end of file diff --git a/tests/package.json b/tests/package.json index 95e241f1c..5521e43d4 100644 --- a/tests/package.json +++ b/tests/package.json @@ -2,10 +2,10 @@ "nativescript": { "id": "org.nativescript.ngtests", "tns-ios": { - "version": "6.0.0-2019-06-06-144931-01" + "version": "next" }, "tns-android": { - "version": "6.0.0-2019-06-10-092203-01" + "version": "next" } }, "name": "ngtests", @@ -61,7 +61,7 @@ "lazy": "1.0.11", "mocha": "6.1.4", "nativescript-dev-typescript": "next", - "nativescript-dev-webpack": "~0.25.0-webpack-2019-06-06-120047-02", + "nativescript-dev-webpack": "webpack", "sinon": "^7.3.2", "tslint": "^4.5.1", "typescript": "~3.4.5" From e46ba21059a6a09eeab7d891ad871f1a8302667d Mon Sep 17 00:00:00 2001 From: VladimirAmiorkov Date: Wed, 12 Jun 2019 14:00:23 +0300 Subject: [PATCH 04/14] chore: make `nested-router-tab-view` example webpack compatible --- e2e/nested-router-tab-view/app/app.routing.ts | 3 ++- e2e/nested-router-tab-view/package.json | 3 ++- e2e/nested-router-tab-view/tsconfig.json | 11 +++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/e2e/nested-router-tab-view/app/app.routing.ts b/e2e/nested-router-tab-view/app/app.routing.ts index b77942d75..7ca6a1e0a 100644 --- a/e2e/nested-router-tab-view/app/app.routing.ts +++ b/e2e/nested-router-tab-view/app/app.routing.ts @@ -9,6 +9,7 @@ import { TeamDetailComponent } from "./team/team-detail.component"; import { LoginComponent } from "./login/login.component"; import { TabsComponent } from "./tabs/tabs.component"; import { HomeComponent } from "./home/home.component"; +import { HomeLazyModule } from "./home-lazy/home-lazy.module"; import { AboutComponent } from "./about/about.component"; import { AboutNestedComponent } from "./about/about-nested.component"; @@ -46,7 +47,7 @@ const routes: Routes = [ }, { path: "home-lazy", - loadChildren: "./home-lazy/home-lazy.module#HomeLazyModule", + loadChildren: () => HomeLazyModule, }, { path: "custom-tabs", diff --git a/e2e/nested-router-tab-view/package.json b/e2e/nested-router-tab-view/package.json index 97ee5a7c8..6086d2ac1 100644 --- a/e2e/nested-router-tab-view/package.json +++ b/e2e/nested-router-tab-view/package.json @@ -6,7 +6,7 @@ "nativescript": { "id": "org.nativescript.nestedroutertabview", "tns-ios": { - "version": "next" + "version": "6.0.0-2019-06-10-154118-03" }, "tns-android": { "version": "next" @@ -23,6 +23,7 @@ "@angular/platform-browser-dynamic": "8.0.0", "@angular/router": "8.0.0", "nativescript-angular": "file:../../nativescript-angular", + "nativescript-dev-webpack": "webpack", "nativescript-theme-core": "~1.0.4", "reflect-metadata": "~0.1.8", "rxjs": "~6.3.3", diff --git a/e2e/nested-router-tab-view/tsconfig.json b/e2e/nested-router-tab-view/tsconfig.json index 575276e9f..d93d819b4 100644 --- a/e2e/nested-router-tab-view/tsconfig.json +++ b/e2e/nested-router-tab-view/tsconfig.json @@ -6,7 +6,6 @@ "emitDecoratorMetadata": true, "noEmitHelpers": true, "noEmitOnError": true, - "sourceMap": true, "lib": [ "es6", "dom", @@ -23,8 +22,16 @@ ] } }, + "include": [ + "../../nativescript-angular", + "**/*" + ], "exclude": [ + "../../nativescript-angular/node_modules", + "../../nativescript-angular/**/*.d.ts", "node_modules", - "platforms" + "platforms", + "**/*.aot", + "e2e" ] } \ No newline at end of file From ebf75521c1a4a888bd2c251e5c6c03f60d3d9144 Mon Sep 17 00:00:00 2001 From: VladimirAmiorkov Date: Wed, 12 Jun 2019 14:32:31 +0300 Subject: [PATCH 05/14] chore: fix lazy loaded component not loading --- e2e/nested-router-tab-view/app/app.routing.ts | 3 ++- e2e/nested-router-tab-view/package.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/e2e/nested-router-tab-view/app/app.routing.ts b/e2e/nested-router-tab-view/app/app.routing.ts index 7ca6a1e0a..50d824095 100644 --- a/e2e/nested-router-tab-view/app/app.routing.ts +++ b/e2e/nested-router-tab-view/app/app.routing.ts @@ -10,6 +10,7 @@ import { LoginComponent } from "./login/login.component"; import { TabsComponent } from "./tabs/tabs.component"; import { HomeComponent } from "./home/home.component"; import { HomeLazyModule } from "./home-lazy/home-lazy.module"; +import { CustomTabsModule } from "./custom-tabs/custom-tabs.module" import { AboutComponent } from "./about/about.component"; import { AboutNestedComponent } from "./about/about-nested.component"; @@ -51,7 +52,7 @@ const routes: Routes = [ }, { path: "custom-tabs", - loadChildren: "./custom-tabs/custom-tabs.module#CustomTabsModule", + loadChildren: () => CustomTabsModule, }, { path: "tabs", component: TabsComponent, children: [ diff --git a/e2e/nested-router-tab-view/package.json b/e2e/nested-router-tab-view/package.json index 6086d2ac1..e6aa54f32 100644 --- a/e2e/nested-router-tab-view/package.json +++ b/e2e/nested-router-tab-view/package.json @@ -6,7 +6,7 @@ "nativescript": { "id": "org.nativescript.nestedroutertabview", "tns-ios": { - "version": "6.0.0-2019-06-10-154118-03" + "version": "next" }, "tns-android": { "version": "next" From f877ca9ced49dd6864d30b6c82084909794d7c0b Mon Sep 17 00:00:00 2001 From: VladimirAmiorkov Date: Wed, 12 Jun 2019 14:42:15 +0300 Subject: [PATCH 06/14] chore: make `modal-navigation-ng` example webpack compatible --- e2e/modal-navigation-ng/package.json | 1 + e2e/modal-navigation-ng/tsconfig.json | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/e2e/modal-navigation-ng/package.json b/e2e/modal-navigation-ng/package.json index 6e3e6944f..531105fba 100644 --- a/e2e/modal-navigation-ng/package.json +++ b/e2e/modal-navigation-ng/package.json @@ -23,6 +23,7 @@ "@angular/platform-browser-dynamic": "8.0.0", "@angular/router": "8.0.0", "nativescript-angular": "file:../../nativescript-angular", + "nativescript-dev-webpack": "webpack", "nativescript-theme-core": "~1.0.4", "reflect-metadata": "~0.1.8", "rxjs": "~6.3.3", diff --git a/e2e/modal-navigation-ng/tsconfig.json b/e2e/modal-navigation-ng/tsconfig.json index f251eb444..d93d819b4 100644 --- a/e2e/modal-navigation-ng/tsconfig.json +++ b/e2e/modal-navigation-ng/tsconfig.json @@ -22,8 +22,16 @@ ] } }, + "include": [ + "../../nativescript-angular", + "**/*" + ], "exclude": [ + "../../nativescript-angular/node_modules", + "../../nativescript-angular/**/*.d.ts", "node_modules", - "platforms" + "platforms", + "**/*.aot", + "e2e" ] } \ No newline at end of file From 95e4d3eb111a891e54d509f8edeb354d17fb1021 Mon Sep 17 00:00:00 2001 From: VladimirAmiorkov Date: Wed, 19 Jun 2019 13:42:27 +0300 Subject: [PATCH 07/14] chore: add webpack config due to issue in CLI that disregards the `nsconfig.json` --- tests/webpack.config.js | 318 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 318 insertions(+) create mode 100644 tests/webpack.config.js diff --git a/tests/webpack.config.js b/tests/webpack.config.js new file mode 100644 index 000000000..0d150698a --- /dev/null +++ b/tests/webpack.config.js @@ -0,0 +1,318 @@ +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 TerserPlugin = require("terser-webpack-plugin"); +const { getAngularCompilerPlugin } = require("nativescript-dev-webpack/plugins/NativeScriptAngularCompilerPlugin"); +const hashSalt = Date.now().toString(); + +module.exports = env => { + // Add your custom Activities, Services and other Android app components here. + const appComponents = [ + "tns-core-modules/ui/frame", + "tns-core-modules/ui/frame/activity", + ]; + + const platform = env && (env.android && "android" || env.ios && "ios"); + if (!platform) { + throw new Error("You need to provide a target platform!"); + } + + const AngularCompilerPlugin = getAngularCompilerPlugin(platform); + const projectRoot = __dirname; + + // Default destination inside platforms//... + const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot)); + const appResourcesPlatformDir = platform === "android" ? "Android" : "iOS"; + + const { + // 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", + + // You can provide the following flags when running 'tns run android|ios' + aot, // --env.aot + snapshot, // --env.snapshot, + production, // --env.production + uglify, // --env.uglify + report, // --env.report + sourceMap, // --env.sourceMap + hiddenSourceMap, // --env.hiddenSourceMap + hmr, // --env.hmr, + unitTesting, // --env.unitTesting + verbose, // --env.verbose + } = env; + + const isAnySourceMapEnabled = !!sourceMap || !!hiddenSourceMap; + 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, platform)}.ts`; + const entryPath = `.${sep}${entryModule}`; + const entries = { bundle: entryPath }; + if (platform === "ios") { + entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules.js"; + }; + + 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: ngCompilerTransformers.map(t => t(() => ngCompilerPlugin, resolve(appFullPath, entryModule), projectRoot)), + mainPath: join(appFullPath, entryModule), + tsConfigPath: join(__dirname, tsConfigName), + skipCodeGeneration: !aot, + sourceMap: !!isAnySourceMapEnabled, + additionalLazyModuleResources: additionalLazyModuleResources + }); + + let sourceMapFilename = nsWebpack.getSourceMapFilename(hiddenSourceMap, __dirname, dist); + + const itemsToClean = [`${dist}/**/*`]; + if (platform === "android") { + itemsToClean.push(`${join(projectRoot, "platforms", "android", "app", "src", "main", "assets", "snapshots")}`); + itemsToClean.push(`${join(projectRoot, "platforms", "android", "app", "build", "configurations", "nativescript-android-snapshot")}`); + } + + const config = { + mode: production ? "production" : "development", + context: appFullPath, + externals, + watchOptions: { + ignored: [ + appResourcesFullPath, + // Don't watch hidden files + "**/.*", + ] + }, + target: nativescriptTarget, + entry: entries, + output: { + pathinfo: false, + path: dist, + sourceMapFilename, + libraryTarget: "commonjs2", + filename: "[name].js", + globalObject: "global", + hashSalt + }, + resolve: { + extensions: [".ts", ".js", ".scss", ".css"], + // Resolve {N} system modules from tns-core-modules + modules: [ + resolve(__dirname, "node_modules/tns-core-modules"), + resolve(__dirname, "node_modules"), + "node_modules/tns-core-modules", + "node_modules", + ], + alias: { + '~': appFullPath + }, + symlinks: true + }, + resolveLoader: { + symlinks: false + }, + node: { + // Disable node shims that conflict with NativeScript + "http": false, + "timers": false, + "setImmediate": false, + "fs": "empty", + "__dirname": false, + }, + devtool: hiddenSourceMap ? "hidden-source-map" : (sourceMap ? "inline-source-map" : "none"), + optimization: { + runtimeChunk: "single", + splitChunks: { + cacheGroups: { + vendor: { + name: "vendor", + chunks: "all", + test: (module, chunks) => { + const moduleName = module.nameForCondition ? module.nameForCondition() : ''; + return /[\\/]node_modules[\\/]/.test(moduleName) || + appComponents.some(comp => comp === moduleName); + }, + enforce: true, + }, + } + }, + minimize: !!uglify, + minimizer: [ + new TerserPlugin({ + parallel: true, + cache: true, + sourceMap: isAnySourceMapEnabled, + terserOptions: { + output: { + comments: false, + semicolons: !isAnySourceMapEnabled + }, + compress: { + // The Android SBG has problems parsing the output + // when these options are enabled + 'collapse_vars': platform !== "android", + sequences: platform !== "android", + } + } + }) + ], + }, + module: { + rules: [ + { + test: nsWebpack.getEntryPathRegExp(appFullPath, entryPath), + use: [ + // Require all Android app components + platform === "android" && { + loader: "nativescript-dev-webpack/android-app-components-loader", + options: { modules: appComponents } + }, + + { + loader: "nativescript-dev-webpack/bundle-config-loader", + options: { + angular: true, + loadCss: !snapshot, // load the application css if in debug mode + unitTesting, + appFullPath, + projectRoot, + } + }, + ].filter(loader => !!loader) + }, + + { test: /\.html$|\.xml$/, use: "raw-loader" }, + + // tns-core-modules reads the app.css and its imports using css-loader + { + test: /[\/|\\]app\.css$/, + use: [ + "nativescript-dev-webpack/style-hot-loader", + { loader: "css-loader", options: { url: false } } + ] + }, + { + test: /[\/|\\]app\.scss$/, + use: [ + "nativescript-dev-webpack/style-hot-loader", + { loader: "css-loader", options: { url: false } }, + "sass-loader" + ] + }, + + // Angular components reference css files and their imports using raw-loader + { test: /\.css$/, exclude: /[\/|\\]app\.css$/, use: "raw-loader" }, + { test: /\.scss$/, exclude: /[\/|\\]app\.scss$/, use: ["raw-loader", "resolve-url-loader", "sass-loader"] }, + + { + test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/, + use: [ + "nativescript-dev-webpack/moduleid-compat-loader", + "nativescript-dev-webpack/lazy-ngmodule-hot-loader", + "@ngtools/webpack", + ] + }, + + // Mark files inside `@angular/core` as using SystemJS style dynamic imports. + // Removing this will cause deprecation warnings to appear. + { + test: /[\/\\]@angular[\/\\]core[\/\\].+\.js$/, + parser: { system: true }, + }, + ], + }, + plugins: [ + // Define useful constants like TNS_WEBPACK + new webpack.DefinePlugin({ + "global.TNS_WEBPACK": "true", + "process": undefined, + }), + // Remove all files from the out dir. + new CleanWebpackPlugin(itemsToClean, { verbose: !!verbose }), + // Copy assets to out dir. Add your own globs as needed. + new CopyWebpackPlugin([ + { from: { glob: "fonts/**" } }, + { from: { glob: "**/*.jpg" } }, + { from: { glob: "**/*.png" } }, + ], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }), + new nsWebpack.GenerateNativeScriptEntryPointsPlugin("bundle"), + // For instructions on how to set up workers with webpack + // check out https://github.com/nativescript/worker-loader + new NativeScriptWorkerPlugin(), + ngCompilerPlugin, + // Does IPC communication with the {N} CLI to notify events when running in watch mode. + new nsWebpack.WatchStateLoggerPlugin(), + ], + }; + + if (report) { + // Generate report files for bundles content + config.plugins.push(new BundleAnalyzerPlugin({ + analyzerMode: "static", + openAnalyzer: false, + generateStatsFile: true, + reportFilename: resolve(projectRoot, "report", `report.html`), + statsFilename: resolve(projectRoot, "report", `stats.json`), + })); + } + + if (snapshot) { + config.plugins.push(new nsWebpack.NativeScriptSnapshotPlugin({ + chunk: "vendor", + angular: true, + requireModules: [ + "reflect-metadata", + "@angular/platform-browser", + "@angular/core", + "@angular/common", + "@angular/router", + "nativescript-angular/platform-static", + "nativescript-angular/router", + ], + projectRoot, + webpackConfig: config, + })); + } + + if (hmr) { + config.plugins.push(new webpack.HotModuleReplacementPlugin()); + } + + return config; +}; From 80c275487e260d56670751029f3e53dd2e4084fb Mon Sep 17 00:00:00 2001 From: VladimirAmiorkov Date: Wed, 19 Jun 2019 16:31:42 +0300 Subject: [PATCH 08/14] chore: update test app with latest deps and remove not used d.ts --- tests/app/global.d.ts | 1 - tests/karma.conf.js | 3 --- tests/package.json | 2 +- tests/references.d.ts | 3 ++- 4 files changed, 3 insertions(+), 6 deletions(-) delete mode 100644 tests/app/global.d.ts diff --git a/tests/app/global.d.ts b/tests/app/global.d.ts deleted file mode 100644 index 81ddef2ce..000000000 --- a/tests/app/global.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/tests/karma.conf.js b/tests/karma.conf.js index a18a79a09..be7b94f40 100644 --- a/tests/karma.conf.js +++ b/tests/karma.conf.js @@ -11,8 +11,6 @@ module.exports = function (config) { // list of files / patterns to load in the browser - // files: ['app/tests/**/*.ts'], - files: [ 'app/tests/test-main.js', 'app/**/*.js', @@ -107,7 +105,6 @@ function setWebpack(config, options) { options.webpack = require('./webpack.config')(env); delete options.webpack.entry; delete options.webpack.output.libraryTarget; - const invalidPluginsForUnitTesting = ["GenerateBundleStarterPlugin", "GenerateNativeScriptEntryPointsPlugin"]; options.webpack.plugins = options.webpack.plugins.filter(p => !invalidPluginsForUnitTesting.includes(p.constructor.name)); } diff --git a/tests/package.json b/tests/package.json index d6fc4fd68..28209febc 100644 --- a/tests/package.json +++ b/tests/package.json @@ -45,7 +45,7 @@ "@ngtools/webpack": "8.0.0", "@types/chai": "^4.1.4", "@types/karma-chai": "0.1.1", - "@types/mocha": "5.2.6", + "@types/mocha": "5.2.7", "@types/sinon": "^7.0.11", "babel-traverse": "6.8.0", "babel-types": "6.8.1", diff --git a/tests/references.d.ts b/tests/references.d.ts index b14f3837d..23f21bb29 100644 --- a/tests/references.d.ts +++ b/tests/references.d.ts @@ -1 +1,2 @@ -/// Needed for autocompletion and compilation. \ No newline at end of file +/// Needed for autocompletion and compilation. +/// \ No newline at end of file From 5fee43012fa005f1ba17cc097c7f07a362f6d803 Mon Sep 17 00:00:00 2001 From: VladimirAmiorkov Date: Wed, 19 Jun 2019 17:09:18 +0300 Subject: [PATCH 09/14] chore: update karma config --- tests/karma.conf.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/karma.conf.js b/tests/karma.conf.js index be7b94f40..91c67210c 100644 --- a/tests/karma.conf.js +++ b/tests/karma.conf.js @@ -11,10 +11,10 @@ module.exports = function (config) { // list of files / patterns to load in the browser + // TODO: changing this to .ts files causes the test to become lest from 126 to 106. ~20 tests are cutoff by something. Needs a future research files: [ 'app/tests/test-main.js', - 'app/**/*.js', - 'src/tests/**/*.js' + 'app/**/*.js' ], // list of files to exclude From 7db226614515aa78746e5643f876a1b2675fed45 Mon Sep 17 00:00:00 2001 From: VladimirAmiorkov Date: Mon, 24 Jun 2019 13:14:09 +0300 Subject: [PATCH 10/14] chore: resolve issue caused by overrding `global.__extends ` --- tests/package.json | 1 + tests/webpack.config.js | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/tests/package.json b/tests/package.json index 28209febc..bbf5b08fd 100644 --- a/tests/package.json +++ b/tests/package.json @@ -62,6 +62,7 @@ "mocha": "6.1.4", "nativescript-dev-typescript": "next", "nativescript-dev-webpack": "webpack", + "remove-strict-webpack-plugin": "~0.1.2", "sinon": "^7.3.2", "tslint": "^4.5.1", "typescript": "~3.4.5" diff --git a/tests/webpack.config.js b/tests/webpack.config.js index 0d150698a..bdf8ff91d 100644 --- a/tests/webpack.config.js +++ b/tests/webpack.config.js @@ -13,6 +13,7 @@ const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer"); const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin"); const TerserPlugin = require("terser-webpack-plugin"); const { getAngularCompilerPlugin } = require("nativescript-dev-webpack/plugins/NativeScriptAngularCompilerPlugin"); +const RemoveStrictPlugin = require( 'remove-strict-webpack-plugin' ); const hashSalt = Date.now().toString(); module.exports = env => { @@ -34,6 +35,9 @@ module.exports = env => { const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot)); const appResourcesPlatformDir = platform === "android" ? "Android" : "iOS"; + // Workaround for CLI issue in version `6.0.0-2019-06-19-13454` + env.unitTesting = true; + const { // The 'appPath' and 'appResourcesPath' values are fetched from // the nsconfig.json configuration file @@ -314,5 +318,11 @@ module.exports = env => { config.plugins.push(new webpack.HotModuleReplacementPlugin()); } + // Workaround for issue caused by + // `https://github.com/NativeScript/nativescript-angular/blob/f506b3cb047180c7e208b49ab2def690fad6691e/nativescript-angular/http-client/http-client.module.ts#L5-L7 + if (unitTesting) { + config.plugins.push(new RemoveStrictPlugin()); + } + return config; }; From 060aabf146aa0f132f3617dcfaeea0efa7baf228 Mon Sep 17 00:00:00 2001 From: VladimirAmiorkov Date: Mon, 24 Jun 2019 14:29:41 +0300 Subject: [PATCH 11/14] chore: update Angular deps --- e2e/animation-examples/package.json | 28 +++++++++++----------- e2e/modal-navigation-ng/package.json | 20 ++++++++-------- e2e/nested-router-tab-view/package.json | 20 ++++++++-------- e2e/renderer/package.json | 18 +++++++------- e2e/routable-animations/package.json | 20 ++++++++-------- e2e/router-tab-view/package.json | 16 ++++++------- e2e/router/package.json | 20 ++++++++-------- e2e/single-page/package.json | 20 ++++++++-------- e2e/tests-app-ng/package.json | 14 +++++------ nativescript-angular/package.json | 32 ++++++++++++------------- ng-sample/package.json | 16 ++++++------- tests/package.json | 16 ++++++------- 12 files changed, 120 insertions(+), 120 deletions(-) diff --git a/e2e/animation-examples/package.json b/e2e/animation-examples/package.json index a9747cd56..fbcb1370d 100644 --- a/e2e/animation-examples/package.json +++ b/e2e/animation-examples/package.json @@ -9,29 +9,29 @@ "version": "latest" }, "tns-android": { - "version": "5.4.0-2019-05-02-235338-05" + "version": "latest" } }, "dependencies": { - "@angular/animations": "8.0.0", - "@angular/common": "8.0.0", - "@angular/compiler": "8.0.0", - "@angular/core": "8.0.0", - "@angular/forms": "8.0.0", + "@angular/animations": "~8.0.0", + "@angular/common": "~8.0.0", + "@angular/compiler": "~8.0.0", + "@angular/core": "~8.0.0", + "@angular/forms": "~8.0.0", "@angular/http": "8.0.0-beta.10", - "@angular/platform-browser": "8.0.0", - "@angular/platform-browser-dynamic": "8.0.0", - "@angular/router": "8.0.0", + "@angular/platform-browser": "~8.0.0", + "@angular/platform-browser-dynamic": "~8.0.0", + "@angular/router": "~8.0.0", "nativescript-angular": "file:../../nativescript-angular", "nativescript-theme-core": "~1.0.2", "reflect-metadata": "~0.1.8", "rxjs": "^6.3.3", - "tns-core-modules": "^5.4.0-next-2019-05-01-141636-02", + "tns-core-modules": "next", "zone.js": "^0.9.1" }, "devDependencies": { - "@angular/compiler-cli": "8.0.0", - "@ngtools/webpack": "8.0.0", + "@angular/compiler-cli": "~8.0.0", + "@ngtools/webpack": "~8.0.0", "@types/chai": "~4.1.7", "@types/mocha": "~5.2.5", "@types/node": "~10.12.18", @@ -43,8 +43,8 @@ "mochawesome": "~3.1.2", "nativescript-css-loader": "~0.26.0", "nativescript-dev-appium": "next", - "nativescript-dev-typescript": "^0.9.1-next-2019-03-12-162713-03", - "nativescript-dev-webpack": "^0.22.0-next-2019-04-17-111030-01", + "nativescript-dev-typescript": "next", + "nativescript-dev-webpack": "next", "typescript": "~3.4.5" }, "scripts": { diff --git a/e2e/modal-navigation-ng/package.json b/e2e/modal-navigation-ng/package.json index e3d4a56c6..9eae37e01 100644 --- a/e2e/modal-navigation-ng/package.json +++ b/e2e/modal-navigation-ng/package.json @@ -13,15 +13,15 @@ } }, "dependencies": { - "@angular/animations": "8.0.0", - "@angular/common": "8.0.0", - "@angular/compiler": "8.0.0", - "@angular/core": "8.0.0", - "@angular/forms": "8.0.0", + "@angular/animations": "~8.0.0", + "@angular/common": "~8.0.0", + "@angular/compiler": "~8.0.0", + "@angular/core": "~8.0.0", + "@angular/forms": "~8.0.0", "@angular/http": "8.0.0-beta.10", - "@angular/platform-browser": "8.0.0", - "@angular/platform-browser-dynamic": "8.0.0", - "@angular/router": "8.0.0", + "@angular/platform-browser": "~8.0.0", + "@angular/platform-browser-dynamic": "~8.0.0", + "@angular/router": "~8.0.0", "nativescript-angular": "file:../../nativescript-angular", "nativescript-dev-webpack": "webpack", "nativescript-theme-core": "~1.0.4", @@ -31,8 +31,8 @@ "zone.js": "^0.9.1" }, "devDependencies": { - "@angular/compiler-cli": "8.0.0", - "@ngtools/webpack": "8.0.0", + "@angular/compiler-cli": "~8.0.0", + "@ngtools/webpack": "~8.0.0", "@types/chai": "~4.1.7", "@types/mocha": "~5.2.5", "@types/node": "~10.12.18", diff --git a/e2e/nested-router-tab-view/package.json b/e2e/nested-router-tab-view/package.json index 5024a56e5..8d6fa7958 100644 --- a/e2e/nested-router-tab-view/package.json +++ b/e2e/nested-router-tab-view/package.json @@ -13,15 +13,15 @@ } }, "dependencies": { - "@angular/animations": "8.0.0", - "@angular/common": "8.0.0", - "@angular/compiler": "8.0.0", - "@angular/core": "8.0.0", - "@angular/forms": "8.0.0", + "@angular/animations": "~8.0.0", + "@angular/common": "~8.0.0", + "@angular/compiler": "~8.0.0", + "@angular/core": "~8.0.0", + "@angular/forms": "~8.0.0", "@angular/http": "8.0.0-beta.10", - "@angular/platform-browser": "8.0.0", - "@angular/platform-browser-dynamic": "8.0.0", - "@angular/router": "8.0.0", + "@angular/platform-browser": "~8.0.0", + "@angular/platform-browser-dynamic": "~8.0.0", + "@angular/router": "~8.0.0", "nativescript-angular": "file:../../nativescript-angular", "nativescript-dev-webpack": "webpack", "nativescript-theme-core": "~1.0.4", @@ -31,8 +31,8 @@ "zone.js": "^0.9.1" }, "devDependencies": { - "@angular/compiler-cli": "8.0.0", - "@ngtools/webpack": "8.0.0", + "@angular/compiler-cli": "~8.0.0", + "@ngtools/webpack": "~8.0.0", "@types/chai": "~4.1.7", "@types/mocha": "~5.2.5", "@types/node": "~10.12.18", diff --git a/e2e/renderer/package.json b/e2e/renderer/package.json index 1b361039c..ccb61a320 100644 --- a/e2e/renderer/package.json +++ b/e2e/renderer/package.json @@ -7,14 +7,14 @@ "id": "org.nativescript.renderer" }, "dependencies": { - "@angular/common": "8.0.0", - "@angular/compiler": "8.0.0", - "@angular/core": "8.0.0", - "@angular/forms": "8.0.0", + "@angular/common": "~8.0.0", + "@angular/compiler": "~8.0.0", + "@angular/core": "~8.0.0", + "@angular/forms": "~8.0.0", "@angular/http": "8.0.0-beta.10", - "@angular/platform-browser": "8.0.0", - "@angular/platform-browser-dynamic": "8.0.0", - "@angular/router": "8.0.0", + "@angular/platform-browser": "~8.0.0", + "@angular/platform-browser-dynamic": "~8.0.0", + "@angular/router": "~8.0.0", "nativescript-angular": "file:../../nativescript-angular", "nativescript-intl": "^3.0.0", "reflect-metadata": "~0.1.8", @@ -23,8 +23,8 @@ "zone.js": "^0.9.1" }, "devDependencies": { - "@angular/compiler-cli": "8.0.0", - "@ngtools/webpack": "8.0.0", + "@angular/compiler-cli": "~8.0.0", + "@ngtools/webpack": "~8.0.0", "@types/chai": "~4.1.7", "@types/mocha": "~5.2.5", "@types/node": "~10.12.18", diff --git a/e2e/routable-animations/package.json b/e2e/routable-animations/package.json index 89a5ca351..e7d9fae01 100644 --- a/e2e/routable-animations/package.json +++ b/e2e/routable-animations/package.json @@ -7,15 +7,15 @@ "id": "org.nativescript.nsroanimations" }, "dependencies": { - "@angular/animations": "8.0.0", - "@angular/common": "8.0.0", - "@angular/compiler": "8.0.0", - "@angular/core": "8.0.0", - "@angular/forms": "8.0.0", + "@angular/animations": "~8.0.0", + "@angular/common": "~8.0.0", + "@angular/compiler": "~8.0.0", + "@angular/core": "~8.0.0", + "@angular/forms": "~8.0.0", "@angular/http": "8.0.0-beta.10", - "@angular/platform-browser": "8.0.0", - "@angular/platform-browser-dynamic": "8.0.0", - "@angular/router": "8.0.0", + "@angular/platform-browser": "~8.0.0", + "@angular/platform-browser-dynamic": "~8.0.0", + "@angular/router": "~8.0.0", "nativescript-angular": "next", "nativescript-theme-core": "~1.0.2", "reflect-metadata": "~0.1.8", @@ -24,8 +24,8 @@ "zone.js": "^0.9.1" }, "devDependencies": { - "@ngtools/webpack": "8.0.0", - "@angular/compiler-cli": "8.0.0", + "@ngtools/webpack": "~8.0.0", + "@angular/compiler-cli": "~8.0.0", "@types/chai": "~4.1.3", "@types/mocha": "~5.2.1", "@types/node": "^7.0.5", diff --git a/e2e/router-tab-view/package.json b/e2e/router-tab-view/package.json index 0619d458b..9ddd20551 100644 --- a/e2e/router-tab-view/package.json +++ b/e2e/router-tab-view/package.json @@ -13,15 +13,15 @@ } }, "dependencies": { - "@angular/animations": "8.0.0", - "@angular/common": "8.0.0", - "@angular/compiler": "8.0.0", - "@angular/core": "8.0.0", - "@angular/forms": "8.0.0", + "@angular/animations": "~8.0.0", + "@angular/common": "~8.0.0", + "@angular/compiler": "~8.0.0", + "@angular/core": "~8.0.0", + "@angular/forms": "~8.0.0", "@angular/http": "8.0.0-beta.10", - "@angular/platform-browser": "8.0.0", - "@angular/platform-browser-dynamic": "8.0.0", - "@angular/router": "8.0.0", + "@angular/platform-browser": "~8.0.0", + "@angular/platform-browser-dynamic": "~8.0.0", + "@angular/router": "~8.0.0", "nativescript-angular": "file:../../nativescript-angular", "nativescript-dev-webpack": "webpack", "nativescript-theme-core": "~1.0.4", diff --git a/e2e/router/package.json b/e2e/router/package.json index 7467fec70..06f280221 100644 --- a/e2e/router/package.json +++ b/e2e/router/package.json @@ -10,15 +10,15 @@ } }, "dependencies": { - "@angular/animations": "8.0.0", - "@angular/common": "8.0.0", - "@angular/compiler": "8.0.0", - "@angular/core": "8.0.0", - "@angular/forms": "8.0.0", + "@angular/animations": "~8.0.0", + "@angular/common": "~8.0.0", + "@angular/compiler": "~8.0.0", + "@angular/core": "~8.0.0", + "@angular/forms": "~8.0.0", "@angular/http": "8.0.0-beta.10", - "@angular/platform-browser": "8.0.0", - "@angular/platform-browser-dynamic": "8.0.0", - "@angular/router": "8.0.0", + "@angular/platform-browser": "~8.0.0", + "@angular/platform-browser-dynamic": "~8.0.0", + "@angular/router": "~8.0.0", "nativescript-angular": "file:../../nativescript-angular", "nativescript-intl": "^3.0.0", "reflect-metadata": "~0.1.8", @@ -27,8 +27,8 @@ "zone.js": "^0.9.1" }, "devDependencies": { - "@angular/compiler-cli": "8.0.0", - "@ngtools/webpack": "8.0.0", + "@angular/compiler-cli": "~8.0.0", + "@ngtools/webpack": "~8.0.0", "@types/chai": "~4.1.7", "@types/mocha": "~5.2.5", "@types/node": "^10.12.12", diff --git a/e2e/single-page/package.json b/e2e/single-page/package.json index 7e2886386..3d208aea7 100644 --- a/e2e/single-page/package.json +++ b/e2e/single-page/package.json @@ -13,15 +13,15 @@ } }, "dependencies": { - "@angular/animations": "8.0.0", - "@angular/common": "8.0.0", - "@angular/compiler": "8.0.0", - "@angular/core": "8.0.0", - "@angular/forms": "8.0.0", + "@angular/animations": "~8.0.0", + "@angular/common": "~8.0.0", + "@angular/compiler": "~8.0.0", + "@angular/core": "~8.0.0", + "@angular/forms": "~8.0.0", "@angular/http": "8.0.0-beta.10", - "@angular/platform-browser": "8.0.0", - "@angular/platform-browser-dynamic": "8.0.0", - "@angular/router": "8.0.0", + "@angular/platform-browser": "~8.0.0", + "@angular/platform-browser-dynamic": "~8.0.0", + "@angular/router": "~8.0.0", "nativescript-angular": "file:../../nativescript-angular", "nativescript-intl": "^3.0.0", "reflect-metadata": "~0.1.8", @@ -30,8 +30,8 @@ "zone.js": "^0.9.1" }, "devDependencies": { - "@angular/compiler-cli": "8.0.0", - "@ngtools/webpack": "8.0.0", + "@angular/compiler-cli": "~8.0.0", + "@ngtools/webpack": "~8.0.0", "@types/chai": "~4.1.7", "@types/mocha": "~5.2.5", "@types/node": "~10.12.18", diff --git a/e2e/tests-app-ng/package.json b/e2e/tests-app-ng/package.json index 08f717f23..cbb98810e 100644 --- a/e2e/tests-app-ng/package.json +++ b/e2e/tests-app-ng/package.json @@ -13,13 +13,13 @@ } }, "dependencies": { - "@angular/common": "8.0.0", - "@angular/compiler": "8.0.0", - "@angular/core": "8.0.0", - "@angular/forms": "8.0.0", - "@angular/platform-browser": "8.0.0", - "@angular/platform-browser-dynamic": "8.0.0", - "@angular/router": "8.0.0", + "@angular/common": "~8.0.0", + "@angular/compiler": "~8.0.0", + "@angular/core": "~8.0.0", + "@angular/forms": "~8.0.0", + "@angular/platform-browser": "~8.0.0", + "@angular/platform-browser-dynamic": "~8.0.0", + "@angular/router": "~8.0.0", "nativescript-angular": "next", "nativescript-intl": "~3.0.0", "nativescript-theme-core": "^1.0.4", diff --git a/nativescript-angular/package.json b/nativescript-angular/package.json index 6439dc7c9..901bc399c 100644 --- a/nativescript-angular/package.json +++ b/nativescript-angular/package.json @@ -45,30 +45,30 @@ "reflect-metadata": "^0.1.8" }, "peerDependencies": { - "@angular/platform-browser-dynamic": "8.0.0", - "@angular/common": "8.0.0", - "@angular/compiler": "8.0.0", - "@angular/core": "8.0.0", - "@angular/forms": "8.0.0", + "@angular/platform-browser-dynamic": "~8.0.0", + "@angular/common": "~8.0.0", + "@angular/compiler": "~8.0.0", + "@angular/core": "~8.0.0", + "@angular/forms": "~8.0.0", "@angular/http": "8.0.0-beta.10", - "@angular/platform-browser": "8.0.0", - "@angular/router": "8.0.0", + "@angular/platform-browser": "~8.0.0", + "@angular/router": "~8.0.0", "rxjs": "^6.3.3", "tns-core-modules": "^5.1.0 || >5.1.0- || >5.2.0-", "typescript": "~3.4.5", "zone.js": "^0.9.1" }, "devDependencies": { - "@angular/animations": "8.0.0", - "@angular/common": "8.0.0", - "@angular/compiler": "8.0.0", - "@angular/compiler-cli": "8.0.0", - "@angular/core": "8.0.0", - "@angular/forms": "8.0.0", + "@angular/animations": "~8.0.0", + "@angular/common": "~8.0.0", + "@angular/compiler": "~8.0.0", + "@angular/compiler-cli": "~8.0.0", + "@angular/core": "~8.0.0", + "@angular/forms": "~8.0.0", "@angular/http": "8.0.0-beta.10", - "@angular/platform-browser": "8.0.0", - "@angular/platform-browser-dynamic": "8.0.0", - "@angular/router": "8.0.0", + "@angular/platform-browser": "~8.0.0", + "@angular/platform-browser-dynamic": "~8.0.0", + "@angular/router": "~8.0.0", "codelyzer": "^4.5.0", "conventional-changelog-cli": "^1.3.22", "rxjs": "~6.3.3", diff --git a/ng-sample/package.json b/ng-sample/package.json index aba4a594b..019f35337 100644 --- a/ng-sample/package.json +++ b/ng-sample/package.json @@ -32,15 +32,15 @@ }, "homepage": "https://github.com/NativeScript/template-hello-world", "dependencies": { - "@angular/animations": "8.0.0", - "@angular/common": "8.0.0", - "@angular/compiler": "8.0.0", - "@angular/core": "8.0.0", - "@angular/forms": "8.0.0", + "@angular/animations": "~8.0.0", + "@angular/common": "~8.0.0", + "@angular/compiler": "~8.0.0", + "@angular/core": "~8.0.0", + "@angular/forms": "~8.0.0", "@angular/http": "8.0.0-beta.10", - "@angular/platform-browser": "8.0.0", - "@angular/platform-browser-dynamic": "8.0.0", - "@angular/router": "8.0.0", + "@angular/platform-browser": "~8.0.0", + "@angular/platform-browser-dynamic": "~8.0.0", + "@angular/router": "~8.0.0", "nativescript-angular": "file:../nativescript-angular", "rxjs": "~6.3.3", "tns-core-modules": "next", diff --git a/tests/package.json b/tests/package.json index bbf5b08fd..c80098be9 100644 --- a/tests/package.json +++ b/tests/package.json @@ -25,15 +25,15 @@ ], "homepage": "http://nativescript.org", "dependencies": { - "@angular/animations": "8.0.0", - "@angular/common": "8.0.0", - "@angular/compiler": "8.0.0", - "@angular/core": "8.0.0", - "@angular/forms": "8.0.0", + "@angular/animations": "~8.0.0", + "@angular/common": "~8.0.0", + "@angular/compiler": "~8.0.0", + "@angular/core": "~8.0.0", + "@angular/forms": "~8.0.0", "@angular/http": "8.0.0-beta.10", - "@angular/platform-browser": "8.0.0", - "@angular/platform-browser-dynamic": "8.0.0", - "@angular/router": "8.0.0", + "@angular/platform-browser": "~8.0.0", + "@angular/platform-browser-dynamic": "~8.0.0", + "@angular/router": "~8.0.0", "nativescript-angular": "../nativescript-angular", "nativescript-unit-test-runner": "~0.6.3", "rxjs": "~6.3.3", From 69edae4192e2fc997f2432f1eedaaa1acb2d6eae Mon Sep 17 00:00:00 2001 From: VladimirAmiorkov Date: Tue, 25 Jun 2019 13:09:46 +0300 Subject: [PATCH 12/14] chore: update `nativescript-dev-webpack` to next --- e2e/modal-navigation-ng/package.json | 2 +- e2e/nested-router-tab-view/package.json | 2 +- e2e/router-tab-view/package.json | 2 +- tests/package.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e/modal-navigation-ng/package.json b/e2e/modal-navigation-ng/package.json index 9eae37e01..e3d559af2 100644 --- a/e2e/modal-navigation-ng/package.json +++ b/e2e/modal-navigation-ng/package.json @@ -23,7 +23,7 @@ "@angular/platform-browser-dynamic": "~8.0.0", "@angular/router": "~8.0.0", "nativescript-angular": "file:../../nativescript-angular", - "nativescript-dev-webpack": "webpack", + "nativescript-dev-webpack": "next", "nativescript-theme-core": "~1.0.4", "reflect-metadata": "~0.1.8", "rxjs": "~6.3.3", diff --git a/e2e/nested-router-tab-view/package.json b/e2e/nested-router-tab-view/package.json index 8d6fa7958..ea1c576b2 100644 --- a/e2e/nested-router-tab-view/package.json +++ b/e2e/nested-router-tab-view/package.json @@ -23,7 +23,7 @@ "@angular/platform-browser-dynamic": "~8.0.0", "@angular/router": "~8.0.0", "nativescript-angular": "file:../../nativescript-angular", - "nativescript-dev-webpack": "webpack", + "nativescript-dev-webpack": "next", "nativescript-theme-core": "~1.0.4", "reflect-metadata": "~0.1.8", "rxjs": "~6.3.3", diff --git a/e2e/router-tab-view/package.json b/e2e/router-tab-view/package.json index 9ddd20551..d1758be19 100644 --- a/e2e/router-tab-view/package.json +++ b/e2e/router-tab-view/package.json @@ -23,7 +23,7 @@ "@angular/platform-browser-dynamic": "~8.0.0", "@angular/router": "~8.0.0", "nativescript-angular": "file:../../nativescript-angular", - "nativescript-dev-webpack": "webpack", + "nativescript-dev-webpack": "next", "nativescript-theme-core": "~1.0.4", "reflect-metadata": "~0.1.8", "rxjs": "~6.3.3", diff --git a/tests/package.json b/tests/package.json index c80098be9..794743063 100644 --- a/tests/package.json +++ b/tests/package.json @@ -61,7 +61,7 @@ "lazy": "1.0.11", "mocha": "6.1.4", "nativescript-dev-typescript": "next", - "nativescript-dev-webpack": "webpack", + "nativescript-dev-webpack": "next", "remove-strict-webpack-plugin": "~0.1.2", "sinon": "^7.3.2", "tslint": "^4.5.1", From 1bf07f5656ed666de6f135934f7f971fa245d607 Mon Sep 17 00:00:00 2001 From: SvetoslavTsenov Date: Tue, 25 Jun 2019 14:20:08 +0300 Subject: [PATCH 13/14] refactor: unit-test configs --- tests/karma.conf.js | 1 + tests/webpack.config.js | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/karma.conf.js b/tests/karma.conf.js index 91c67210c..96ee10227 100644 --- a/tests/karma.conf.js +++ b/tests/karma.conf.js @@ -102,6 +102,7 @@ function setWebpack(config, options) { const env = {}; env[config.platform] = true; env.sourceMap = config.debugBrk; + env.unitTesting = true; options.webpack = require('./webpack.config')(env); delete options.webpack.entry; delete options.webpack.output.libraryTarget; diff --git a/tests/webpack.config.js b/tests/webpack.config.js index bdf8ff91d..bc4bf2305 100644 --- a/tests/webpack.config.js +++ b/tests/webpack.config.js @@ -35,9 +35,6 @@ module.exports = env => { const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot)); const appResourcesPlatformDir = platform === "android" ? "Android" : "iOS"; - // Workaround for CLI issue in version `6.0.0-2019-06-19-13454` - env.unitTesting = true; - const { // The 'appPath' and 'appResourcesPath' values are fetched from // the nsconfig.json configuration file From 6c0f74d16d2879b08e8e86719406ef67e629c15f Mon Sep 17 00:00:00 2001 From: SvetoslavTsenov Date: Tue, 25 Jun 2019 14:37:32 +0300 Subject: [PATCH 14/14] test: update webpack config --- tests/karma.conf.js | 4 ++++ tests/webpack.config.js | 7 ------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/karma.conf.js b/tests/karma.conf.js index 96ee10227..cfac187c6 100644 --- a/tests/karma.conf.js +++ b/tests/karma.conf.js @@ -1,3 +1,6 @@ + +const RemoveStrictPlugin = require( 'remove-strict-webpack-plugin' ); + module.exports = function (config) { const options = { @@ -108,5 +111,6 @@ function setWebpack(config, options) { delete options.webpack.output.libraryTarget; const invalidPluginsForUnitTesting = ["GenerateBundleStarterPlugin", "GenerateNativeScriptEntryPointsPlugin"]; options.webpack.plugins = options.webpack.plugins.filter(p => !invalidPluginsForUnitTesting.includes(p.constructor.name)); + options.webpack.plugins.push(new RemoveStrictPlugin()); } } diff --git a/tests/webpack.config.js b/tests/webpack.config.js index bc4bf2305..0d150698a 100644 --- a/tests/webpack.config.js +++ b/tests/webpack.config.js @@ -13,7 +13,6 @@ const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer"); const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin"); const TerserPlugin = require("terser-webpack-plugin"); const { getAngularCompilerPlugin } = require("nativescript-dev-webpack/plugins/NativeScriptAngularCompilerPlugin"); -const RemoveStrictPlugin = require( 'remove-strict-webpack-plugin' ); const hashSalt = Date.now().toString(); module.exports = env => { @@ -315,11 +314,5 @@ module.exports = env => { config.plugins.push(new webpack.HotModuleReplacementPlugin()); } - // Workaround for issue caused by - // `https://github.com/NativeScript/nativescript-angular/blob/f506b3cb047180c7e208b49ab2def690fad6691e/nativescript-angular/http-client/http-client.module.ts#L5-L7 - if (unitTesting) { - config.plugins.push(new RemoveStrictPlugin()); - } - return config; };