Skip to content

Commit

Permalink
BW-744 upgrade nativescript angular
Browse files Browse the repository at this point in the history
  • Loading branch information
jitendraashutec committed Mar 26, 2020
1 parent 1a70ac1 commit 6e31113
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 25 deletions.
3 changes: 1 addition & 2 deletions ngsw-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
"/*.js"
],
"urls": [
"https://cdnjs.cloudflare.com/ajax/libs/core-js/2.4.1/shim.min.js",
"https://fonts.googleapis.com/icon?family=Material+Icons"
"https://cdnjs.cloudflare.com/ajax/libs/core-js/2.4.1/shim.min.js"
]
}
},
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"angular-cli": {},
"nativescript": {
"id": "${packageName}",
"tns-ios": {
"version": "6.2.0"
},
"tns-android": {
"version": "6.2.0"
"version": "6.5.0"
},
"tns-ios": {
"version": "6.5.0"
}
},
"scripts": {
Expand Down Expand Up @@ -63,9 +63,9 @@
"google-libphonenumber": "^3.2.5",
"hammerjs": "^2.0.8",
"lodash.clonedeep": "^4.5.0",
"nativescript-angular": "^8.2.1",
"nativescript-angular": "^8.21.0",
"nativescript-appversion": "^1.4.1",
"nativescript-camera": "^4.4.1",
"nativescript-camera": "^4.5.0",
"nativescript-cardview": "^3.1.1",
"nativescript-carousel": "^6.1.1",
"nativescript-checkbox": "^3.0.3",
Expand All @@ -91,11 +91,11 @@
"ngx-papaparse": "^3.0.2",
"ngx-swiper-wrapper": "^8.0.1",
"reflect-metadata": "^0.1.13",
"rxjs": "^6.5.3",
"rxjs": "^6.4.0",
"stream": "0.0.2",
"string-hash": "^1.1.3",
"time-ago-pipe": "^1.3.2",
"tns-core-modules": "^6.1.1",
"tns-core-modules": "^6.5.0",
"zone.js": "^0.9.1"
},
"devDependencies": {
Expand Down Expand Up @@ -136,7 +136,7 @@
"lodash": "^4.17.11",
"lodash.template": "^4.5.0",
"mathquill": "^0.10.1-a",
"nativescript-dev-webpack": "^1.3.0",
"nativescript-dev-webpack": "^1.5.1",
"nativescript-pager": "^9.5.4",
"ng-katex": "^1.2.1",
"node-sass": "^4.12.0",
Expand Down
2 changes: 1 addition & 1 deletion projects/trivia/src/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ refer to http://docs.nativescript.org/ui/theme.

// @import '~nativescript-theme-core/css/core.light.css';
@import "./styles/light.theme.scss";
@import "./styles/styles.scss";
// @import "./styles/styles.scss";
@import "./styles/global.scss";
@import './styles/mobile.scss';
@import './styles/icon-moon.scss';
Expand Down
Binary file added quill-blot-formatter-1.0.4.tgz
Binary file not shown.
65 changes: 52 additions & 13 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const { nsReplaceBootstrap } = require("nativescript-dev-webpack/transformers/ns
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 { getNoEmitOnErrorFromTSConfig, getCompilerOptionsFromTSConfig } = require("nativescript-dev-webpack/utils/tsconfig-utils");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
Expand All @@ -18,12 +19,13 @@ const resExt = require("./resolver-extended");

module.exports = env => {
// Add your custom Activities, Services and other Android app components here.
const appComponents = [
const appComponents = env.appComponents || [];
appComponents.push(...[
"tns-core-modules/ui/frame",
"tns-core-modules/ui/frame/activity",
];
]);

const platform = env && (env.android && "android" || env.ios && "ios");
const platform = env && (env.android && "android" || env.ios && "ios" || env.platform);
if (!platform) {
throw new Error("You need to provide a target platform!");
}
Expand Down Expand Up @@ -52,17 +54,41 @@ module.exports = env => {
unitTesting, // --env.unitTesting
verbose, // --env.verbose
snapshotInDocker, // --env.snapshotInDocker
skipSnapshotTools // --env.skipSnapshotTools
skipSnapshotTools, // --env.skipSnapshotTools
compileSnapshot // --env.compileSnapshot
} = env;

const useLibs = compileSnapshot;
const isAnySourceMapEnabled = !!sourceMap || !!hiddenSourceMap;
const externals = nsWebpack.getConvertedExternals(env.externals);
const appFullPath = resolve(projectRoot, appPath);
const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
// const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
const tsConfigName = "tsconfig.tns.json";
const tsConfigPath = join(__dirname, tsConfigName);
const hasRootLevelScopedModules = nsWebpack.hasRootLevelScopedModules({ projectDir: projectRoot });
const hasRootLevelScopedAngular = nsWebpack.hasRootLevelScopedAngular({ projectDir: projectRoot });
let coreModulesPackageName = "tns-core-modules";
const alias = env.alias || {};
alias['~'] = appFullPath;

const compilerOptions = getCompilerOptionsFromTSConfig(tsConfigPath);
if (hasRootLevelScopedModules) {
coreModulesPackageName = "@nativescript/core";
alias["tns-core-modules"] = coreModulesPackageName;
nsWebpack.processTsPathsForScopedModules({ compilerOptions });
}

if (hasRootLevelScopedAngular) {
alias["nativescript-angular"] = "@nativescript/angular";
nsWebpack.processTsPathsForScopedAngular({ compilerOptions });
}

const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
const entryModule = `${nsWebpack.getEntryModule(appFullPath, platform)}.ts`;
const entryPath = `.${sep}${entryModule}`;
const entries = { bundle: entryPath };
const entries = env.entries || {};
entries.bundle = entryPath;

const areCoreModulesExternal = Array.isArray(env.externals) && env.externals.some(e => e.indexOf("tns-core-modules") > -1);
if (platform === "ios" && !areCoreModulesExternal) {
entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules";
Expand Down Expand Up @@ -93,13 +119,16 @@ module.exports = env => {
}
const envFullPath = (env.prod) ? "prod" : "dev";
const ngCompilerPlugin = new AngularCompilerPlugin({
// hostReplacementPaths: nsWebpack.getResolver([platform, "tns"]),
hostReplacementPaths: resExt.getResolverExtended([platform, "tns", envFullPath], env.project),
platformTransformers: ngCompilerTransformers.map(t => t(() => ngCompilerPlugin, resolve(appFullPath, entryModule), projectRoot)),
mainPath: join(appFullPath, entryModule),
// tsConfigPath,
tsConfigPath: join(__dirname, tsConfigName),
skipCodeGeneration: !aot,
sourceMap: !!isAnySourceMapEnabled,
additionalLazyModuleResources: additionalLazyModuleResources
additionalLazyModuleResources: additionalLazyModuleResources,
compilerOptions: { paths: compilerOptions.paths }
});

let sourceMapFilename = nsWebpack.getSourceMapFilename(hiddenSourceMap, __dirname, dist);
Expand All @@ -110,6 +139,8 @@ module.exports = env => {
itemsToClean.push(`${join(projectRoot, "platforms", "android", "app", "build", "configurations", "nativescript-android-snapshot")}`);
}

const noEmitOnErrorFromTSConfig = getNoEmitOnErrorFromTSConfig(join(projectRoot, tsConfigName));

nsWebpack.processAppComponents(appComponents, platform);
const config = {
mode: production ? "production" : "development",
Expand Down Expand Up @@ -137,11 +168,12 @@ module.exports = env => {
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/${coreModulesPackageName}`),
resolve(__dirname, "node_modules"),
"node_modules/tns-core-modules",
`node_modules/${coreModulesPackageName}`,
"node_modules",
],
// alias,
alias: {
'~': appFullPath
},
Expand All @@ -161,6 +193,7 @@ module.exports = env => {
devtool: hiddenSourceMap ? "hidden-source-map" : (sourceMap ? "inline-source-map" : "none"),
optimization: {
runtimeChunk: "single",
noEmitOnErrors: noEmitOnErrorFromTSConfig,
splitChunks: {
cacheGroups: {
vendor: {
Expand Down Expand Up @@ -223,19 +256,24 @@ module.exports = env => {

{ 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 } }
{
loader: "nativescript-dev-webpack/css2json-loader",
options: { useForImports: true }
}
]
},
{
test: /[\/|\\]app\.scss$/,
use: [
"nativescript-dev-webpack/style-hot-loader",
{ loader: "css-loader", options: { url: false } },
{
loader: "nativescript-dev-webpack/css2json-loader",
options: { useForImports: true }
},
"sass-loader"
]
},
Expand Down Expand Up @@ -321,7 +359,8 @@ module.exports = env => {
projectRoot,
webpackConfig: config,
snapshotInDocker,
skipSnapshotTools
skipSnapshotTools,
useLibs
}));
}

Expand Down

0 comments on commit 6e31113

Please sign in to comment.