Merge branch 'master' into feat/webpack5-polyfills

This commit is contained in:
Nathan Walker
2021-12-21 18:27:39 -08:00
committed by GitHub
98 changed files with 1465 additions and 1232 deletions

View File

@@ -94,6 +94,52 @@ interface IConfigAndroid extends IConfigPlatform {
enableMultithreadedJavascript?: boolean;
}
interface IConfigCLI {
/**
* Set the package manager to use for this project.
* Defaults to the CLI set package manager, or `npm` if not set globally
*/
packageManager: 'yarn' | 'pnpm' | 'npm';
}
interface IConfigHook {
// prettier-ignore
/**
* Event name for when to run the hook.
* Possible event names are any of the following with the pattern
* `before-*` and `after-*`
*
* * `buildAndroidPlugin` - Builds aar file for Android plugin, runs during prepareNativeApp
* * `buildAndroid` - Builds Android app
* * `buildIOS` - Builds iOS app
* * `checkEnvironment` - Validate project env, runs during ns doctor, clean, and most build commands
* * `checkForChanges` - Changes occured during watch
* * `install` - Application installed to device/emulator
* * `prepare` - Compiles webpack and prepares native app in platforms folder
* * `prepareNativeApp` - Preparing the actual native app, runs during prepare/watch hook
* * `resolveCommand` - Resolves command and arguments, runs before all cli commands
* * `watch` - Setup watchers for live sync, runs during prepare hook
* * `watchPatterns` - Setup watch patterns, runs during watch hook
*/
type:
| 'before-buildAndroidPlugin' | 'after-buildAndroidPlugin'
| 'before-buildAndroid' | 'after-buildAndroid'
| 'before-buildIOS' | 'after-buildIOS'
| 'before-checkEnvironment' | 'after-checkEnvironment'
| 'before-checkForChanges' | 'after-checkForChanges'
| 'before-install' | 'after-install'
| 'before-prepare' | 'after-prepare'
| 'before-prepareNativeApp' | 'after-prepareNativeApp'
| 'before-resolveCommand' | 'after-resolveCommand'
| 'before-watch' | 'after-watch'
| 'before-watchPatterns' | 'after-watchPatterns';
/**
* Path to the hook script file to run
*/
script: string;
}
export interface NativeScriptConfig {
/**
* App's bundle id
@@ -147,4 +193,14 @@ export interface NativeScriptConfig {
* Optionally specify a list of npm package names for which you would like the NativeScript CLI to ignore when attaching native dependencies to the build
*/
ignoredNativeDependencies?: string[];
/**
* Set cli options
*/
cli?: IConfigCLI;
/**
* Set project persistent hooks to run
*/
hooks?: IConfigHook[];
}

View File

@@ -175,7 +175,7 @@ export class DOMNode {
dispose() {
unregisterNode(this);
this.viewRef.clear();
// this.viewRef.clear();
}
public toObject() {

View File

@@ -0,0 +1,55 @@
{
"root": "packages/core",
"sourceRoot": "packages/core",
"projectType": "library",
"generators": {},
"targets": {
"lint": {
"executor": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": ["packages/core/**/*.ts", "packages/core/references.d.ts", "packages/core/**/*.spec.ts", "packages/core/**/*.spec.tsx", "packages/core/**/*.spec.js", "packages/core/**/*.spec.jsx", "packages/core/**/*.d.ts"]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"options": {
"jestConfig": "packages/core/jest.config.js",
"passWithNoTests": true
},
"outputs": ["coverage/packages/core"]
},
"build": {
"executor": "@nrwl/workspace:run-commands",
"outputs": ["dist/packages"],
"options": {
"commands": [
"npx rimraf dist/packages/core",
"./node_modules/.bin/tsc -p packages/core/tsconfig.lib.json",
"./node_modules/.bin/copyfiles -e \"packages/core/__tests__/**/*\" \"packages/core/**/*.d.ts\" dist && ./node_modules/.bin/copyfiles -e \"packages/core/__tests__/**/*\" \"packages/core/js-libs/**/*\" dist && ./node_modules/.bin/copyfiles -e \"packages/core/__tests__/**/*\" \"packages/core/cli-hooks/**/*.js\" dist && ./node_modules/.bin/copyfiles -e \"packages/core/__tests__/**/*\" \"packages/core/platforms/**/*\" dist && ./node_modules/.bin/copyfiles -e \"packages/core/__tests__/**/*\" \"packages/core/fetch/**/*\" dist && ./node_modules/.bin/copyfiles -e \"packages/core/__tests__/**/*\" \"packages/core/css/**/*\" dist && ./node_modules/.bin/copyfiles -e \"packages/core/__tests__/**/*\" \"packages/core/css-value/**/*\" dist",
"cp packages/core/package.json dist/packages/core",
"cp packages/core/README.md dist/packages/core",
"cp LICENSE dist/packages/core",
"cd dist/packages/core && npm pack && mv *.tgz .."
],
"cwd": ".",
"parallel": false
}
},
"unit": {
"executor": "@nrwl/workspace:run-commands",
"options": {
"commands": ["../../../node_modules/.bin/tsc -p tsconfig.json && ../../../node_modules/.bin/mocha --config=.mocharc.yml"],
"cwd": "packages/core/__tests__",
"parallel": false
}
},
"unit.watch": {
"executor": "@nrwl/workspace:run-commands",
"options": {
"commands": ["../../../node_modules/.bin/tsc -p tsconfig.json && ../../../node_modules/.bin/mocha --watch --config=.mocharc.yml"],
"cwd": "packages/core/__tests__",
"parallel": false
}
}
}
}

View File

@@ -1,8 +1,8 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": "."
},
"include": ["**/*.ts", "./references.d.ts"],
"exclude": ["dist", "__tests__"]
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"baseUrl": "."
},
"include": ["**/*.ts", "./references.d.ts"],
"exclude": ["dist", "__tests__"]
}

View File

@@ -22,6 +22,6 @@
}
]
},
"exclude": ["**/*.spec.ts", "dist", "__tests__"],
"exclude": ["**/*.spec.ts", "**/*.test.ts", "dist", "__tests__"],
"include": ["**/*.ts", "./references.d.ts"]
}

View File

