mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore: cleanup
This commit is contained in:
@@ -1,22 +1,21 @@
|
||||
console.log("####### ------ APP MODULES START ");
|
||||
|
||||
import * as application from "tns-core-modules/application";
|
||||
import * as trace from "tns-core-modules/trace";
|
||||
trace.addCategories(trace.categories.NativeLifecycle);
|
||||
trace.addCategories(trace.categories.Navigation);
|
||||
trace.addCategories(trace.categories.Transition);
|
||||
import { Trace, Application, UnhandledErrorEventData, LaunchEventData, ApplicationEventData, DiscardedErrorEventData } from "@nativescript/core";
|
||||
Trace.addCategories(Trace.categories.NativeLifecycle);
|
||||
Trace.addCategories(Trace.categories.Navigation);
|
||||
Trace.addCategories(Trace.categories.Transition);
|
||||
|
||||
trace.enable();
|
||||
Trace.enable();
|
||||
|
||||
var countResume = 0;
|
||||
var countSuspend = 0;
|
||||
|
||||
application.on("displayed", args => {
|
||||
Application.on("displayed", args => {
|
||||
const uptime = global.android ? (<any>org).nativescript.Process.getUpTime : (<any>global).__tns_uptime;
|
||||
console.log("Startup time: " + uptime() + "ms.");
|
||||
});
|
||||
|
||||
application.on("uncaughtError", args => {
|
||||
Application.on("uncaughtError", args => {
|
||||
const error = args.error;
|
||||
console.warn(error.message);
|
||||
if (error.nativeError) {
|
||||
@@ -24,7 +23,7 @@ application.on("uncaughtError", args => {
|
||||
}
|
||||
});
|
||||
|
||||
application.on(application.launchEvent, function (args: application.LaunchEventData) {
|
||||
Application.on(Application.launchEvent, function (args: LaunchEventData) {
|
||||
if (args.android) {
|
||||
// For Android applications, args.android is an android.content.Intent class.
|
||||
console.log("### Launched application with: " + args.android + ".");
|
||||
@@ -34,7 +33,7 @@ application.on(application.launchEvent, function (args: application.LaunchEventD
|
||||
}
|
||||
});
|
||||
|
||||
application.on(application.suspendEvent, function (args: application.ApplicationEventData) {
|
||||
Application.on(Application.suspendEvent, function (args: ApplicationEventData) {
|
||||
if (args.android) {
|
||||
// For Android applications, args.android is an android activity class.
|
||||
console.log("#" + ++countSuspend + "# SuspendEvent Activity: " + args.android);
|
||||
@@ -44,7 +43,7 @@ application.on(application.suspendEvent, function (args: application.Application
|
||||
}
|
||||
});
|
||||
|
||||
application.on(application.resumeEvent, function (args: application.ApplicationEventData) {
|
||||
Application.on(Application.resumeEvent, function (args: ApplicationEventData) {
|
||||
if (args.android) {
|
||||
// For Android applications, args.android is an android activity class.
|
||||
console.log("#" + ++countResume + "# ResumeEvent Activity: " + args.android);
|
||||
@@ -54,7 +53,7 @@ application.on(application.resumeEvent, function (args: application.ApplicationE
|
||||
}
|
||||
});
|
||||
|
||||
application.on(application.exitEvent, function (args: application.ApplicationEventData) {
|
||||
Application.on(Application.exitEvent, function (args: ApplicationEventData) {
|
||||
if (args.android) {
|
||||
// For Android applications, args.android is an android activity class.
|
||||
console.log("### ExitEvent Activity: " + args.android);
|
||||
@@ -64,7 +63,7 @@ application.on(application.exitEvent, function (args: application.ApplicationEve
|
||||
}
|
||||
});
|
||||
|
||||
application.on(application.lowMemoryEvent, function (args: application.ApplicationEventData) {
|
||||
Application.on(Application.lowMemoryEvent, function (args: ApplicationEventData) {
|
||||
if (args.android) {
|
||||
// For Android applications, args.android is an android activity class.
|
||||
console.log("### LowMemoryEvent Activity: " + args.android);
|
||||
@@ -74,21 +73,21 @@ application.on(application.lowMemoryEvent, function (args: application.Applicati
|
||||
}
|
||||
});
|
||||
|
||||
application.on(application.uncaughtErrorEvent, function (args: application.UnhandledErrorEventData) {
|
||||
Application.on(Application.uncaughtErrorEvent, function (args: UnhandledErrorEventData) {
|
||||
console.log("### NativeScriptError: " + args.error);
|
||||
console.log("### nativeException: " + (<any>args.error).nativeException);
|
||||
console.log("### stackTrace: " + (<any>args.error).stackTrace);
|
||||
console.log("### stack: " + args.error.stack);
|
||||
});
|
||||
|
||||
application.on(application.discardedErrorEvent, function (args: application.DiscardedErrorEventData) {
|
||||
Application.on(Application.discardedErrorEvent, function (args: DiscardedErrorEventData) {
|
||||
console.log("### [Discarded] NativeScriptError: " + args.error);
|
||||
console.log("### [Discarded] nativeException: " + (<any>args.error).nativeException);
|
||||
console.log("### [Discarded] stackTrace: " + (<any>args.error).stackTrace);
|
||||
console.log("### [Discarded] stack: " + args.error.stack);
|
||||
});
|
||||
|
||||
application.run({ moduleName: "app-root" });
|
||||
Application.run({ moduleName: "app-root" });
|
||||
|
||||
// TODO: investigate tab-view -> tabviewcss test crash
|
||||
// TODO: investigate css -> layouts border overlap failure
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { EventData, Page } from "tns-core-modules/ui/page/page";
|
||||
import { BottomNavigation } from "tns-core-modules/ui/bottom-navigation/bottom-navigation";
|
||||
import { EventData, Page, BottomNavigation } from "@nativescript/core";
|
||||
|
||||
export const selectTab = (args: EventData) => {
|
||||
const page = <Page>(<any>args.object).page;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { EventData } from "tns-core-modules/data/observable";
|
||||
import { Button } from "tns-core-modules/ui/button/button";
|
||||
import { Button } from "tns-core-modules/ui/button";
|
||||
|
||||
export function goToSecond(args: EventData) {
|
||||
console.log("---> goToSecond Page");
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
import { EventData } from "tns-core-modules/data/observable";
|
||||
import { Frame } from "tns-core-modules/ui/frame/frame";
|
||||
import { Page } from "tns-core-modules/ui/page";
|
||||
import {
|
||||
TabStripItemEventData, SelectedIndexChangedEventData, BottomNavigation, TabStrip,
|
||||
} from "tns-core-modules/ui/bottom-navigation";
|
||||
import { EventData, Frame, Page, TabStripItemEventData, SelectedIndexChangedEventData, BottomNavigation, TabStrip } from "@nativescript/core";
|
||||
|
||||
export function goToFirst(args: EventData) {
|
||||
console.log("---> goToFirst");
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { EventData } from "tns-core-modules/data/observable";
|
||||
import { Button } from "tns-core-modules/ui/button/button";
|
||||
import { Button, EventData } from "@nativescript/core";
|
||||
|
||||
export function goToFirst(args: EventData) {
|
||||
console.log("---> goToFirst Page");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Button } from "tns-core-modules/ui/button/button";
|
||||
import { EventData } from "tns-core-modules/ui/page/page";
|
||||
import { Button } from "tns-core-modules/ui/button";
|
||||
import { EventData } from "tns-core-modules/ui/page";
|
||||
|
||||
const states = [
|
||||
{ class: "", text: "default elevation" },
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import * as stack from "tns-core-modules/ui/layouts/stack-layout";
|
||||
import { Button } from "@nativescript/core/ui/button";
|
||||
import * as view from "tns-core-modules/ui/core/view";
|
||||
import { unsetValue } from "tns-core-modules/ui/core/view";
|
||||
import { unsetValue, Button, View, StackLayout } from "@nativescript/core";
|
||||
|
||||
export function resetStyles(args) {
|
||||
var stackLayout = <stack.StackLayout>args.object.parent.parent;
|
||||
view.eachDescendant(stackLayout, function (v: view.View) {
|
||||
var stackLayout = <StackLayout>args.object.parent.parent;
|
||||
view.eachDescendant(stackLayout, function (v: View) {
|
||||
v.style.fontFamily = unsetValue;
|
||||
v.style.fontSize = unsetValue;
|
||||
v.style.fontStyle = unsetValue;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { StackLayout } from "tns-core-modules/ui/layouts/stack-layout";
|
||||
import { View, unsetValue, eachDescendant } from "tns-core-modules/ui/core/view";
|
||||
import { View, unsetValue, eachDescendant, StackLayout } from "@nativescript/core";
|
||||
|
||||
export function resetStyles(args) {
|
||||
var stackLayout = <StackLayout>args.object.parent;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { EventData, Page } from "tns-core-modules/ui/page/page";
|
||||
import { Label } from "tns-core-modules/ui/label/label";
|
||||
import { EventData, Page, Label } from "@nativescript/core";
|
||||
|
||||
const setLabelTextAndLog = (args, text: string) => {
|
||||
const page = <Page>args.object.page;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { EventData } from "tns-core-modules/data/observable";
|
||||
import { Page } from "tns-core-modules/ui/page";
|
||||
import { Tabs } from "tns-core-modules/ui/tabs";
|
||||
import { EventData, Page, Tabs } from "@nativescript/core";
|
||||
|
||||
export function goToFirst(args: EventData) {
|
||||
const page = <Page>(<any>args.object).page;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { EventData } from "tns-core-modules/data/observable";
|
||||
import { Page } from "tns-core-modules/ui/page";
|
||||
import { Tabs } from "tns-core-modules/ui/tabs";
|
||||
import { EventData, Page, Tabs } from "@nativescript/core";
|
||||
|
||||
export function goToFirst(args: EventData) {
|
||||
const page = <Page>(<any>args.object).page;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { View } from "tns-core-modules/ui/core/view";
|
||||
import { Page } from "tns-core-modules/ui/page";
|
||||
import { Tabs } from "tns-core-modules/ui/tabs";
|
||||
import { View, Page, Tabs } from "@nativescript/core";
|
||||
|
||||
export function onButtonTap(args) {
|
||||
const page = <Page>(<View>args.object).page;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { EventData } from "tns-core-modules/data/observable";
|
||||
import { Page } from "tns-core-modules/ui/page";
|
||||
import { Tabs, SelectedIndexChangedEventData } from "tns-core-modules/ui/tabs";
|
||||
import { EventData, Page, Tabs, SelectedIndexChangedEventData } from "@nativescript/core";
|
||||
|
||||
export function goToFirst(args: EventData) {
|
||||
console.log("---> goToFirst");
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { EventData } from "tns-core-modules/data/observable";
|
||||
import { Button } from "tns-core-modules/ui/button/button";
|
||||
import { EventData, Button } from "@nativescript/core";
|
||||
|
||||
export function goToSecond(args: EventData) {
|
||||
console.log("---> goToSecond Page");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Tabs, SelectedIndexChangedEventData } from "tns-core-modules/ui/tabs";
|
||||
import { Tabs, SelectedIndexChangedEventData } from "@nativescript/core";
|
||||
|
||||
export function onSelectedIndexChanged(args: SelectedIndexChangedEventData) {
|
||||
const tabsNav = <Tabs>args.object;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { EventData } from "tns-core-modules/data/observable";
|
||||
import { WrapLayout } from "tns-core-modules/ui/layouts/wrap-layout";
|
||||
import { Page } from "tns-core-modules/ui/page";
|
||||
import { EventData, WrapLayout, Page } from "@nativescript/core";
|
||||
|
||||
import { SubMainPageViewModel } from "../sub-main-page-view-model";
|
||||
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
import { EventData } from "tns-core-modules/data/observable";
|
||||
import { Frame } from "tns-core-modules/ui/frame/frame";
|
||||
import { Page } from "tns-core-modules/ui/page";
|
||||
import {
|
||||
TabStripItemEventData, SelectedIndexChangedEventData, Tabs, TabStrip //, TabStripItem
|
||||
} from "tns-core-modules/ui/tabs";
|
||||
import { EventData, Frame, Page, TabStripItemEventData, SelectedIndexChangedEventData, Tabs, TabStrip } from "@nativescript/core";
|
||||
|
||||
export function goToFirst(args: EventData) {
|
||||
console.log("---> goToFirst");
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { EventData } from "tns-core-modules/data/observable";
|
||||
import { Button } from "tns-core-modules/ui/button/button";
|
||||
import { EventData, Button } from "@nativescript/core";
|
||||
|
||||
export function goToFirst(args: EventData) {
|
||||
console.log("---> goToFirst Page");
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { EventData } from "tns-core-modules/data/observable";
|
||||
import { Page } from "tns-core-modules/ui/page";
|
||||
import { Tabs } from "tns-core-modules/ui/tabs";
|
||||
import { EventData, Page, Tabs } from "@nativescript/core";
|
||||
|
||||
export function goToFirst(args: EventData) {
|
||||
const page = <Page>(<any>args.object).page;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { TextField } from "tns-core-modules/ui/text-field";
|
||||
import { TextView } from "tns-core-modules/ui/text-view";
|
||||
import { TextField, TextView } from "@nativescript/core";
|
||||
|
||||
export function onLoaded(args) {
|
||||
const page = args.object;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { EventData } from "tns-core-modules/data/observable";
|
||||
import { EventData, WrapLayout, Page } from "@nativescript/core";
|
||||
import { SubMainPageViewModel } from "../sub-main-page-view-model";
|
||||
import { WrapLayout } from "tns-core-modules/ui/layouts/wrap-layout";
|
||||
import { Page } from "tns-core-modules/ui/page";
|
||||
|
||||
export function pageLoaded(args: EventData) {
|
||||
const page = <Page>args.object;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Page } from "tns-core-modules/ui/page";
|
||||
import { TextField } from "tns-core-modules/ui/text-field";
|
||||
import { Page, TextField } from "@nativescript/core";
|
||||
|
||||
export function setText(args) {
|
||||
let page = args;
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import { Page } from "tns-core-modules/ui/page";
|
||||
import { unsetValue } from "tns-core-modules/ui/core/view";
|
||||
import { TextView } from "tns-core-modules/ui/text-view";
|
||||
import { TextField } from "tns-core-modules/ui/text-field";
|
||||
import { TextView, unsetValue, TextField, Page } from "@nativescript/core";
|
||||
|
||||
function exectuteOnAll(page: Page, callback: (txt: TextView | TextField) => void) {
|
||||
page.getViewById("container").eachChild((child) => {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { EventData } from "tns-core-modules/data/observable";
|
||||
import { EventData, WrapLayout, Page } from "@nativescript/core";
|
||||
import { SubMainPageViewModel } from "../sub-main-page-view-model";
|
||||
import { WrapLayout } from "tns-core-modules/ui/layouts/wrap-layout";
|
||||
import { Page } from "tns-core-modules/ui/page";
|
||||
|
||||
export function pageLoaded(args: EventData) {
|
||||
const page = <Page>args.object;
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { Page } from "tns-core-modules/ui/page";
|
||||
import { TextView } from "tns-core-modules/ui/text-view";
|
||||
import { Color } from "tns-core-modules/color";
|
||||
import { Page, TextView, Color } from "@nativescript/core";
|
||||
|
||||
export function changeTextAndColor(args) {
|
||||
const page = <Page>args.object.page;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"version": "next"
|
||||
},
|
||||
"tns-ios": {
|
||||
"version": "next"
|
||||
"version": "6.6.0-alpha.2-ios14-2020-07-06-159403-01"
|
||||
}
|
||||
},
|
||||
"main": "app.js",
|
||||
@@ -13,8 +13,8 @@
|
||||
"license": "SEE LICENSE IN <your-license-filename>",
|
||||
"repository": "<fill-your-repository-here>",
|
||||
"dependencies": {
|
||||
"@nativescript/core": "file:../../nativescript-core",
|
||||
"tns-core-modules": "file:../../dist/tns-core-modules"
|
||||
"@nativescript/core": "file:../../dist/nativescript-core-7.0.0-rc.6.tgz",
|
||||
"@nativescript/core-widgets": "^7.0.0-rc.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@testdeck/mocha": "0.0.6",
|
||||
@@ -29,8 +29,8 @@
|
||||
"mochawesome": "~3.1.2",
|
||||
"nativescript-dev-appium": "next",
|
||||
"@nativescript/webpack": "^2.0.0-alpha.3",
|
||||
"tns-platform-declarations": "file:../../tns-platform-declarations",
|
||||
"typescript": "~3.4.1"
|
||||
"@nativescript/types": "file:../../dist/nativescript-types-7.0.0-rc.0.tgz",
|
||||
"typescript": "~3.9.0"
|
||||
},
|
||||
"gitHead": "8ab7726d1ee9991706069c1359c552e67ee0d1a4",
|
||||
"readme": "NativeScript Application",
|
||||
|
||||
4
e2e/ui-tests-app/references.d.ts
vendored
4
e2e/ui-tests-app/references.d.ts
vendored
@@ -1,2 +1,2 @@
|
||||
/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" />
|
||||
/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />
|
||||
/// <reference path="./node_modules/@nativescript/types/android.d.ts" />
|
||||
/// <reference path="./node_modules/@nativescript/types/ios.d.ts" />
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"noEmitHelpers": true,
|
||||
"noEmitOnError": true,
|
||||
"noEmitOnError": false,
|
||||
"skipLibCheck": true,
|
||||
"lib": [
|
||||
"es6",
|
||||
@@ -16,6 +16,9 @@
|
||||
"~/*": [
|
||||
"app/*"
|
||||
],
|
||||
"tns-core-modules/*": [
|
||||
"./node_modules/@nativescript/core/*"
|
||||
],
|
||||
"*": [
|
||||
"./node_modules/*"
|
||||
]
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
const { join, relative, resolve, sep } = require("path");
|
||||
|
||||
const webpack = require("webpack");
|
||||
const nsWebpack = require("nativescript-dev-webpack");
|
||||
const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target");
|
||||
const CleanWebpackPlugin = require("clean-webpack-plugin");
|
||||
const nsWebpack = require("@nativescript/webpack");
|
||||
const nativescriptTarget = require("@nativescript/webpack/nativescript-target");
|
||||
const { getNoEmitOnErrorFromTSConfig } = require("@nativescript/webpack/utils/tsconfig-utils");
|
||||
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
|
||||
const CopyWebpackPlugin = require("copy-webpack-plugin");
|
||||
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
||||
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
|
||||
@@ -13,12 +14,13 @@ 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 appComponents = env.appComponents || [];
|
||||
appComponents.push(...[
|
||||
"@nativescript/core/ui/frame",
|
||||
"@nativescript/core/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!");
|
||||
}
|
||||
@@ -26,6 +28,10 @@ module.exports = env => {
|
||||
const platforms = ["ios", "android"];
|
||||
const projectRoot = __dirname;
|
||||
|
||||
if (env.platform) {
|
||||
platforms.push(env.platform);
|
||||
}
|
||||
|
||||
// Default destination inside platforms/<platform>/...
|
||||
const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot));
|
||||
|
||||
@@ -45,22 +51,39 @@ module.exports = env => {
|
||||
hmr, // --env.hmr,
|
||||
unitTesting, // --env.unitTesting,
|
||||
verbose, // --env.verbose
|
||||
snapshotInDocker, // --env.snapshotInDocker
|
||||
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 hasRootLevelScopedModules = nsWebpack.hasRootLevelScopedModules({ projectDir: projectRoot });
|
||||
let coreModulesPackageName = "tns-core-modules";
|
||||
const alias = env.alias || {};
|
||||
alias['~'] = appFullPath;
|
||||
|
||||
if (hasRootLevelScopedModules) {
|
||||
coreModulesPackageName = "@nativescript/core";
|
||||
alias["tns-core-modules"] = coreModulesPackageName;
|
||||
}
|
||||
const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
|
||||
|
||||
const copyIgnore = { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] };
|
||||
|
||||
const entryModule = nsWebpack.getEntryModule(appFullPath, platform);
|
||||
const entryPath = `.${sep}${entryModule}.ts`;
|
||||
const entries = { bundle: entryPath };
|
||||
const entries = env.entries || {};
|
||||
entries.bundle = entryPath;
|
||||
|
||||
const tsConfigPath = resolve(projectRoot, "tsconfig.tns.json");
|
||||
|
||||
const areCoreModulesExternal = Array.isArray(env.externals) && env.externals.some(e => e.indexOf("tns-core-modules") > -1);
|
||||
const areCoreModulesExternal = Array.isArray(env.externals) && env.externals.some(e => e.indexOf("@nativescript") > -1);
|
||||
if (platform === "ios" && !areCoreModulesExternal) {
|
||||
entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules";
|
||||
entries["tns_modules/@nativescript/core/inspector_modules"] = "inspector_modules";
|
||||
};
|
||||
|
||||
let sourceMapFilename = nsWebpack.getSourceMapFilename(hiddenSourceMap, __dirname, dist);
|
||||
@@ -71,6 +94,8 @@ module.exports = env => {
|
||||
itemsToClean.push(`${join(projectRoot, "platforms", "android", "app", "build", "configurations", "nativescript-android-snapshot")}`);
|
||||
}
|
||||
|
||||
const noEmitOnErrorFromTSConfig = getNoEmitOnErrorFromTSConfig(tsConfigPath);
|
||||
|
||||
nsWebpack.processAppComponents(appComponents, platform);
|
||||
const config = {
|
||||
mode: production ? "production" : "development",
|
||||
@@ -96,16 +121,14 @@ module.exports = env => {
|
||||
},
|
||||
resolve: {
|
||||
extensions: [".ts", ".js", ".scss", ".css"],
|
||||
// Resolve {N} system modules from tns-core-modules
|
||||
// Resolve {N} system modules from @nativescript/core
|
||||
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: {
|
||||
'~': appFullPath
|
||||
},
|
||||
alias,
|
||||
// resolve symlinks to symlinked modules
|
||||
symlinks: true
|
||||
},
|
||||
@@ -124,6 +147,7 @@ module.exports = env => {
|
||||
devtool: hiddenSourceMap ? "hidden-source-map" : (sourceMap ? "inline-source-map" : "none"),
|
||||
optimization: {
|
||||
runtimeChunk: "single",
|
||||
noEmitOnErrors: noEmitOnErrorFromTSConfig,
|
||||
splitChunks: {
|
||||
cacheGroups: {
|
||||
vendor: {
|
||||
@@ -167,12 +191,12 @@ module.exports = env => {
|
||||
use: [
|
||||
// Require all Android app components
|
||||
platform === "android" && {
|
||||
loader: "nativescript-dev-webpack/android-app-components-loader",
|
||||
loader: "@nativescript/webpack/android-app-components-loader",
|
||||
options: { modules: appComponents }
|
||||
},
|
||||
|
||||
{
|
||||
loader: "nativescript-dev-webpack/bundle-config-loader",
|
||||
loader: "@nativescript/webpack/bundle-config-loader",
|
||||
options: {
|
||||
loadCss: !snapshot, // load the application css if in debug mode
|
||||
unitTesting,
|
||||
@@ -186,20 +210,20 @@ module.exports = env => {
|
||||
|
||||
{
|
||||
test: /\.(ts|css|scss|html|xml)$/,
|
||||
use: "nativescript-dev-webpack/hmr/hot-loader"
|
||||
use: "@nativescript/webpack/hmr/hot-loader"
|
||||
},
|
||||
|
||||
{ test: /\.(html|xml)$/, use: "nativescript-dev-webpack/xml-namespace-loader" },
|
||||
{ test: /\.(html|xml)$/, use: "@nativescript/webpack/xml-namespace-loader" },
|
||||
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: { loader: "css-loader", options: { url: false } }
|
||||
use: "@nativescript/webpack/css2json-loader"
|
||||
},
|
||||
|
||||
{
|
||||
test: /\.scss$/,
|
||||
use: [
|
||||
{ loader: "css-loader", options: { url: false } },
|
||||
"@nativescript/webpack/css2json-loader",
|
||||
"sass-loader"
|
||||
]
|
||||
},
|
||||
@@ -230,15 +254,19 @@ module.exports = env => {
|
||||
"process": "global.process",
|
||||
}),
|
||||
// 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" } },
|
||||
{ from: { glob: "**/*.html" } },
|
||||
{ from: { glob: "web-view/test.css" } },
|
||||
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
|
||||
new CleanWebpackPlugin({
|
||||
cleanOnceBeforeBuildPatterns: itemsToClean,
|
||||
verbose: !!verbose
|
||||
}),
|
||||
// Copy assets
|
||||
new CopyWebpackPlugin({
|
||||
patterns: [
|
||||
{ from: 'assets/**', noErrorOnMissing: true, globOptions: { dot: false, ...copyIgnore } },
|
||||
{ from: 'fonts/**', noErrorOnMissing: true, globOptions: { dot: false, ...copyIgnore } },
|
||||
{ from: '**/*.jpg', noErrorOnMissing: true, globOptions: { dot: false, ...copyIgnore } },
|
||||
{ from: '**/*.png', noErrorOnMissing: true, globOptions: { dot: false, ...copyIgnore } },
|
||||
],
|
||||
}),
|
||||
new nsWebpack.GenerateNativeScriptEntryPointsPlugin("bundle"),
|
||||
// For instructions on how to set up workers with webpack
|
||||
// check out https://github.com/nativescript/worker-loader
|
||||
@@ -252,10 +280,15 @@ module.exports = env => {
|
||||
// https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#faster-builds
|
||||
// https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#hot-module-replacement
|
||||
new ForkTsCheckerWebpackPlugin({
|
||||
tsconfig: tsConfigPath,
|
||||
async: false,
|
||||
useTypescriptIncrementalApi: true,
|
||||
memoryLimit: 4096
|
||||
async: false,
|
||||
typescript: {
|
||||
configFile: tsConfigPath,
|
||||
memoryLimit: 4096,
|
||||
diagnosticOptions: {
|
||||
syntactic: true,
|
||||
semantic: true
|
||||
}
|
||||
}
|
||||
})
|
||||
],
|
||||
};
|
||||
@@ -275,10 +308,13 @@ module.exports = env => {
|
||||
config.plugins.push(new nsWebpack.NativeScriptSnapshotPlugin({
|
||||
chunk: "vendor",
|
||||
requireModules: [
|
||||
"tns-core-modules/bundle-entry-points",
|
||||
"@nativescript/core/bundle-entry-points",
|
||||
],
|
||||
projectRoot,
|
||||
webpackConfig: config,
|
||||
snapshotInDocker,
|
||||
skipSnapshotTools,
|
||||
useLibs
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user