diff --git a/src/app.nativescript/_files/app/main.ts b/src/app.nativescript/_files/app/main.ts index e944956d..558760dd 100644 --- a/src/app.nativescript/_files/app/main.ts +++ b/src/app.nativescript/_files/app/main.ts @@ -1,7 +1,6 @@ // https://github.com/NativeScript/nativescript-dev-webpack/issues/660#issuecomment-422711983 import 'reflect-metadata'; import { platformNativeScriptDynamic } from 'nativescript-angular/platform'; -import { AppOptions } from 'nativescript-angular/platform-common'; import { enableProdMode } from '@angular/core'; import { AppModule } from './app.module'; @@ -11,25 +10,4 @@ if (typeof __UGLIFIED__ !== 'undefined' && __UGLIFIED__) { require('@angular/core').enableProdMode(); } -let options: AppOptions = {}; -if (module['hot']) { - <% if (routing || sample) { %> - // attach to livesync hooks and perform navigation - require('@<%= npmScope %>/nativescript').attachLivesyncNavigation(); - <% } %> - const hmrUpdate = require('nativescript-dev-webpack/hmr').hmrUpdate; - - options.hmrOptions = { - moduleTypeFactory: () => AppModule, - livesyncCallback: platformReboot => { - console.log('HMR: Sync...'); - hmrUpdate(); - setTimeout(platformReboot, 0); - } - }; - hmrUpdate(); - - module['hot'].accept(['./app.module']); -} - -platformNativeScriptDynamic(options).bootstrapModule(AppModule); +platformNativeScriptDynamic().bootstrapModule(AppModule); diff --git a/src/app.nativescript/_files/package.json b/src/app.nativescript/_files/package.json index bb3a4716..124d10d8 100644 --- a/src/app.nativescript/_files/package.json +++ b/src/app.nativescript/_files/package.json @@ -38,16 +38,16 @@ "nativescript-theme-core": "file:../../node_modules/nativescript-theme-core", "reflect-metadata": "file:../../node_modules/reflect-metadata", "rxjs": "file:../../node_modules/rxjs", - "rxjs-compat": "file:../../node_modules/rxjs-compat", "tns-core-modules": "file:../../node_modules/tns-core-modules", "zone.js": "file:../../node_modules/zone.js" }, "devDependencies": { - "@angular/compiler-cli": "~7.1.0", + "@angular/compiler-cli": "~7.2.0", "@angular/language-service": "file:../../node_modules/@angular/language-service", - "@ngtools/webpack": "~7.1.0", + "@ngtools/webpack": "~7.2.0", "codelyzer": "file:../../node_modules/codelyzer", - "nativescript-dev-webpack": "~0.18.0", + "nativescript-dev-webpack": "~0.20.0", + "terser-webpack-plugin": "file:../../node_modules/terser-webpack-plugin", "tns-platform-declarations": "file:../../node_modules/tns-platform-declarations", "typescript": "file:../../node_modules/typescript" } diff --git a/src/app.nativescript/_files/webpack.config.js b/src/app.nativescript/_files/webpack.config.js index 7eee7c0d..6fde319a 100644 --- a/src/app.nativescript/_files/webpack.config.js +++ b/src/app.nativescript/_files/webpack.config.js @@ -1,295 +1,319 @@ -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 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 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 { AngularCompilerPlugin } = require('@ngtools/webpack'); 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", - ]; + // 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 platform = env && ((env.android && 'android') || (env.ios && 'ios')); + if (!platform) { + throw new Error('You need to provide a target platform!'); + } - const projectRoot = __dirname; + const projectRoot = __dirname; - // Default destination inside platforms//... - const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot)); - const appResourcesPlatformDir = platform === "android" ? "Android" : "iOS"; + // 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", + 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 - uglify, // --env.uglify - report, // --env.report - sourceMap, // --env.sourceMap - hmr, // --env.hmr, - } = env; - const externals = (env.externals || []).map((e) => { // --env.externals - return new RegExp(e + ".*"); - }); + // You can provide the following flags when running 'tns run android|ios' + aot, // --env.aot + snapshot, // --env.snapshot + uglify, // --env.uglify + report, // --env.report + sourceMap, // --env.sourceMap + hmr // --env.hmr, + } = env; - const appFullPath = resolve(projectRoot, appPath); - const appResourcesFullPath = resolve(projectRoot, appResourcesPath); + 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 entries = { bundle: entryPath }; + if (platform === 'ios') { + entries['tns_modules/tns-core-modules/inspector_modules'] = 'inspector_modules.js'; + } - const entryModule = `${nsWebpack.getEntryModule(appFullPath)}.ts`; - const entryPath = `.${sep}${entryModule}`; + const ngCompilerTransformers = []; + const additionalLazyModuleResources = []; + if (aot) { + ngCompilerTransformers.push(nsReplaceBootstrap); + } - const ngCompilerPlugin = new AngularCompilerPlugin({ - hostReplacementPaths: nsWebpack.getResolver([platform, "tns"]), - platformTransformers: aot ? [nsReplaceBootstrap(() => ngCompilerPlugin)] : null, - mainPath: resolve(appPath, entryModule), - tsConfigPath: join(__dirname, "tsconfig.tns.json"), - skipCodeGeneration: !aot, - sourceMap: !!sourceMap, - }); + if (hmr) { + ngCompilerTransformers.push(nsSupportHmrNg); + } - const config = { - mode: uglify ? "production" : "development", - context: appFullPath, - externals, - watchOptions: { - ignored: [ - appResourcesFullPath, - // Don't watch hidden files - "**/.*", - ] - }, - target: nativescriptTarget, - entry: { - bundle: entryPath, - }, - output: { - pathinfo: false, - path: dist, - libraryTarget: "commonjs2", - filename: "[name].js", - globalObject: "global", - }, - 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 + // 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))), + mainPath: resolve(appPath, entryModule), + tsConfigPath: join(__dirname, tsConfigName), + skipCodeGeneration: !aot, + sourceMap: !!sourceMap, + additionalLazyModuleResources: additionalLazyModuleResources + }); + + const config = { + mode: uglify ? 'production' : 'development', + context: appFullPath, + externals, + watchOptions: { + ignored: [ + appResourcesFullPath, + // Don't watch hidden files + '**/.*' + ] + }, + target: nativescriptTarget, + entry: entries, + output: { + pathinfo: false, + path: dist, + libraryTarget: 'commonjs2', + filename: '[name].js', + globalObject: 'global' + }, + 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: 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); }, - symlinks: true - }, - resolveLoader: { - symlinks: false - }, - node: { - // Disable node shims that conflict with NativeScript - "http": false, - "timers": false, - "setImmediate": false, - "fs": "empty", - "__dirname": false, - }, - devtool: sourceMap ? "inline-source-map" : "none", - optimization: { - 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, - }, - } + enforce: true + } + } + }, + minimize: !!uglify, + minimizer: [ + new TerserPlugin({ + parallel: true, + cache: true, + terserOptions: { + output: { + comments: false + }, + compress: { + // The Android SBG has problems parsing the output + // when these options are enabled + collapse_vars: platform !== 'android', + sequences: platform !== 'android', + // custom + drop_console: true, + drop_debugger: true, + ecma: 6, + keep_infinity: platform === 'android', // for Chrome/V8 + reduce_funcs: platform !== 'android', // for Chrome/V8 + pure_funcs: ['this._log.debug', 'this._log.error', 'this._log.info', 'this._log.warn'], + global_defs: { + __UGLIFIED__: true + } + }, + // custom + ecma: 6, + safari10: platform !== 'android' + } + }) + ] + }, + module: { + rules: [ + { + test: new RegExp(entryPath), + use: [ + // Require all Android app components + platform === 'android' && { + loader: 'nativescript-dev-webpack/android-app-components-loader', + options: { modules: appComponents } }, - minimize: !!uglify, - minimizer: [ - new UglifyJsPlugin({ - parallel: true, - cache: true, - uglifyOptions: { - output: { - comments: false, - }, - compress: { - // The Android SBG has problems parsing the output - // when these options are enabled - collapse_vars: platform !== "android", - sequences: platform !== "android", - // custom - drop_console : true, - drop_debugger: true, - ecma: 6, - keep_infinity: platform === 'android', // for Chrome/V8 - reduce_funcs : platform !== 'android', // for Chrome/V8 - pure_funcs : [ - 'this._log.debug', - 'this._log.error', - 'this._log.info', - 'this._log.warn', - ], - global_defs: { - __UGLIFIED__: true, - } - }, - // custom - ecma: 6, - safari10: platform !== 'android' - } - }) - ], - }, - module: { - rules: [ - { - test: new RegExp(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 - } - }, - ].filter(loader => !!loader) - }, - { test: /\.html$|\.xml$/, use: "raw-loader" }, + { + loader: 'nativescript-dev-webpack/bundle-config-loader', + options: { + angular: true, + loadCss: !snapshot // load the application css if in debug mode + } + } + ].filter(loader => !!loader) + }, - // 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 }, - } - }, - { - test: /[\/|\\]app\.scss$/, - use: [ - { loader: "css-loader", options: { minimize: false, url: false } }, - "sass-loader" - ] - }, + { test: /\.html$|\.xml$/, use: 'raw-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"] }, + // 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: { minimize: false, url: false } }] + }, + { + test: /[\/|\\]app\.scss$/, + use: [ + 'nativescript-dev-webpack/style-hot-loader', + { loader: 'css-loader', options: { minimize: false, url: false } }, + 'sass-loader' + ] + }, - { - test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/, - use: [ - "nativescript-dev-webpack/moduleid-compat-loader", - "@ngtools/webpack", - ] - }, + // 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'] }, - // 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 }, - }, - ], + // Compile TypeScript files with ahead-of-time compiler + { + test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/, + exclude: /\.worker\.ts$/, + use: ['nativescript-dev-webpack/moduleid-compat-loader', 'nativescript-dev-webpack/lazy-ngmodule-hot-loader', '@ngtools/webpack'] }, - 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([`${dist}/**/*`]), - // Copy native app resources to out dir. - new CopyWebpackPlugin([ - { - from: `${appResourcesFullPath}/${appResourcesPlatformDir}`, - to: `${dist}/App_Resources/${appResourcesPlatformDir}`, - context: projectRoot - }, - ]), - // Copy assets to out dir. Add your own globs as needed. - new CopyWebpackPlugin([ - { from: "assets/**" }, - { from: "fonts/**" } - ], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }), - // Generate a bundle starter script and activate it in package.json - new nsWebpack.GenerateBundleStarterPlugin([ - "./vendor", - "./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(), - ], - }; + // Compile Worker files with ts-loader + { test: /\.worker\.ts$/, loader: 'ts-loader' }, - 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`), - })); - } + // 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([`${dist}/**/*`]), + // Copy native app resources to out dir. + new CopyWebpackPlugin([ + { + from: `${appResourcesFullPath}/${appResourcesPlatformDir}`, + to: `${dist}/App_Resources/${appResourcesPlatformDir}`, + context: projectRoot + } + ]), + // Copy assets to out dir. Add your own globs as needed. + new CopyWebpackPlugin([{ from: { glob: 'assets/**' } }, { from: { glob: 'fonts/**' } }], { + ignore: [`${relative(appPath, appResourcesFullPath)}/**`] + }), + // Generate a bundle starter script and activate it in package.json + new nsWebpack.GenerateBundleStarterPlugin( + // Don't include `runtime.js` when creating a snapshot. The plugin + // configures the WebPack runtime to be generated inside the snapshot + // module and no `runtime.js` module exist. + (snapshot ? [] : ['./runtime']).concat(['./vendor', './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 (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 (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 (hmr) { - config.plugins.push(new webpack.HotModuleReplacementPlugin()); - } + 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; + return config; }; diff --git a/src/migrations/migrations.json b/src/migrations/migrations.json index a073ebb4..3d8b05f6 100644 --- a/src/migrations/migrations.json +++ b/src/migrations/migrations.json @@ -54,6 +54,11 @@ "version": "7.3.1", "description": "Update Electron to v4 and fix scripts", "factory": "./update-7-3-1/update-7-3-1" + }, + "update-to-7.3.2": { + "version": "7.3.2", + "description": "Update NativeScript to 5.2", + "factory": "./update-7-3-2/update-7-3-2" } } } \ No newline at end of file diff --git a/src/migrations/update-7-3-2/update-7-3-2.ts b/src/migrations/update-7-3-2/update-7-3-2.ts new file mode 100644 index 00000000..e6a4e44e --- /dev/null +++ b/src/migrations/update-7-3-2/update-7-3-2.ts @@ -0,0 +1,89 @@ +import { + chain, + Rule, + SchematicContext, + Tree +} from "@angular-devkit/schematics"; +import { join } from 'path'; +import * as fs from 'fs'; + +import { getJsonFromFile, updateJsonFile, createOrUpdate, updateJsonInTree } from '../../utils'; + +function updateNativeScriptApps(tree: Tree, context: SchematicContext) { + const appsDir = tree.getDir('apps'); + const appFolders = appsDir.subdirs; + const cwd = process.cwd(); + const mainPath = join(cwd, 'node_modules/@nstudio/schematics/src/app.nativescript/_files/app/main.ts'); + // console.log('webpackConfigPath:', webpackConfigPath); + let mainFile = fs.readFileSync(mainPath, 'UTF-8'); + const webpackConfigPath = join(cwd, 'node_modules/@nstudio/schematics/src/app.nativescript/_files/webpack.config.js'); + // console.log('webpackConfigPath:', webpackConfigPath); + const webpackConfig = fs.readFileSync(webpackConfigPath, 'UTF-8'); + + // update {N} apps and configs + for (const dir of appFolders) { + // console.log(dir); + if (dir.indexOf('nativescript-') === 0 || dir.indexOf('-nativescript') === 0) { + const appDir = `${appsDir.path}/${dir}`; + // console.log('appDir:', appDir); + + createOrUpdate( + tree, + `${appDir}/webpack.config.js`, + webpackConfig + ); + + createOrUpdate( + tree, + `${appDir}/app/main.ts`, + mainFile + ); + + // update {N} app deps + const packagePath = `${appDir}/package.json` + const packageJson = getJsonFromFile(tree, packagePath); + + if (packageJson) { + + packageJson.dependencies = packageJson.dependencies || {}; + packageJson.devDependencies = packageJson.devDependencies || {}; + packageJson.devDependencies = { + ...packageJson.devDependencies, + "@angular/compiler-cli": "~7.2.0", + "@ngtools/webpack": "~7.2.0", + "nativescript-dev-webpack": "~0.20.0", + "terser-webpack-plugin": "file:../../node_modules/terser-webpack-plugin" + }; + + // console.log('path:',path); + // console.log('packageJson overwrite:', JSON.stringify(packageJson)); + tree = updateJsonFile(tree, packagePath, packageJson); + } + } + } + return tree; +} + +function updateRootPackage(tree: Tree, context: SchematicContext) { + return updateJsonInTree("package.json", json => { + json.scripts = json.scripts || {}; + json.dependencies = json.dependencies || {}; + json.dependencies = { + ...json.dependencies, + "nativescript-angular": "~7.2.0", + "tns-core-modules": "~5.2.0" + } + json.devDependencies = json.devDependencies || {}; + json.devDependencies = { + ...json.devDependencies, + "terser-webpack-plugin": "~1.2.0", + "tns-platform-declarations": "~5.2.0" + } + + return json; + })(tree, context); +} + +export default function(): Rule { + return chain([updateNativeScriptApps, updateRootPackage]); +} diff --git a/src/utils/general.ts b/src/utils/general.ts index 1be84065..85783f6a 100644 --- a/src/utils/general.ts +++ b/src/utils/general.ts @@ -284,7 +284,7 @@ export function addRootDeps( if (targetPlatforms.nativescript) { dep = { name: "nativescript-angular", - version: "~7.1.0", + version: "~7.2.0", type: "dependency" }; deps.push(dep); @@ -303,25 +303,22 @@ export function addRootDeps( }; deps.push(dep); - // convenience for now since some {N} plugins may not support rxjs 6.x fully yet - // remove in future dep = { - name: "rxjs-compat", - version: "~6.3.3", + name: "tns-core-modules", + version: "~5.2.0", type: "dependency" }; deps.push(dep); dep = { - name: "tns-core-modules", - version: "~5.1.0", - type: "dependency" + name: "terser-webpack-plugin", + version: "~1.2.0", + type: "devDependency" }; - deps.push(dep); dep = { name: "tns-platform-declarations", - version: "~5.1.0", + version: "~5.2.0", type: "devDependency" }; deps.push(dep);