@@ -1,15 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": [
"**/*.spec.ts",
"**/*.spec.tsx",
"**/*.spec.js",
"**/*.spec.jsx",
"**/*.d.ts"
]
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": ["**/*.spec.ts", "**/*.test.ts", "**/*.spec.tsx", "**/*.test.tsx", "**/*.spec.js", "**/*.test.js", "**/*.spec.jsx", "**/*.test.jsx", "**/*.d.ts"]
}

View File

@@ -3,7 +3,7 @@ import { ScopeError, SourceError, Source } from '../../utils/debug';
import * as xml from '../../xml';
import { isString, isObject } from '../../utils/types';
import { getComponentModule } from './component-builder';
import { ComponentModule } from './component-builder';
import type { ComponentModule } from './component-builder';
import { Device } from '../../platform';
import { profile } from '../../profiling';
import { android, ios, loadCustomComponent, defaultNameSpaceMatcher, getExports, Builder } from './index';
@@ -296,7 +296,7 @@ export namespace xml2ui {
return this._value;
}
constructor(private parent: XmlStateConsumer, private templateProperty: TemplateProperty) { }
constructor(private parent: XmlStateConsumer, private templateProperty: TemplateProperty) {}
public parse(args: xml.ParserEvent): XmlStateConsumer {
if (args.eventType === xml.ParserEventType.StartElement && args.elementName === 'template') {
@@ -331,7 +331,7 @@ export namespace xml2ui {
export const enum State {
EXPECTING_START,
PARSING,
FINISHED
FINISHED,
}
}
@@ -514,7 +514,7 @@ export namespace xml2ui {
parent: ComponentModule;
name: string;
items?: Array<any>;
parser?: { value: any; };
parser?: { value: any };
}
}
}

View File

@@ -164,9 +164,9 @@ export class Binding {
this.propertyChangeListeners.clear();
if (this.source) {
this.source.clear();
}
// if (this.source) {
// this.source.clear();
// }
if (this.sourceOptions) {
this.sourceOptions.instance.clear();

View File

@@ -853,7 +853,7 @@ export class View extends ViewCommon implements ViewDefinition {
_setNativeClipToBounds() {
const backgroundInternal = this.style.backgroundInternal;
this.nativeViewProtected.clipsToBounds = this.nativeViewProtected instanceof UIScrollView || backgroundInternal.hasBorderWidth() || backgroundInternal.hasBorderRadius();
this.nativeViewProtected.clipsToBounds = (this.nativeViewProtected instanceof UIScrollView || backgroundInternal.hasBorderWidth() || backgroundInternal.hasBorderRadius()) && !backgroundInternal.hasBoxShadow();
}
private _setupPopoverControllerDelegate(controller: UIViewController, parent: View) {

View File

@@ -92,13 +92,19 @@ class CSSSource {
if (typeof cssOrAst === 'string') {
// raw-loader
return CSSSource.fromSource(cssOrAst, keyframes, fileName);
} else if (typeof cssOrAst === 'object' && cssOrAst.type === 'stylesheet' && cssOrAst.stylesheet && cssOrAst.stylesheet.rules) {
// css-loader
return CSSSource.fromAST(cssOrAst, keyframes, fileName);
} else {
// css2json-loader
return CSSSource.fromSource(cssOrAst.toString(), keyframes, fileName);
} else if (typeof cssOrAst === 'object') {
if (cssOrAst.default) {
cssOrAst = cssOrAst.default;
}
if (cssOrAst.type === 'stylesheet' && cssOrAst.stylesheet && cssOrAst.stylesheet.rules) {
// css-loader
return CSSSource.fromAST(cssOrAst, keyframes, fileName);
}
}
// css2json-loader
return CSSSource.fromSource(cssOrAst.toString(), keyframes, fileName);
}
public static fromURI(uri: string, keyframes: KeyframesMap): CSSSource {

View File

@@ -55,6 +55,11 @@ export class WebView extends View {
*/
canGoForward: boolean;
/**
* Disable scrolling in the WebView
*/
disableZoom: boolean;
/**
* Stops loading the current content (if any).
*/

View File

@@ -0,0 +1,17 @@
{
"root": "packages/types-android",
"sourceRoot": "packages/types-android/src",
"projectType": "library",
"generators": {},
"targets": {
"build": {
"executor": "@nrwl/workspace:run-commands",
"outputs": ["dist/packages"],
"options": {
"commands": ["mkdir -p ../../dist/packages/types-android", "cp -R src/* ../../dist/packages/types-android", "cp package.json *.md ../../dist/packages/types-android"],
"cwd": "packages/types-android",
"parallel": false
}
}
}
}

View File

@@ -0,0 +1,16 @@
{
"root": "packages/types-ios",
"sourceRoot": "packages/types-ios/src",
"projectType": "library",
"generators": {},
"targets": {
"build": {
"executor": "@nrwl/workspace:run-commands",
"outputs": ["dist/packages"],
"options": {
"commands": ["./tools/scripts/typings-gen.sh latest", "mkdir -p dist/packages/types-ios", "cp -R packages/types-ios/src/* dist/packages/types-ios", "cp packages/types-ios/package.json dist/packages/types-ios", "cp packages/types-ios/README.md dist/packages/types-ios/README.md"],
"parallel": false
}
}
}
}

View File

@@ -0,0 +1,17 @@
{
"root": "packages/types",
"sourceRoot": "packages/types",
"projectType": "library",
"generators": {},
"targets": {
"build": {
"executor": "@nrwl/workspace:run-commands",
"outputs": ["dist/packages"],
"options": {
"commands": ["mkdir -p ../../dist/packages/types", "cp -R * ../../dist/packages/types"],
"cwd": "packages/types",
"parallel": false
}
}
}
}

View File

@@ -0,0 +1,16 @@
{
"root": "packages/ui-mobile-base",
"sourceRoot": "packages/ui-mobile-base",
"projectType": "library",
"generators": {},
"targets": {
"build": {
"executor": "@nrwl/workspace:run-commands",
"options": {
"commands": ["./build.sh", "cp -R dist/package/platforms/* ../../packages/core/platforms"],
"cwd": "packages/ui-mobile-base",
"parallel": false
}
}
}
}

View File

