chore: cleanup

This commit is contained in:
Nathan Walker
2020-07-13 18:02:10 -07:00
parent 4496cd9f2c
commit 84204cda72
5 changed files with 15 additions and 67 deletions

View File

@@ -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;
});
}

View File

@@ -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"
}
}

View File

@@ -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);
}

View File

@@ -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);
});
});
}

View File

@@ -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"
]
}