Merge branch 'master' of github.com:NativeScript/NativeScript

# Conflicts:
#	packages/core/application/index.d.ts
This commit is contained in:
Martin Guillon
2020-09-10 16:05:56 +02:00
16 changed files with 183 additions and 145 deletions

View File

@ -1,3 +1,32 @@
## [7.0.2](https://github.com/NativeScript/NativeScript/compare/7.0.0...7.0.2) (2020-09-10)
### Bug Fixes
* **core:** autoSystemAppearanceChanged typings in ambient context fix ([c30a9c3](https://github.com/NativeScript/NativeScript/commit/c30a9c3e3569e0367056bfd80fa730ae79e29066))
* **core:** bundle-config-loader global handling ([#8838](https://github.com/NativeScript/NativeScript/issues/8838)) ([1623a56](https://github.com/NativeScript/NativeScript/commit/1623a567b6eaa195d075936103d2f7d829e1fa07))
* **webpack:** verify now works properly ([f7713c4](https://github.com/NativeScript/NativeScript/commit/f7713c40a63959c2b5934a25bd3577f07d0401c0))
## [7.0.1](https://github.com/NativeScript/NativeScript/compare/7.0.0...7.0.1) (2020-09-09)
### Bug Fixes
* **webpack:** react config ([#8822](https://github.com/NativeScript/NativeScript/issues/8822)) ([354b935](https://github.com/NativeScript/NativeScript/commit/354b935c6a334de3d418495b11674a799293a8bd))
* invalid cli tag version ([#8821](https://github.com/NativeScript/NativeScript/issues/8821)) ([d51abef](https://github.com/NativeScript/NativeScript/commit/d51abef6bfeb66ed647d5bd2e1711d0ce9d07113))
* **webpack:** apply-css-loader not applying css ([#8811](https://github.com/NativeScript/NativeScript/issues/8811)) ([c1a2d54](https://github.com/NativeScript/NativeScript/commit/c1a2d543b8a9aad0551ae5bb445ef4e08bac99b2))
* **webpack:** Change NativeClass properties to enumerable ([#8813](https://github.com/NativeScript/NativeScript/issues/8813)) ([e4a2930](https://github.com/NativeScript/NativeScript/commit/e4a2930c6a019e3b65a7968afe4fa2653246ecf4))
### Features
* **core:** boolean to disable systemAppearanceChanged (theme) ([#8827](https://github.com/NativeScript/NativeScript/issues/8827)) ([5286adf](https://github.com/NativeScript/NativeScript/commit/5286adf081cb75ea17251edd498266be7fe7189a))
* **core:** export additional properties for plugin usage ([#8835](https://github.com/NativeScript/NativeScript/issues/8835)) ([a2e1aa2](https://github.com/NativeScript/NativeScript/commit/a2e1aa246e6a9cbdd6d2c4647c9740ef411ad51a))
# [7.0.0](https://github.com/NativeScript/NativeScript/compare/6.5.15...7.0.0) (2020-09-03) # [7.0.0](https://github.com/NativeScript/NativeScript/compare/6.5.15...7.0.0) (2020-09-03)

View File

@ -1,8 +1,11 @@
{ {
"main": "main.js", "main": "main.js",
"description": "NativeScript Application", "description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>", "license": "MIT",
"repository": "<fill-your-repository-here>", "repository": {
"type": "git",
"url": "https://github.com/NativeScript/NativeScript.git"
},
"scripts": { "scripts": {
"clean": "npx rimraf hooks node_modules platforms package-lock.json && npm i" "clean": "npx rimraf hooks node_modules platforms package-lock.json && npm i"
}, },

View File

@ -1,8 +1,11 @@
{ {
"main": "main.js", "main": "main.js",
"description": "NativeScript Application", "description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>", "license": "MIT",
"repository": "<fill-your-repository-here>", "repository": {
"type": "git",
"url": "https://github.com/NativeScript/NativeScript.git"
},
"dependencies": { "dependencies": {
"nativescript-theme-core": "file:../../node_modules/nativescript-theme-core", "nativescript-theme-core": "file:../../node_modules/nativescript-theme-core",
"@nativescript/core": "file:../../packages/core" "@nativescript/core": "file:../../packages/core"

View File

@ -1,4 +1,10 @@
import { AppiumDriver, IRectangle, logInfo, logWarn, Point } from "nativescript-dev-appium"; import {
AppiumDriver,
IRectangle,
logInfo,
logWarn,
Point
} from "nativescript-dev-appium";
export enum ElementCacheStrategy { export enum ElementCacheStrategy {
allAtOnce, allAtOnce,
@ -18,12 +24,15 @@ export class NavigationHelper {
private _cachedElements: ICachedElement; private _cachedElements: ICachedElement;
private _currentSuite: ICachedElement; private _currentSuite: ICachedElement;
constructor(protected _driver: AppiumDriver, protected _suitMainPageNavigationLinks: Array<string>, private _elemtsCacheStrategy: ElementCacheStrategy = ElementCacheStrategy.onload) { constructor(
} protected _driver: AppiumDriver,
protected _suitMainPageNavigationLinks: Array<string>,
private _elementsCacheStrategy: ElementCacheStrategy = ElementCacheStrategy.onload
) {}
async initSuite() { async initSuite(): Promise<void> {
if (this._elemtsCacheStrategy === ElementCacheStrategy.allAtOnce if (this._elementsCacheStrategy === ElementCacheStrategy.allAtOnce
|| this._elemtsCacheStrategy === ElementCacheStrategy.onload) { || this._elementsCacheStrategy === ElementCacheStrategy.onload) {
if (this._currentSuite) { if (this._currentSuite) {
while (this._currentSuite.parent) { while (this._currentSuite.parent) {
this._currentSuite = this._currentSuite.parent; this._currentSuite = this._currentSuite.parent;
@ -31,7 +40,7 @@ export class NavigationHelper {
} else { } else {
if (!this._cachedElements || this._cachedElements.children.size === 0) { if (!this._cachedElements || this._cachedElements.children.size === 0) {
this._cachedElements = { name: "initSuite", children: new Map<string, ICachedElement>() }; this._cachedElements = { name: "initSuite", children: new Map<string, ICachedElement>() };
if (this._elemtsCacheStrategy === ElementCacheStrategy.allAtOnce) { if (this._elementsCacheStrategy === ElementCacheStrategy.allAtOnce) {
await this.cacheAllElements(this._cachedElements); await this.cacheAllElements(this._cachedElements);
} }
} }
@ -43,12 +52,12 @@ export class NavigationHelper {
await this.navigateToSuitMainPage(); await this.navigateToSuitMainPage();
} }
async endSuite() { async endSuite(): Promise<void> {
logInfo("End of suit 'button' tests!"); logInfo(`End of suit 'button' tests!`);
await this._driver.takeScreenshot("end_button_suit"); await this._driver.takeScreenshot("end_button_suit");
} }
async navigateToSuitMainPage() { async navigateToSuitMainPage(): Promise<void> {
for (let index = 0; index < this._suitMainPageNavigationLinks.length; index++) { for (let index = 0; index < this._suitMainPageNavigationLinks.length; index++) {
const mainPage = this._suitMainPageNavigationLinks[index]; const mainPage = this._suitMainPageNavigationLinks[index];
await this.navigateToSample(mainPage); await this.navigateToSample(mainPage);
@ -59,7 +68,7 @@ export class NavigationHelper {
logInfo(`Navigate to ${sample}`); logInfo(`Navigate to ${sample}`);
const sampleName = sample.toLowerCase(); const sampleName = sample.toLowerCase();
if (this._elemtsCacheStrategy === ElementCacheStrategy.allAtOnce) { if (this._elementsCacheStrategy === ElementCacheStrategy.allAtOnce) {
if (!this._currentSuite.children.has(sampleName)) { if (!this._currentSuite.children.has(sampleName)) {
await this.cacheAllElements(this._currentSuite); await this.cacheAllElements(this._currentSuite);
} }
@ -69,7 +78,7 @@ export class NavigationHelper {
const sampleElement = this._currentSuite.children.get(sampleName).rect; const sampleElement = this._currentSuite.children.get(sampleName).rect;
await this._driver.clickPoint(sampleElement.x + (sampleElement.width / 2), sampleElement.y + (sampleElement.height / 2)); await this._driver.clickPoint(sampleElement.x + (sampleElement.width / 2), sampleElement.y + (sampleElement.height / 2));
this._currentSuite = this._currentSuite.children.get(sampleName); this._currentSuite = this._currentSuite.children.get(sampleName);
} else if (this._elemtsCacheStrategy === ElementCacheStrategy.onload) { } else if (this._elementsCacheStrategy === ElementCacheStrategy.onload) {
if (this._currentSuite.children.has(sampleName)) { if (this._currentSuite.children.has(sampleName)) {
const sampleElement = this._currentSuite.children.get(sampleName).rect; const sampleElement = this._currentSuite.children.get(sampleName).rect;
await this._driver.clickPoint(sampleElement.x + (sampleElement.width / 2), sampleElement.y + (sampleElement.height / 2)); await this._driver.clickPoint(sampleElement.x + (sampleElement.width / 2), sampleElement.y + (sampleElement.height / 2));
@ -94,14 +103,14 @@ export class NavigationHelper {
async navigateBackToSuitMainPage() { async navigateBackToSuitMainPage() {
logInfo(`Navigate to back`); logInfo(`Navigate to back`);
if (this._elemtsCacheStrategy === ElementCacheStrategy.allAtOnce if (this._elementsCacheStrategy === ElementCacheStrategy.allAtOnce
|| this._elemtsCacheStrategy === ElementCacheStrategy.onload) { || this._elementsCacheStrategy === ElementCacheStrategy.onload) {
this._currentSuite = this._currentSuite && this._currentSuite.parent; this._currentSuite = this._currentSuite && this._currentSuite.parent;
} }
await this._driver.navBack(); await this._driver.navBack();
} }
async swipeBackToSuitMainPage() { async swipeBackToSuitMainPage(): Promise<void> {
logInfo(`Swipe to back`); logInfo(`Swipe to back`);
const startPoint = <Point>{}; const startPoint = <Point>{};
const endPoint = <Point>{}; const endPoint = <Point>{};
@ -115,20 +124,29 @@ export class NavigationHelper {
await this._driver.swipe(startPoint, endPoint); await this._driver.swipe(startPoint, endPoint);
} else { } else {
logWarn("Swipe back is not supported from android!"); logWarn(`Swipe back is not supported from android!`);
} }
} }
private async cacheAllElements(cachedElements: ICachedElement) { private async cacheAllElements(cachedElements: ICachedElement): Promise<void> {
const allSamples = await this._driver.findElementsByClassName(this._driver.locators.button); const allSamples = await this._driver.findElementsByClassName(this._driver.locators.button);
for (let index = 0; index < allSamples.length; index++) { for (let index = 0; index < allSamples.length; index++) {
const element = allSamples[index]; const element = allSamples[index];
const rect = await element.getRectangle(); const rect = await element.getRectangle();
const text = (await element.text()).toLowerCase(); const text = (await element.text()).toLowerCase();
if (!cachedElements.children.has(text)) {
console.log(text); if (cachedElements.children.has(text)) continue
cachedElements.children.set(text, { parent: cachedElements, name: text, rect: rect, children: new Map() });
logInfo(text);
cachedElements.children.set(
text,
{
parent: cachedElements,
name: text,
rect: rect,
children: new Map()
} }
);
} }
} }
} }

View File

@ -1,8 +1,11 @@
{ {
"main": "main.js", "main": "main.js",
"description": "NativeScript Application", "description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>", "license": "MIT",
"repository": "<fill-your-repository-here>", "repository": {
"type": "git",
"url": "https://github.com/NativeScript/NativeScript.git"
},
"dependencies": { "dependencies": {
"nativescript-theme-core": "file:../../node_modules/nativescript-theme-core", "nativescript-theme-core": "file:../../node_modules/nativescript-theme-core",
"@nativescript/core": "file:../../packages/core" "@nativescript/core": "file:../../packages/core"

View File

@ -1,6 +1,6 @@
{ {
"name": "nativescript", "name": "nativescript",
"version": "7.0.0", "version": "7.0.2",
"license": "MIT", "license": "MIT",
"config": { "config": {
"npm_alias": "npm" "npm_alias": "npm"
@ -37,6 +37,10 @@
"webpack:build": "cd packages/webpack npm run setup && mkdir -p ../../dist/packages && mv \"$(npm pack | tail -n 1)\" ../../dist/packages/nativescript-webpack.tgz" "webpack:build": "cd packages/webpack npm run setup && mkdir -p ../../dist/packages && mv \"$(npm pack | tail -n 1)\" ../../dist/packages/nativescript-webpack.tgz"
}, },
"private": true, "private": true,
"repository": {
"type": "git",
"url": "https://github.com/NativeScript/NativeScript.git"
},
"dependencies": { "dependencies": {
"nativescript-theme-core": "^1.0.4" "nativescript-theme-core": "^1.0.4"
}, },

View File

@ -1,4 +1,4 @@
import { NavigationEntry } from '../ui/frame'; import { NavigationEntry } from '../ui/frame';
import { View } from '../ui/core/view'; import { View } from '../ui/core/view';
import { Observable, EventData } from '../data/observable'; import { Observable, EventData } from '../data/observable';
@ -57,7 +57,7 @@ export const systemAppearanceChangedEvent: string;
/** /**
* Boolean to enable/disable systemAppearanceChanged * Boolean to enable/disable systemAppearanceChanged
*/ */
export let autoSystemAppearanceChanged = true; export let autoSystemAppearanceChanged: boolean;
/** /**
* enable/disable systemAppearanceChanged * enable/disable systemAppearanceChanged

View File

@ -358,3 +358,6 @@ export function initGlobal() {
}; };
} }
} }
if (!global.NativeScriptHasInitGlobal) {
initGlobal();
}

View File

@ -8,7 +8,7 @@
export type { NativeScriptConfig } from './config'; export type { NativeScriptConfig } from './config';
export { iOSApplication, AndroidApplication } from './application'; export { iOSApplication, AndroidApplication } from './application';
export type { ApplicationEventData, LaunchEventData, OrientationChangedEventData, UnhandledErrorEventData, DiscardedErrorEventData, CssChangedEventData, LoadAppCSSEventData, AndroidActivityEventData, AndroidActivityBundleEventData, AndroidActivityRequestPermissionsEventData, AndroidActivityResultEventData, AndroidActivityNewIntentEventData, AndroidActivityBackPressedEventData, SystemAppearanceChangedEventData } from './application'; export type { ApplicationEventData, LaunchEventData, OrientationChangedEventData, UnhandledErrorEventData, DiscardedErrorEventData, CssChangedEventData, LoadAppCSSEventData, AndroidActivityEventData, AndroidActivityBundleEventData, AndroidActivityRequestPermissionsEventData, AndroidActivityResultEventData, AndroidActivityNewIntentEventData, AndroidActivityBackPressedEventData, SystemAppearanceChangedEventData } from './application';
import { systemAppearanceChanged, getMainEntry, getRootView, _resetRootView, getResources, setResources, setCssFileName, getCssFileName, loadAppCss, addCss, on, off, run, orientation, getNativeApplication, hasLaunched, systemAppearance } from './application'; import { systemAppearanceChanged, getMainEntry, getRootView, _resetRootView, getResources, setResources, setCssFileName, getCssFileName, loadAppCss, addCss, on, off, notify, hasListeners, run, orientation, getNativeApplication, hasLaunched, systemAppearance } from './application';
export declare const Application: { export declare const Application: {
launchEvent: string; launchEvent: string;
displayedEvent: string; displayedEvent: string;
@ -32,6 +32,8 @@ export declare const Application: {
addCss: typeof addCss; addCss: typeof addCss;
on: typeof on; on: typeof on;
off: typeof off; off: typeof off;
notify: typeof notify;
hasListeners: typeof hasListeners;
run: typeof run; run: typeof run;
orientation: typeof orientation; orientation: typeof orientation;
getNativeApplication: typeof getNativeApplication; getNativeApplication: typeof getNativeApplication;
@ -113,6 +115,10 @@ export declare const Utils: {
android: typeof androidUtils; android: typeof androidUtils;
ad: typeof androidUtils; ad: typeof androidUtils;
ios: typeof iosUtils; ios: typeof iosUtils;
setTimeout: typeof setTimeout;
setInterval: typeof setInterval;
clearInterval: typeof clearInterval;
clearTimeout: typeof clearTimeout;
Source: typeof Source; Source: typeof Source;
ClassInfo: typeof ClassInfo; ClassInfo: typeof ClassInfo;
getClass: typeof getClass; getClass: typeof getClass;

View File

@ -6,7 +6,7 @@ nsGlobals.initGlobal();
export { iOSApplication, AndroidApplication } from './application'; export { iOSApplication, AndroidApplication } from './application';
export type { ApplicationEventData, LaunchEventData, OrientationChangedEventData, UnhandledErrorEventData, DiscardedErrorEventData, CssChangedEventData, LoadAppCSSEventData, AndroidActivityEventData, AndroidActivityBundleEventData, AndroidActivityRequestPermissionsEventData, AndroidActivityResultEventData, AndroidActivityNewIntentEventData, AndroidActivityBackPressedEventData, SystemAppearanceChangedEventData } from './application'; export type { ApplicationEventData, LaunchEventData, OrientationChangedEventData, UnhandledErrorEventData, DiscardedErrorEventData, CssChangedEventData, LoadAppCSSEventData, AndroidActivityEventData, AndroidActivityBundleEventData, AndroidActivityRequestPermissionsEventData, AndroidActivityResultEventData, AndroidActivityNewIntentEventData, AndroidActivityBackPressedEventData, SystemAppearanceChangedEventData } from './application';
import { launchEvent, displayedEvent, uncaughtErrorEvent, discardedErrorEvent, suspendEvent, resumeEvent, exitEvent, lowMemoryEvent, orientationChangedEvent, systemAppearanceChanged, systemAppearanceChangedEvent, getMainEntry, getRootView, _resetRootView, getResources, setResources, setCssFileName, getCssFileName, loadAppCss, addCss, on, off, run, orientation, getNativeApplication, hasLaunched, android as appAndroid, ios as iosApp, systemAppearance } from './application'; import { launchEvent, displayedEvent, uncaughtErrorEvent, discardedErrorEvent, suspendEvent, resumeEvent, exitEvent, lowMemoryEvent, orientationChangedEvent, systemAppearanceChanged, systemAppearanceChangedEvent, getMainEntry, getRootView, _resetRootView, getResources, setResources, setCssFileName, getCssFileName, loadAppCss, addCss, on, off, notify, hasListeners, run, orientation, getNativeApplication, hasLaunched, android as appAndroid, ios as iosApp, systemAppearance } from './application';
export const Application = { export const Application = {
launchEvent, launchEvent,
displayedEvent, displayedEvent,
@ -31,6 +31,8 @@ export const Application = {
addCss, addCss,
on, on,
off, off,
notify,
hasListeners,
run, run,
orientation, orientation,
getNativeApplication, getNativeApplication,
@ -103,7 +105,8 @@ export { profile, enable as profilingEnable, disable as profilingDisable, time a
export type { InstrumentationMode, TimerInfo } from './profiling'; export type { InstrumentationMode, TimerInfo } from './profiling';
export { encoding } from './text'; export { encoding } from './text';
// for developers to be explicit if they desire around globals (allows access via Utils below)
import { setTimeout, setInterval, clearInterval, clearTimeout } from './timer';
export * from './trace'; export * from './trace';
export * from './ui'; export * from './ui';
@ -134,6 +137,10 @@ export const Utils = {
// legacy (a lot of plugins use the shorthand "ad" Utils.ad instead of Utils.android) // legacy (a lot of plugins use the shorthand "ad" Utils.ad instead of Utils.android)
ad: androidUtils, ad: androidUtils,
ios: iosUtils, ios: iosUtils,
setTimeout,
setInterval,
clearInterval,
clearTimeout,
Source, Source,
ClassInfo, ClassInfo,
getClass, getClass,

View File

@ -3,7 +3,7 @@
"main": "index", "main": "index",
"types": "index.d.ts", "types": "index.d.ts",
"description": "NativeScript Core Modules", "description": "NativeScript Core Modules",
"version": "7.0.0", "version": "7.0.2",
"homepage": "https://nativescript.org", "homepage": "https://nativescript.org",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -74,7 +74,7 @@ export type { TabStripItemEventData } from './tab-navigation-base/tab-strip';
export { TabStripItem } from './tab-navigation-base/tab-strip-item'; export { TabStripItem } from './tab-navigation-base/tab-strip-item';
export { TabView, TabViewItem } from './tab-view'; export { TabView, TabViewItem } from './tab-view';
export { Tabs } from './tabs'; export { Tabs } from './tabs';
export { TextBase, getTransformedText } from './text-base'; export { TextBase, getTransformedText, letterSpacingProperty, textAlignmentProperty, textDecorationProperty, textTransformProperty, whiteSpaceProperty, lineHeightProperty } from './text-base';
export type { TextTransform } from './text-base'; export type { TextTransform } from './text-base';
export { FormattedString } from './text-base/formatted-string'; export { FormattedString } from './text-base/formatted-string';
export { Span } from './text-base/span'; export { Span } from './text-base/span';

View File

@ -1,6 +1,6 @@
{ {
"name": "@nativescript/webpack", "name": "@nativescript/webpack",
"version": "3.0.1", "version": "3.0.4",
"main": "index", "main": "index",
"description": "Webpack plugin for NativeScript", "description": "Webpack plugin for NativeScript",
"homepage": "https://nativescript.org", "homepage": "https://nativescript.org",

View File

@ -1,3 +1,7 @@
/**
* @see https://github.com/NativeScript/NativeScript/tree/feat/ns7-finishing-touches/packages/webpack/templates
* @see https://github.com/NativeScript/NativeScript/pull/8801/files
*/
const webpackConfig = require("./webpack.typescript"); const webpackConfig = require("./webpack.typescript");
const webpack = require("webpack"); const webpack = require("webpack");
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin'); const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
@ -8,101 +12,73 @@ module.exports = (env) => {
const production = env.production; const production = env.production;
const isAnySourceMapEnabled = !!env.sourceMap || !!env.hiddenSourceMap; const isAnySourceMapEnabled = !!env.sourceMap || !!env.hiddenSourceMap;
const babelOptions = {
sourceMaps: isAnySourceMapEnabled ? "inline" : false,
babelrc: false,
presets: [
// https://github.com/Microsoft/TypeScript-Babel-Starter
"@babel/env",
"@babel/typescript",
"@babel/react"
],
plugins: [
...(
hmr && !production ?
[
require.resolve('react-refresh/babel')
] :
[]
),
["@babel/plugin-proposal-class-properties", { loose: true }]
]
};
const baseConfig = webpackConfig(env); const baseConfig = webpackConfig(env);
// Remove ts-loader as we'll be using Babel to transpile the TypeScript instead. /** Find the rule for transpiling ts files ("ts-loader"), and modify it to test for .tsx files too. */
baseConfig.module.rules = baseConfig.module.rules.filter((rule) => { const tsxRule = baseConfig.module.rules.find(rule => rule.use && rule.use.loader === "ts-loader");
const isTsLoader = rule.use && rule.use.loader === "ts-loader"; tsxRule.test = /\.(ts|tsx)$/;
return !isTsLoader; tsxRule.use = [
}); /**
* Add React Refresh HMR support.
// Modify "nativescript-dev-webpack/hmr/hot-loader" to test for .tsx files * @see https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/55028c6355b31e697e21bf3e9a48613a7b94bee7/examples/typescript-without-babel/webpack.config.js#L18-L21
// (and also js(x) files, which it should have been doing to begin with!) */
baseConfig.module.rules.some(rule => { hmr && !production && {
const isNativeScriptDevWebpackHotLoader = rule.use === "nativescript-dev-webpack/hmr/hot-loader";
if(isNativeScriptDevWebpackHotLoader){
rule.test = /\.(ts|tsx|js|jsx|css|scss|html|xml)$/;
}
return isNativeScriptDevWebpackHotLoader; // Break loop once we've found the one.
});
baseConfig.module.rules.push(
{
test: /\.[jt]s(x?)$/,
exclude: /node_modules/,
use: [
{
loader: "babel-loader", loader: "babel-loader",
options: babelOptions options: {
sourceMaps: isAnySourceMapEnabled ? "inline" : false,
babelrc: false,
plugins: ['react-refresh/babel']
} }
], },
} tsxRule.use,
); ].filter(Boolean);
baseConfig.resolve.extensions = [".ts", ".tsx", ".js", ".jsx", ".scss", ".css"]; /**
* Modify "nativescript-dev-webpack/hmr/hot-loader" to test for .tsx files
* (and also js files, which it should have been doing to begin with!)
*/
const nativeScriptDevWebpackHotLoader = baseConfig.module.rules.find(rule =>
rule.use === "@nativescript/webpack/hmr/hot-loader"
);
nativeScriptDevWebpackHotLoader.test = /\.(ts|tsx|js|css|scss|html|xml)$/;
/** We don't officially support JSX. Makes the webpack config rather more complicated to set up. */
baseConfig.resolve.extensions = [".tsx", ...baseConfig.resolve.extensions];
baseConfig.resolve.alias["react-dom"] = "react-nativescript"; baseConfig.resolve.alias["react-dom"] = "react-nativescript";
// Remove ForkTsCheckerWebpackPlugin because, now that we're using Babel, we'll leave type-checking to the IDE instead. /** Augment NativeScript's existing DefinePlugin definitions with a few more of our own. */
baseConfig.plugins = baseConfig.plugins.filter(plugin => { const existingDefinePlugin = baseConfig.plugins.find(plugin =>
const isForkTsCheckerWebpackPlugin = plugin && plugin.constructor && plugin.constructor.name === "ForkTsCheckerWebpackPlugin"; plugin && plugin.constructor && plugin.constructor.name === "DefinePlugin"
return !isForkTsCheckerWebpackPlugin; );
}); baseConfig.plugins.splice(
baseConfig.plugins.indexOf(existingDefinePlugin),
// Augment NativeScript's existing DefinePlugin definitions with a few more of our own. 1,
let existingDefinePlugin; new webpack.DefinePlugin({
baseConfig.plugins = baseConfig.plugins.filter(plugin => {
const isDefinePlugin = plugin && plugin.constructor && plugin.constructor.name === "DefinePlugin";
existingDefinePlugin = plugin;
return !isDefinePlugin;
});
const newDefinitions = {
...existingDefinePlugin.definitions, ...existingDefinePlugin.definitions,
/* For various libraries in the React ecosystem. */ /** For various libraries in the React ecosystem. */
"__DEV__": production ? "false" : "true", "__DEV__": production ? "false" : "true",
"__TEST__": "false", "__TEST__": "false",
/* /**
* Primarily for React Fast Refresh plugin, but technically the forceEnable option could be used instead. * Primarily for React Fast Refresh plugin, but technically the allowHmrInProduction option could be used instead.
* Worth including anyway, as there are plenty of Node libraries that use this flag. * Worth including anyway, as there are plenty of Node libraries that use this flag.
*/ */
"process.env.NODE_ENV": JSON.stringify(production ? "production" : "development"), "process.env.NODE_ENV": JSON.stringify(production ? "production" : "development"),
}; }),
baseConfig.plugins.unshift(new webpack.DefinePlugin(newDefinitions)); );
/** if(hmr && !production){
* Set forceEnable to `true` if you want to use HMR on a production build.
*/
const forceEnable = false;
if(hmr && (!production || forceEnable)){
baseConfig.plugins.push(new ReactRefreshWebpackPlugin({ baseConfig.plugins.push(new ReactRefreshWebpackPlugin({
/** /**
* Maybe one day we'll implement an Error Overlay, but the work involved is too daunting for now. * Maybe one day we'll implement an Error Overlay, but the work involved is too daunting for now.
* @see https://github.com/pmmmwh/react-refresh-webpack-plugin/issues/79#issuecomment-644324557 * @see https://github.com/pmmmwh/react-refresh-webpack-plugin/issues/79#issuecomment-644324557
*/ */
overlay: false, overlay: false,
forceEnable, /**
* If you (temporarily) want to enable HMR on a production build:
* 1) Set `forceEnable` to `true`
* 2) Remove the `!production` condition on `tsxRule` to ensure that babel-loader gets used.
*/
forceEnable: false,
})); }));
} else { } else {
baseConfig.plugins = baseConfig.plugins.filter(p => !(p && p.constructor && p.constructor.name === "HotModuleReplacementPlugin")); baseConfig.plugins = baseConfig.plugins.filter(p => !(p && p.constructor && p.constructor.name === "HotModuleReplacementPlugin"));

View File

@ -5,7 +5,7 @@ const {
getPackageJson, getPackageJson,
getProjectDir, getProjectDir,
writePackageJson, writePackageJson,
} = require("../projectHelpers"); } = require("../helpers/projectHelpers");
const { forceUpdateProjectFiles } = require("../helpers/projectFilesManager"); const { forceUpdateProjectFiles } = require("../helpers/projectFilesManager");
const { forceUpdateProjectDeps } = require("../helpers/dependencyManager"); const { forceUpdateProjectDeps } = require("../helpers/dependencyManager");

View File

@ -300,12 +300,8 @@
"builder": "@nrwl/workspace:run-commands", "builder": "@nrwl/workspace:run-commands",
"options": { "options": {
"commands": [ "commands": [
{ "./build.sh",
"command": "./build.sh" "cp -R dist/package/platforms/* ../../packages/core/platforms"
},
{
"command": "cp -R dist/package/platforms/* ../../packages/core/platforms"
}
], ],
"cwd": "packages/ui-mobile-base", "cwd": "packages/ui-mobile-base",
"parallel": false "parallel": false
@ -337,12 +333,8 @@
"builder": "@nrwl/workspace:run-commands", "builder": "@nrwl/workspace:run-commands",
"options": { "options": {
"commands": [ "commands": [
{ "npm run tsc",
"command": "npm run tsc" "npm run jasmine"
},
{
"command": "npm run jasmine"
}
], ],
"cwd": "packages/webpack", "cwd": "packages/webpack",
"parallel": false "parallel": false
@ -353,15 +345,9 @@
"outputs": ["dist/packages"], "outputs": ["dist/packages"],
"options": { "options": {
"commands": [ "commands": [
{ "npm run setup",
"command": "npm run setup" "mkdir -p ../../dist/packages",
}, "mv \"$(npm pack | tail -n 1)\" ../../dist/packages/nativescript-webpack.tgz"
{
"command": "mkdir -p ../../dist/packages"
},
{
"command": "mv \"$(npm pack | tail -n 1)\" ../../dist/packages/nativescript-webpack.tgz"
}
], ],
"cwd": "packages/webpack", "cwd": "packages/webpack",
"parallel": false "parallel": false