From 84204cda729ad8838cb8dc42de751189e75f181a Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Mon, 13 Jul 2020 18:02:10 -0700 Subject: [PATCH] chore: cleanup --- packages/webpack/hmr/hmr-update.ts | 8 ++-- packages/webpack/package.json | 5 +- packages/webpack/templates/webpack.angular.js | 5 -- .../webpack/templates/webpack.config.spec.ts | 47 ------------------- packages/webpack/tsconfig.json | 17 +++---- 5 files changed, 15 insertions(+), 67 deletions(-) diff --git a/packages/webpack/hmr/hmr-update.ts b/packages/webpack/hmr/hmr-update.ts index bde808342..398f5485e 100644 --- a/packages/webpack/hmr/hmr-update.ts +++ b/packages/webpack/hmr/hmr-update.ts @@ -1,13 +1,13 @@ import * as hot from '../hot'; -import { knownFolders, path, File } from '@nativescript/core'; declare const __webpack_require__: any; export function hmrUpdate() { - const currentAppFolder = knownFolders.currentApp(); + const coreFile = require('@nativescript/core'); + const currentAppFolder = coreFile.knownFolders.currentApp(); const latestHash = __webpack_require__['h'](); return hot(latestHash, (filename) => { - const fullFilePath = path.join(currentAppFolder.path, filename); - return File.exists(fullFilePath) ? currentAppFolder.getFile(filename) : null; + const fullFilePath = coreFile.path.join(currentAppFolder.path, filename); + return coreFile.File.exists(fullFilePath) ? currentAppFolder.getFile(filename) : null; }); } diff --git a/packages/webpack/package.json b/packages/webpack/package.json index 2dee7b7dd..9999787a4 100644 --- a/packages/webpack/package.json +++ b/packages/webpack/package.json @@ -73,7 +73,7 @@ "shelljs": "~0.8.4", "tapable": "~1.1.3", "terser": "~4.8.0", - "terser-webpack-plugin": "~3.0.0", + "terser-webpack-plugin": "~3.0.6", "ts-loader": "^7.0.0", "webpack": "~4.43.0", "webpack-bundle-analyzer": "~3.8.0", @@ -99,7 +99,6 @@ "nyc": "^15.1.0", "proxyquire": "~2.1.0", "source-map-support": "^0.5.13", - "@nativescript/core": "file:../core", - "typescript": "~3.9.0" + "typescript": "file:../../node_modules/typescript" } } diff --git a/packages/webpack/templates/webpack.angular.js b/packages/webpack/templates/webpack.angular.js index edd97db3c..0846c7b64 100644 --- a/packages/webpack/templates/webpack.angular.js +++ b/packages/webpack/templates/webpack.angular.js @@ -3,9 +3,6 @@ const { join, relative, resolve, sep, dirname } = require('path'); const webpack = require('webpack'); const nsWebpack = require('@nativescript/webpack'); const nativescriptTarget = require('@nativescript/webpack/nativescript-target'); -const { - nsReplaceLazyLoader -} = require('@nativescript/webpack/transformers/ns-replace-lazy-loader'); const { nsSupportHmrNg } = require('@nativescript/webpack/transformers/ns-support-hmr-ng'); @@ -115,8 +112,6 @@ module.exports = env => { 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); } diff --git a/packages/webpack/templates/webpack.config.spec.ts b/packages/webpack/templates/webpack.config.spec.ts index 2536baeae..eeca37d2b 100644 --- a/packages/webpack/templates/webpack.config.spec.ts +++ b/packages/webpack/templates/webpack.config.spec.ts @@ -200,53 +200,6 @@ describe('webpack.config.js', () => { expect(angularCompilerOptions.platformTransformers.length).toEqual(1); expect(angularCompilerOptions.platformTransformers[0]).toEqual(FakeHmrTransformerFlag); }); - - it('should contain the Lazy transformer when the @angular/core is an external module', () => { - const input = getInput({ platform, externals: ['@angular/core'] }); - - webpackConfig(input); - - expect(angularCompilerOptions).toBeDefined(); - expect(angularCompilerOptions.platformTransformers).toBeDefined(); - expect(angularCompilerOptions.platformTransformers.length).toEqual(1); - expect(angularCompilerOptions.platformTransformers[0]).toEqual(FakeLazyTransformerFlag); - }); - - it('should contain the HMR + Lazy transformers when the HMR flag is passed and @angular/core is an external module', () => { - const input = getInput({ platform, hmr: true, externals: ['@angular/core'] }); - - webpackConfig(input); - - expect(angularCompilerOptions).toBeDefined(); - expect(angularCompilerOptions.platformTransformers).toBeDefined(); - expect(angularCompilerOptions.platformTransformers.length).toEqual(2); - expect(angularCompilerOptions.platformTransformers).toContain(FakeHmrTransformerFlag); - expect(angularCompilerOptions.platformTransformers).toContain(FakeLazyTransformerFlag); - }); - - it('should contain the HMR + Lazy transformers when the HMR flags are passed and @angular/core is an external module', () => { - const input = getInput({ platform, hmr: true, externals: ['@angular/core'] }); - - webpackConfig(input); - - expect(angularCompilerOptions).toBeDefined(); - expect(angularCompilerOptions.platformTransformers).toBeDefined(); - expect(angularCompilerOptions.platformTransformers.length).toEqual(2); - expect(angularCompilerOptions.platformTransformers).toContain(FakeHmrTransformerFlag); - expect(angularCompilerOptions.platformTransformers).toContain(FakeLazyTransformerFlag); - }); - - it('should contain the HMR + Lazy transformers in the proper order when the HMR flags are passed and @angular/core is an external module', () => { - const input = getInput({ platform, hmr: true, externals: ['@angular/core'] }); - - webpackConfig(input); - - expect(angularCompilerOptions).toBeDefined(); - expect(angularCompilerOptions.platformTransformers).toBeDefined(); - expect(angularCompilerOptions.platformTransformers.length).toEqual(2); - expect(angularCompilerOptions.platformTransformers[0]).toEqual(FakeHmrTransformerFlag); - expect(angularCompilerOptions.platformTransformers[1]).toEqual(FakeLazyTransformerFlag); - }); }); } diff --git a/packages/webpack/tsconfig.json b/packages/webpack/tsconfig.json index e527d7c85..6901fa9c7 100644 --- a/packages/webpack/tsconfig.json +++ b/packages/webpack/tsconfig.json @@ -1,19 +1,20 @@ { "compilerOptions": { - "target": "es2015", + "rootDir": ".", + "target": "es5", "module": "commonjs", "declaration": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, "lib": [ "es2017" ], "sourceMap": true, - "skipLibCheck": true + "skipLibCheck": true, + "skipDefaultLibCheck": true, + "diagnostics": true, + "baseUrl": "." }, - "include": [ - "../types-ios/src/lib/ios.d.ts", - "../types-android/src/lib/android-29.d.ts" - ], "exclude": [ "node_modules", - "demo", - "../core" + "demo" ] }