@@ -0,0 +1,31 @@
{
"root": "packages/webpack",
"sourceRoot": "packages/webpack",
"projectType": "library",
"generators": {},
"targets": {
"lint": {
"executor": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": []
}
},
"test": {
"executor": "@nrwl/workspace:run-commands",
"options": {
"commands": ["npm run tsc", "npm run jasmine"],
"cwd": "packages/webpack",
"parallel": false
}
},
"build": {
"executor": "@nrwl/workspace:run-commands",
"outputs": ["dist/packages"],
"options": {
"commands": ["npm run setup", "mkdir -p ../../dist/packages", "mv \"$(npm pack | tail -n 1)\" ../../dist/packages/nativescript-webpack.tgz"],
"cwd": "packages/webpack",
"parallel": false
}
}
}
}

View File

@@ -84,23 +84,9 @@ exports[`angular configuration for android 1`] = `
options: {
platform: 'android'
}
},
/* config.module.rule('bundle').use('nativescript-hot-loader') */
{
loader: 'nativescript-hot-loader',
options: {
injectHMRRuntime: true
}
}
]
},
/* config.module.rule('js') */
{
test: /\\\\.js$/,
exclude: [
/node_modules/
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
@@ -111,6 +97,13 @@ exports[`angular configuration for android 1`] = `
}
]
},
/* config.module.rule('js') */
{
test: /\\\\.js$/,
exclude: [
/node_modules/
]
},
/* config.module.rule('xml') */
{
test: /\\\\.xml$/,
@@ -144,7 +137,12 @@ exports[`angular configuration for android 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -174,7 +172,12 @@ exports[`angular configuration for android 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -185,6 +188,26 @@ exports[`angular configuration for android 1`] = `
}
]
},
/* config.module.rule('angular-webpack-loader') */
{
test: /\\\\.[cm]?[tj]sx?$/,
exclude: [
/[/\\\\\\\\](?:core-js|@babel|tslib|web-animations-js|web-streams-polyfill)[/\\\\\\\\]/
],
use: [
/* config.module.rule('angular-webpack-loader').use('webpack-loader') */
{
loader: '@angular-devkit/build-angular/src/babel/webpack-loader',
options: {
scriptTarget: 99,
aot: true
}
}
],
resolve: {
fullySpecified: false
}
},
/* config.module.rule('angular') */
{
test: /(?:\\\\.ngfactory.js|\\\\.ngstyle\\\\.js|\\\\.ts)$/,
@@ -246,7 +269,12 @@ exports[`angular configuration for android 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -378,8 +406,8 @@ exports[`angular configuration for android 1`] = `
],
entry: {
bundle: [
'@nativescript/core/globals/index.js',
'@nativescript/core/bundle-entry-points.js',
'@nativescript/core/globals/index',
'@nativescript/core/bundle-entry-points',
'__jest__/src/app.js',
'@nativescript/core/ui/frame',
'@nativescript/core/ui/frame/activity'
@@ -472,23 +500,9 @@ exports[`angular configuration for ios 1`] = `
options: {
platform: 'ios'
}
},
/* config.module.rule('bundle').use('nativescript-hot-loader') */
{
loader: 'nativescript-hot-loader',
options: {
injectHMRRuntime: true
}
}
]
},
/* config.module.rule('js') */
{
test: /\\\\.js$/,
exclude: [
/node_modules/
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
@@ -499,6 +513,13 @@ exports[`angular configuration for ios 1`] = `
}
]
},
/* config.module.rule('js') */
{
test: /\\\\.js$/,
exclude: [
/node_modules/
]
},
/* config.module.rule('xml') */
{
test: /\\\\.xml$/,
@@ -532,7 +553,12 @@ exports[`angular configuration for ios 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -562,7 +588,12 @@ exports[`angular configuration for ios 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -573,6 +604,26 @@ exports[`angular configuration for ios 1`] = `
}
]
},
/* config.module.rule('angular-webpack-loader') */
{
test: /\\\\.[cm]?[tj]sx?$/,
exclude: [
/[/\\\\\\\\](?:core-js|@babel|tslib|web-animations-js|web-streams-polyfill)[/\\\\\\\\]/
],
use: [
/* config.module.rule('angular-webpack-loader').use('webpack-loader') */
{
loader: '@angular-devkit/build-angular/src/babel/webpack-loader',
options: {
scriptTarget: 99,
aot: true
}
}
],
resolve: {
fullySpecified: false
}
},
/* config.module.rule('angular') */
{
test: /(?:\\\\.ngfactory.js|\\\\.ngstyle\\\\.js|\\\\.ts)$/,
@@ -634,7 +685,12 @@ exports[`angular configuration for ios 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -766,8 +822,8 @@ exports[`angular configuration for ios 1`] = `
],
entry: {
bundle: [
'@nativescript/core/globals/index.js',
'@nativescript/core/bundle-entry-points.js',
'@nativescript/core/globals/index',
'@nativescript/core/bundle-entry-points',
'__jest__/src/app.js'
],
'tns_modules/inspector_modules': [
@@ -780,7 +836,7 @@ exports[`angular configuration for ios 1`] = `
exports[`angular configuration loads polyfills.android.ts into the bundle entry if it exists 1`] = `
Array [
"__jest__/src/polyfills.android.ts",
"@nativescript/core/bundle-entry-points.js",
"@nativescript/core/bundle-entry-points",
"__jest__/src/app.js",
"@nativescript/core/ui/frame",
"@nativescript/core/ui/frame/activity",
@@ -790,7 +846,7 @@ Array [
exports[`angular configuration loads polyfills.ios.ts into the bundle entry if it exists 1`] = `
Array [
"__jest__/src/polyfills.ios.ts",
"@nativescript/core/bundle-entry-points.js",
"@nativescript/core/bundle-entry-points",
"__jest__/src/app.js",
]
`;
@@ -798,7 +854,7 @@ Array [
exports[`angular configuration loads polyfills.ts into the bundle entry if it exists 1`] = `
Array [
"__jest__/src/polyfills.ts",
"@nativescript/core/bundle-entry-points.js",
"@nativescript/core/bundle-entry-points",
"__jest__/src/app.js",
]
`;

View File

@@ -72,13 +72,16 @@ exports[`base configuration for android 1`] = `
options: {
platform: 'android'
}
},
/* config.module.rule('bundle').use('nativescript-hot-loader') */
}
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-hot-loader',
options: {
injectHMRRuntime: true
}
loader: 'nativescript-worker-loader'
}
]
},
@@ -110,16 +113,6 @@ exports[`base configuration for android 1`] = `
/node_modules/
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-worker-loader'
}
]
},
/* config.module.rule('xml') */
{
test: /\\\\.xml$/,
@@ -148,7 +141,12 @@ exports[`base configuration for android 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -173,7 +171,12 @@ exports[`base configuration for android 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -301,8 +304,8 @@ exports[`base configuration for android 1`] = `
],
entry: {
bundle: [
'@nativescript/core/globals/index.js',
'@nativescript/core/bundle-entry-points.js',
'@nativescript/core/globals/index',
'@nativescript/core/bundle-entry-points',
'__jest__/src/app.js',
'@nativescript/core/ui/frame',
'@nativescript/core/ui/frame/activity'
@@ -383,13 +386,16 @@ exports[`base configuration for ios 1`] = `
options: {
platform: 'ios'
}
},
/* config.module.rule('bundle').use('nativescript-hot-loader') */
}
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-hot-loader',
options: {
injectHMRRuntime: true
}
loader: 'nativescript-worker-loader'
}
]
},
@@ -421,16 +427,6 @@ exports[`base configuration for ios 1`] = `
/node_modules/
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-worker-loader'
}
]
},
/* config.module.rule('xml') */
{
test: /\\\\.xml$/,
@@ -459,7 +455,12 @@ exports[`base configuration for ios 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -484,7 +485,12 @@ exports[`base configuration for ios 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -612,8 +618,8 @@ exports[`base configuration for ios 1`] = `
],
entry: {
bundle: [
'@nativescript/core/globals/index.js',
'@nativescript/core/bundle-entry-points.js',
'@nativescript/core/globals/index',
'@nativescript/core/bundle-entry-points',
'__jest__/src/app.js'
],
'tns_modules/inspector_modules': [

View File

@@ -72,13 +72,16 @@ exports[`javascript configuration for android 1`] = `
options: {
platform: 'android'
}
},
/* config.module.rule('bundle').use('nativescript-hot-loader') */
}
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-hot-loader',
options: {
injectHMRRuntime: true
}
loader: 'nativescript-worker-loader'
}
]
},
@@ -110,16 +113,6 @@ exports[`javascript configuration for android 1`] = `
/node_modules/
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-worker-loader'
}
]
},
/* config.module.rule('xml') */
{
test: /\\\\.xml$/,
@@ -148,7 +141,12 @@ exports[`javascript configuration for android 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -173,7 +171,12 @@ exports[`javascript configuration for android 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -183,23 +186,6 @@ exports[`javascript configuration for android 1`] = `
loader: 'sass-loader'
}
]
},
/* config.module.rule('hmr-core') */
{
test: /\\\\.js$/,
exclude: [
/node_modules/,
'__jest__/src/app.js'
],
use: [
/* config.module.rule('hmr-core').use('nativescript-hot-loader') */
{
loader: 'nativescript-hot-loader',
options: {
appPath: '__jest__/src'
}
}
]
}
]
},
@@ -326,9 +312,9 @@ exports[`javascript configuration for android 1`] = `
],
entry: {
bundle: [
'@nativescript/core/globals/index.js',
'@nativescript/core/globals/index',
'__jest__/src/__@nativescript_webpack_virtual_entry_javascript__',
'@nativescript/core/bundle-entry-points.js',
'@nativescript/core/bundle-entry-points',
'__jest__/src/app.js',
'@nativescript/core/ui/frame',
'@nativescript/core/ui/frame/activity'
@@ -409,13 +395,16 @@ exports[`javascript configuration for ios 1`] = `
options: {
platform: 'ios'
}
},
/* config.module.rule('bundle').use('nativescript-hot-loader') */
}
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-hot-loader',
options: {
injectHMRRuntime: true
}
loader: 'nativescript-worker-loader'
}
]
},
@@ -447,16 +436,6 @@ exports[`javascript configuration for ios 1`] = `
/node_modules/
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-worker-loader'
}
]
},
/* config.module.rule('xml') */
{
test: /\\\\.xml$/,
@@ -485,7 +464,12 @@ exports[`javascript configuration for ios 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -510,7 +494,12 @@ exports[`javascript configuration for ios 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -520,23 +509,6 @@ exports[`javascript configuration for ios 1`] = `
loader: 'sass-loader'
}
]
},
/* config.module.rule('hmr-core') */
{
test: /\\\\.js$/,
exclude: [
/node_modules/,
'__jest__/src/app.js'
],
use: [
/* config.module.rule('hmr-core').use('nativescript-hot-loader') */
{
loader: 'nativescript-hot-loader',
options: {
appPath: '__jest__/src'
}
}
]
}
]
},
@@ -663,9 +635,9 @@ exports[`javascript configuration for ios 1`] = `
],
entry: {
bundle: [
'@nativescript/core/globals/index.js',
'@nativescript/core/globals/index',
'__jest__/src/__@nativescript_webpack_virtual_entry_javascript__',
'@nativescript/core/bundle-entry-points.js',
'@nativescript/core/bundle-entry-points',
'__jest__/src/app.js'
],
'tns_modules/inspector_modules': [

View File

@@ -85,6 +85,16 @@ exports[`react configuration > android > adds ReactRefreshWebpackPlugin when HMR
}
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-worker-loader'
}
]
},
/* config.module.rule('ts') */
{
test: [
@@ -125,16 +135,6 @@ exports[`react configuration > android > adds ReactRefreshWebpackPlugin when HMR
/node_modules/
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-worker-loader'
}
]
},
/* config.module.rule('xml') */
{
test: /\\\\.xml$/,
@@ -163,7 +163,12 @@ exports[`react configuration > android > adds ReactRefreshWebpackPlugin when HMR
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -188,7 +193,12 @@ exports[`react configuration > android > adds ReactRefreshWebpackPlugin when HMR
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -317,14 +327,14 @@ exports[`react configuration > android > adds ReactRefreshWebpackPlugin when HMR
overlay: false,
forceEnable: false,
exclude: /node_modules/i,
include: /\\\\.([jt]sx?|flow)$/i
include: /\\\\.([cm]js|[jt]sx?|flow)$/i
}
)
],
entry: {
bundle: [
'@nativescript/core/globals/index.js',
'@nativescript/core/bundle-entry-points.js',
'@nativescript/core/globals/index',
'@nativescript/core/bundle-entry-points',
'__jest__/src/app.js',
'@nativescript/core/ui/frame',
'@nativescript/core/ui/frame/activity'
@@ -408,13 +418,16 @@ exports[`react configuration > android > base config 1`] = `
options: {
platform: 'android'
}
},
/* config.module.rule('bundle').use('nativescript-hot-loader') */
}
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-hot-loader',
options: {
injectHMRRuntime: true
}
loader: 'nativescript-worker-loader'
}
]
},
@@ -447,16 +460,6 @@ exports[`react configuration > android > base config 1`] = `
/node_modules/
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-worker-loader'
}
]
},
/* config.module.rule('xml') */
{
test: /\\\\.xml$/,
@@ -485,7 +488,12 @@ exports[`react configuration > android > base config 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -510,7 +518,12 @@ exports[`react configuration > android > base config 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -634,8 +647,8 @@ exports[`react configuration > android > base config 1`] = `
],
entry: {
bundle: [
'@nativescript/core/globals/index.js',
'@nativescript/core/bundle-entry-points.js',
'@nativescript/core/globals/index',
'@nativescript/core/bundle-entry-points',
'__jest__/src/app.js',
'@nativescript/core/ui/frame',
'@nativescript/core/ui/frame/activity'
@@ -729,6 +742,16 @@ exports[`react configuration > ios > adds ReactRefreshWebpackPlugin when HMR ena
}
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-worker-loader'
}
]
},
/* config.module.rule('ts') */
{
test: [
@@ -769,16 +792,6 @@ exports[`react configuration > ios > adds ReactRefreshWebpackPlugin when HMR ena
/node_modules/
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-worker-loader'
}
]
},
/* config.module.rule('xml') */
{
test: /\\\\.xml$/,
@@ -807,7 +820,12 @@ exports[`react configuration > ios > adds ReactRefreshWebpackPlugin when HMR ena
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -832,7 +850,12 @@ exports[`react configuration > ios > adds ReactRefreshWebpackPlugin when HMR ena
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -961,14 +984,14 @@ exports[`react configuration > ios > adds ReactRefreshWebpackPlugin when HMR ena
overlay: false,
forceEnable: false,
exclude: /node_modules/i,
include: /\\\\.([jt]sx?|flow)$/i
include: /\\\\.([cm]js|[jt]sx?|flow)$/i
}
)
],
entry: {
bundle: [
'@nativescript/core/globals/index.js',
'@nativescript/core/bundle-entry-points.js',
'@nativescript/core/globals/index',
'@nativescript/core/bundle-entry-points',
'__jest__/src/app.js'
],
'tns_modules/inspector_modules': [
@@ -1053,13 +1076,16 @@ exports[`react configuration > ios > base config 1`] = `
options: {
platform: 'ios'
}
},
/* config.module.rule('bundle').use('nativescript-hot-loader') */
}
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-hot-loader',
options: {
injectHMRRuntime: true
}
loader: 'nativescript-worker-loader'
}
]
},
@@ -1092,16 +1118,6 @@ exports[`react configuration > ios > base config 1`] = `
/node_modules/
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-worker-loader'
}
]
},
/* config.module.rule('xml') */
{
test: /\\\\.xml$/,
@@ -1130,7 +1146,12 @@ exports[`react configuration > ios > base config 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -1155,7 +1176,12 @@ exports[`react configuration > ios > base config 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -1279,8 +1305,8 @@ exports[`react configuration > ios > base config 1`] = `
],
entry: {
bundle: [
'@nativescript/core/globals/index.js',
'@nativescript/core/bundle-entry-points.js',
'@nativescript/core/globals/index',
'@nativescript/core/bundle-entry-points',
'__jest__/src/app.js'
],
'tns_modules/inspector_modules': [

View File

@@ -34,6 +34,7 @@ exports[`svelte configuration for android 1`] = `
alias: {
'~': '__jest__/src',
'@': '__jest__/src',
svelte$: 'svelte/internal',
'tns-core-modules': '@nativescript/core'
},
extensions: [
@@ -75,13 +76,16 @@ exports[`svelte configuration for android 1`] = `
options: {
platform: 'android'
}
},
/* config.module.rule('bundle').use('nativescript-hot-loader') */
}
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts|svelte)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-hot-loader',
options: {
injectHMRRuntime: true
}
loader: 'nativescript-worker-loader'
}
]
},
@@ -113,16 +117,6 @@ exports[`svelte configuration for android 1`] = `
/node_modules/
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts|svelte)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-worker-loader'
}
]
},
/* config.module.rule('xml') */
{
test: /\\\\.xml$/,
@@ -151,7 +145,12 @@ exports[`svelte configuration for android 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -176,7 +175,12 @@ exports[`svelte configuration for android 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -321,8 +325,8 @@ exports[`svelte configuration for android 1`] = `
],
entry: {
bundle: [
'@nativescript/core/globals/index.js',
'@nativescript/core/bundle-entry-points.js',
'@nativescript/core/globals/index',
'@nativescript/core/bundle-entry-points',
'__jest__/src/app.js',
'@nativescript/core/ui/frame',
'@nativescript/core/ui/frame/activity'
@@ -365,6 +369,7 @@ exports[`svelte configuration for ios 1`] = `
alias: {
'~': '__jest__/src',
'@': '__jest__/src',
svelte$: 'svelte/internal',
'tns-core-modules': '@nativescript/core'
},
extensions: [
@@ -406,13 +411,16 @@ exports[`svelte configuration for ios 1`] = `
options: {
platform: 'ios'
}
},
/* config.module.rule('bundle').use('nativescript-hot-loader') */
}
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts|svelte)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-hot-loader',
options: {
injectHMRRuntime: true
}
loader: 'nativescript-worker-loader'
}
]
},
@@ -444,16 +452,6 @@ exports[`svelte configuration for ios 1`] = `
/node_modules/
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts|svelte)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-worker-loader'
}
]
},
/* config.module.rule('xml') */
{
test: /\\\\.xml$/,
@@ -482,7 +480,12 @@ exports[`svelte configuration for ios 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -507,7 +510,12 @@ exports[`svelte configuration for ios 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -652,8 +660,8 @@ exports[`svelte configuration for ios 1`] = `
],
entry: {
bundle: [
'@nativescript/core/globals/index.js',
'@nativescript/core/bundle-entry-points.js',
'@nativescript/core/globals/index',
'@nativescript/core/bundle-entry-points',
'__jest__/src/app.js'
],
'tns_modules/inspector_modules': [

View File

@@ -72,13 +72,16 @@ exports[`typescript configuration for android 1`] = `
options: {
platform: 'android'
}
},
/* config.module.rule('bundle').use('nativescript-hot-loader') */
}
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-hot-loader',
options: {
injectHMRRuntime: true
}
loader: 'nativescript-worker-loader'
}
]
},
@@ -110,16 +113,6 @@ exports[`typescript configuration for android 1`] = `
/node_modules/
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-worker-loader'
}
]
},
/* config.module.rule('xml') */
{
test: /\\\\.xml$/,
@@ -148,7 +141,12 @@ exports[`typescript configuration for android 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -173,7 +171,12 @@ exports[`typescript configuration for android 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -183,23 +186,6 @@ exports[`typescript configuration for android 1`] = `
loader: 'sass-loader'
}
]
},
/* config.module.rule('hmr-core') */
{
test: /\\\\.(js|ts)$/,
exclude: [
/node_modules/,
'__jest__/src/app.js'
],
use: [
/* config.module.rule('hmr-core').use('nativescript-hot-loader') */
{
loader: 'nativescript-hot-loader',
options: {
appPath: '__jest__/src'
}
}
]
}
]
},
@@ -326,9 +312,9 @@ exports[`typescript configuration for android 1`] = `
],
entry: {
bundle: [
'@nativescript/core/globals/index.js',
'@nativescript/core/globals/index',
'__jest__/src/__@nativescript_webpack_virtual_entry_typescript__',
'@nativescript/core/bundle-entry-points.js',
'@nativescript/core/bundle-entry-points',
'__jest__/src/app.js',
'@nativescript/core/ui/frame',
'@nativescript/core/ui/frame/activity'
@@ -409,13 +395,16 @@ exports[`typescript configuration for ios 1`] = `
options: {
platform: 'ios'
}
},
/* config.module.rule('bundle').use('nativescript-hot-loader') */
}
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-hot-loader',
options: {
injectHMRRuntime: true
}
loader: 'nativescript-worker-loader'
}
]
},
@@ -447,16 +436,6 @@ exports[`typescript configuration for ios 1`] = `
/node_modules/
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-worker-loader'
}
]
},
/* config.module.rule('xml') */
{
test: /\\\\.xml$/,
@@ -485,7 +464,12 @@ exports[`typescript configuration for ios 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -510,7 +494,12 @@ exports[`typescript configuration for ios 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -520,23 +509,6 @@ exports[`typescript configuration for ios 1`] = `
loader: 'sass-loader'
}
]
},
/* config.module.rule('hmr-core') */
{
test: /\\\\.(js|ts)$/,
exclude: [
/node_modules/,
'__jest__/src/app.js'
],
use: [
/* config.module.rule('hmr-core').use('nativescript-hot-loader') */
{
loader: 'nativescript-hot-loader',
options: {
appPath: '__jest__/src'
}
}
]
}
]
},
@@ -663,9 +635,9 @@ exports[`typescript configuration for ios 1`] = `
],
entry: {
bundle: [
'@nativescript/core/globals/index.js',
'@nativescript/core/globals/index',
'__jest__/src/__@nativescript_webpack_virtual_entry_typescript__',
'@nativescript/core/bundle-entry-points.js',
'@nativescript/core/bundle-entry-points',
'__jest__/src/app.js'
],
'tns_modules/inspector_modules': [

View File

@@ -75,13 +75,16 @@ exports[`vue configuration for android 1`] = `
options: {
platform: 'android'
}
},
/* config.module.rule('bundle').use('nativescript-hot-loader') */
}
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-hot-loader',
options: {
injectHMRRuntime: true
}
loader: 'nativescript-worker-loader'
}
]
},
@@ -116,16 +119,6 @@ exports[`vue configuration for android 1`] = `
/node_modules/
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-worker-loader'
}
]
},
/* config.module.rule('xml') */
{
test: /\\\\.xml$/,
@@ -158,7 +151,12 @@ exports[`vue configuration for android 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -187,7 +185,12 @@ exports[`vue configuration for android 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -335,8 +338,8 @@ exports[`vue configuration for android 1`] = `
],
entry: {
bundle: [
'@nativescript/core/globals/index.js',
'@nativescript/core/bundle-entry-points.js',
'@nativescript/core/globals/index',
'@nativescript/core/bundle-entry-points',
'__jest__/src/app.js',
'@nativescript/core/ui/frame',
'@nativescript/core/ui/frame/activity'
@@ -420,13 +423,16 @@ exports[`vue configuration for ios 1`] = `
options: {
platform: 'ios'
}
},
/* config.module.rule('bundle').use('nativescript-hot-loader') */
}
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-hot-loader',
options: {
injectHMRRuntime: true
}
loader: 'nativescript-worker-loader'
}
]
},
@@ -461,16 +467,6 @@ exports[`vue configuration for ios 1`] = `
/node_modules/
]
},
/* config.module.rule('workers') */
{
test: /\\\\.(js|ts)$/,
use: [
/* config.module.rule('workers').use('nativescript-worker-loader') */
{
loader: 'nativescript-worker-loader'
}
]
},
/* config.module.rule('xml') */
{
test: /\\\\.xml$/,
@@ -503,7 +499,12 @@ exports[`vue configuration for ios 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -532,7 +533,12 @@ exports[`vue configuration for ios 1`] = `
options: {
postcssOptions: {
plugins: [
'postcss-import'
[
'postcss-import',
{
resolve: function () { /* omitted long function */ }
}
]
]
}
}
@@ -680,8 +686,8 @@ exports[`vue configuration for ios 1`] = `
],
entry: {
bundle: [
'@nativescript/core/globals/index.js',
'@nativescript/core/bundle-entry-points.js',
'@nativescript/core/globals/index',
'@nativescript/core/bundle-entry-points',
'__jest__/src/app.js'
],
'tns_modules/inspector_modules': [

View File

@@ -44,41 +44,43 @@ function getContext(
return {
rootContext: 'app',
context: 'app/component',
async: () => (error, source: string) => {
if (callbackCalled) {
done.fail('Callback called more than once!');
}
callbackCalled = true;
async() {
return (error, source: string) => {
if (callbackCalled) {
throw new Error('Callback called more than once!');
}
callbackCalled = true;
expectedDeps.forEach((expectedDep) => {
expect(actualDeps).toContain(expectedDep);
});
expectedDeps.forEach((expectedDep) => {
expect(actualDeps).toContain(expectedDep);
});
expectedRegs.forEach(({ name, path }) => {
expect(source).toContain(dedent`
expectedRegs.forEach(({ name, path }) => {
expect(source).toContain(dedent`
global.registerModule(
'${name}',
() => require("${path}")
)
`);
});
});
if (assureNoDeps) {
expect(actualDeps.length).toBe(0);
expect(source).not.toContain('global.registerModule');
}
if (assureNoDeps) {
expect(actualDeps.length).toBe(0);
expect(source).not.toContain('global.registerModule');
}
if (expectWarnings) {
expect(actualWarnings.length).toEqual(expectWarnings);
}
if (expectWarnings) {
expect(actualWarnings.length).toEqual(expectWarnings);
}
if (error && !expectError) {
done.fail(error);
} else if (!error && expectError) {
done.fail('Error expected here');
} else {
done();
}
if (error && !expectError) {
throw error;
} else if (!error && expectError) {
throw new Error('Error expected here');
} else {
done();
}
};
},
resolve: (
context: string,
@@ -272,10 +274,13 @@ describe('xml-namespace-loader', () => {
const expectedDeps = [];
const expectedRegs = [
{ name: 'nativescript-ui-chart', path: 'nativescript-ui-chart' },
{
name: 'nativescript-ui-chart',
path: 'node_modules/nativescript-ui-chart/ui-chart.js',
},
{
name: 'nativescript-ui-chart/RadCartesianChart',
path: 'nativescript-ui-chart',
path: 'node_modules/nativescript-ui-chart/ui-chart.js',
},
];
@@ -392,25 +397,16 @@ describe('xml-namespace-loader', () => {
});
it("with '&&', '||', '<=' and '>=' in binding expression, emits warnings, but does not fail", (done) => {
const resolveMap = {
'nativescript-ui-chart': 'node_modules/nativescript-ui-chart/ui-chart.js',
};
const resolveMap = {};
const expectedDeps = [];
const expectedRegs = [
{ name: 'nativescript-ui-chart', path: 'nativescript-ui-chart' },
{
name: 'nativescript-ui-chart/RadCartesianChart',
path: 'nativescript-ui-chart',
},
];
const expectedRegs = [];
const testXml = `
<Page xmlns="http://www.nativescript.org/tns.xsd">
<StackLayout xmlns:chart="nativescript-ui-chart">
<TextField text="{{ var1 && var2 || var1 >= var2 || var2 <= var1 }}" />
<chart:RadCartesianChart></chart:RadCartesianChart>
</StackLayout>
</Page>`;

View File

@@ -1,6 +1,6 @@
{
"name": "@nativescript/webpack",
"version": "5.0.0",
"version": "5.0.2-alpha.1",
"private": false,
"main": "dist/index.js",
"files": [
@@ -18,7 +18,7 @@
},
"dependencies": {
"@babel/core": "^7.0.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.4.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.2",
"acorn": "^8.0.0",
"acorn-stage3": "^4.0.0",
"babel-loader": "^8.0.0",
@@ -39,7 +39,7 @@
"postcss-import": "^14.0.0",
"postcss-loader": "^6.0.0",
"raw-loader": "^4.0.0",
"react-refresh": "~0.8.3",
"react-refresh": "~0.11.0",
"sass": "^1.0.0",
"sass-loader": "^12.0.0",
"sax": "^1.0.0",

View File

@@ -0,0 +1,21 @@
{
"root": "packages/webpack5",
"sourceRoot": "packages/webpack5",
"projectType": "library",
"generators": {},
"targets": {
"lint": {
"executor": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": []
}
},
"build": {
"executor": "@nrwl/workspace:run-commands",
"outputs": ["dist/packages"],
"options": {
"command": "npx zx ./tools/scripts/pack-webpack5.mjs"
}
}
}
}

View File

@@ -1,5 +1,5 @@
import { ScriptTarget } from 'typescript';
import { extname, resolve } from 'path';
import { merge } from 'webpack-merge';
import Config from 'webpack-chain';
import { existsSync } from 'fs';
@@ -148,7 +148,9 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
if (!transformers.before) {
transformers.before = [];
}
transformers.before.push(require('../transformers/NativeClass').default);
transformers.before.unshift(
require('../transformers/NativeClass').default
);
args[1] = transformers;
return originalCreateFileEmitter.apply(this, args);
};
@@ -167,6 +169,23 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
.use('angular-hot-loader')
.loader('angular-hot-loader');
});
// zone + async/await
config.module
.rule('angular-webpack-loader')
.test(/\.[cm]?[tj]sx?$/)
.exclude.add(
/[/\\](?:core-js|@babel|tslib|web-animations-js|web-streams-polyfill)[/\\]/
)
.end()
.resolve.set('fullySpecified', false)
.end()
.before('angular')
.use('webpack-loader')
.loader('@angular-devkit/build-angular/src/babel/webpack-loader')
.options({
scriptTarget: ScriptTarget.ESNext,
aot: true,
});
}
// look for platform specific polyfills first
@@ -182,10 +201,8 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
// replace globals with the polyfills file which
// should handle loading the correct globals
// and any additional polyfills required.
if (paths.includes('@nativescript/core/globals/index.js')) {
paths[
paths.indexOf('@nativescript/core/globals/index.js')
] = polyfillsPath;
if (paths.includes('@nativescript/core/globals/index')) {
paths[paths.indexOf('@nativescript/core/globals/index')] = polyfillsPath;
// replace paths with the updated paths
config.entry('bundle').clear().merge(paths);

View File

@@ -1,3 +1,4 @@
import { extname, resolve } from 'path';
import {
ContextExclusionPlugin,
DefinePlugin,
@@ -5,7 +6,7 @@ import {
ProvidePlugin,
} from 'webpack';
import Config from 'webpack-chain';
import { resolve } from 'path';
import { existsSync } from 'fs';
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
@@ -87,8 +88,8 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
config
.entry('bundle')
// ensure we load nativescript globals first
.add('@nativescript/core/globals/index.js')
.add('@nativescript/core/bundle-entry-points.js')
.add('@nativescript/core/globals/index')
.add('@nativescript/core/bundle-entry-points')
.add(entryPath);
// Add android app components to the bundle to SBG can generate the java classes
@@ -127,6 +128,7 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
config.optimization.minimizer('TerserPlugin').use(TerserPlugin, [
{
terserOptions: {
// @ts-ignore - https://github.com/webpack-contrib/terser-webpack-plugin/pull/463 broke the types?
compress: {
collapse_vars: platform !== 'android',
sequences: platform !== 'android',
@@ -199,12 +201,24 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
.options({
platform,
})
.end()
.use('nativescript-hot-loader')
.loader('nativescript-hot-loader')
.options({
injectHMRRuntime: true,
});
.end();
config.when(env.hmr, (config) => {
config.module
.rule('bundle')
.use('nativescript-hot-loader')
.loader('nativescript-hot-loader')
.options({
injectHMRRuntime: true,
});
});
// worker-loader should be declared before ts-loader
config.module
.rule('workers')
.test(/\.(js|ts)$/)
.use('nativescript-worker-loader')
.loader('nativescript-worker-loader');
// set up ts support
config.module
@@ -250,12 +264,6 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
.exclude.add(/node_modules/)
.end();
config.module
.rule('workers')
.test(/\.(js|ts)$/)
.use('nativescript-worker-loader')
.loader('nativescript-worker-loader');
// config.resolve.extensions.add('.xml');
// set up xml
config.module
@@ -271,7 +279,36 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
postcssOptions: {
plugins: [
// inlines @imported stylesheets
'postcss-import',
[
'postcss-import',
{
// custom resolver to resolve platform extensions in @import statements
// ie. @import "foo.css" would import "foo.ios.css" if the platform is ios and it exists
resolve(id, baseDir, importOptions) {
const ext = extname(id);
const platformExt = ext ? `.${platform}${ext}` : '';
if (!id.includes(platformExt)) {
const platformRequest = id.replace(ext, platformExt);
const extPath = resolve(baseDir, platformRequest);
try {
return require.resolve(platformRequest, {
paths: [baseDir],
});
} catch {}
if (existsSync(extPath)) {
console.log(`resolving "${id}" to "${platformRequest}"`);
return extPath;
}
}
// fallback to postcss-import default resolution
return id;
},
},
],
],
},
};

View File

@@ -30,22 +30,25 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
chainedSetAddAfter(
config.entry('bundle'),
'@nativescript/core/globals/index.js',
'@nativescript/core/globals/index',
virtualEntryPath
);
// set up core HMR
config.module
.rule('hmr-core')
.test(/\.js$/)
.exclude.add(/node_modules/)
.add(entryPath)
.end()
.use('nativescript-hot-loader')
.loader('nativescript-hot-loader')
.options({
appPath: getEntryDirPath(),
});
config.when(env.hmr, (config) => {
// set up core HMR
config.module
.rule('hmr-core')
.before('js')
.test(/\.js$/)
.exclude.add(/node_modules/)
.add(entryPath)
.end()
.use('nativescript-hot-loader')
.loader('nativescript-hot-loader')
.options({
appPath: getEntryDirPath(),
});
});
return config;
}

View File

@@ -30,22 +30,25 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
chainedSetAddAfter(
config.entry('bundle'),
'@nativescript/core/globals/index.js',
'@nativescript/core/globals/index',
virtualEntryPath
);
// set up core HMR
config.module
.rule('hmr-core')
.test(/\.(js|ts)$/)
.exclude.add(/node_modules/)
.add(entryPath)
.end()
.use('nativescript-hot-loader')
.loader('nativescript-hot-loader')
.options({
appPath: getEntryDirPath(),
});
config.when(env.hmr, (config) => {
// set up core HMR
config.module
.rule('hmr-core')
.before('ts')
.test(/\.(js|ts)$/)
.exclude.add(/node_modules/)
.add(entryPath)
.end()
.use('nativescript-hot-loader')
.loader('nativescript-hot-loader')
.options({
appPath: getEntryDirPath(),
});
});
return config;
}

View File

@@ -78,6 +78,10 @@ async function parseXML(content: string): Promise<ParseResult> {
`${localModulePath}.xml`,
moduleName,
namespace,
`${moduleName}.xml`,
`~/${moduleName}`,
`~/${namespace}`,
`~/${moduleName}.xml`,
];
DEBUG && console.log({ resolvePaths });
let resolvedPath;
@@ -118,12 +122,13 @@ async function parseXML(content: string): Promise<ParseResult> {
this.addDependency(xml);
namespaces.push({ name: `${moduleName}.xml`, path: xml });
})
.catch(() => {
// if there is no XML file, fall back to namespace as the path
// will become require(<namespace>)
namespaces.push({ name: namespace, path: namespace });
namespaces.push({ name: moduleName, path: namespace });
});
.catch(noop);
// .catch(() => {
// // if there is no XML file, fall back to namespace as the path
// // will become require(<namespace>)
// namespaces.push({ name: namespace, path: namespace });
// namespaces.push({ name: moduleName, path: namespace });
// });
// look for css files with the same name
await resolveAsync(this.context, `${noExtFilename}.css`)
@@ -163,6 +168,8 @@ async function parseXML(content: string): Promise<ParseResult> {
distinctNamespaces.set(name, path.replace(/\\/g, '/'));
});
DEBUG && console.log({ distinctNamespaces });
distinctNamespaces.forEach((path, name) => {
moduleRegisters.push(dedent`
global.registerModule(