From 7f069a7093087a060274e59f53f68db879846b3e Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Tue, 8 Nov 2022 15:18:10 -0800 Subject: [PATCH] feat: TypeScript 4.8+ support and NativeClass decorator improvements (#10081) --- apps/automated/package.json | 2 +- apps/automated/project.json | 1 + .../src/ui/styling/style-properties-tests.ts | 2 +- apps/toolbox/package.json | 2 +- apps/toolbox/project.json | 1 + apps/ui/package.json | 2 +- apps/ui/project.json | 1 + nx.json | 22 +++++++---- package.json | 24 ++++++------ packages/core/project.json | 11 +++--- packages/core/ui/styling/font.d.ts | 22 +++++------ packages/core/ui/styling/style-properties.ts | 5 ++- packages/core/ui/styling/style/index.ts | 6 +-- .../core/ui/text-base/formatted-string.ts | 10 ++--- packages/core/ui/text-base/span.ts | 10 ++--- packages/types-android/project.json | 37 ++++++++----------- packages/types-ios/project.json | 37 ++++++++----------- packages/types-minimal/project.json | 37 ++++++++----------- packages/types/project.json | 5 ++- packages/ui-mobile-base/project.json | 32 ++++++++-------- packages/webpack5/package.json | 2 +- packages/webpack5/project.json | 5 ++- .../src/transformers/NativeClass/index.ts | 11 +++--- tools/scripts/project.json | 5 ++- 24 files changed, 143 insertions(+), 149 deletions(-) diff --git a/apps/automated/package.json b/apps/automated/package.json index fcdecff89..7c22fd46e 100644 --- a/apps/automated/package.json +++ b/apps/automated/package.json @@ -14,7 +14,7 @@ "@nativescript/android": "~8.3.0", "@nativescript/ios": "~8.3.0", "@nativescript/webpack": "file:../../dist/packages/nativescript-webpack.tgz", - "typescript": "4.7.3" + "typescript": "4.8.4" }, "gitHead": "c06800e52ee1a184ea2dffd12a6702aaa43be4e3", "readme": "NativeScript Application" diff --git a/apps/automated/project.json b/apps/automated/project.json index 514cc7d26..057ff4fd3 100644 --- a/apps/automated/project.json +++ b/apps/automated/project.json @@ -1,4 +1,5 @@ { + "name": "apps-automated", "$schema": "../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "apps/automated/app", "projectType": "application", diff --git a/apps/automated/src/ui/styling/style-properties-tests.ts b/apps/automated/src/ui/styling/style-properties-tests.ts index b46625903..2f8632276 100644 --- a/apps/automated/src/ui/styling/style-properties-tests.ts +++ b/apps/automated/src/ui/styling/style-properties-tests.ts @@ -556,7 +556,7 @@ export function test_setting_font_shorthand_property() { test_font_shorthand_property('normal normal normal 15px/30px Arial', 'Arial', 15, 'normal', 'normal'); } -function test_font_shorthand_property(short: string, family: string, size: number, style: string, weight: string) { +function test_font_shorthand_property(short: string, family: string, size: number, style: string, weight: string | number) { const testView = new Button(); (testView.style)['font'] = short; diff --git a/apps/toolbox/package.json b/apps/toolbox/package.json index c55efa293..88fd27c87 100644 --- a/apps/toolbox/package.json +++ b/apps/toolbox/package.json @@ -15,6 +15,6 @@ "@nativescript/android": "~8.3.0", "@nativescript/ios": "~8.3.0", "@nativescript/webpack": "file:../../dist/packages/nativescript-webpack.tgz", - "typescript": "4.7.3" + "typescript": "4.8.4" } } diff --git a/apps/toolbox/project.json b/apps/toolbox/project.json index cc7c1e29e..2bd2ce7a6 100644 --- a/apps/toolbox/project.json +++ b/apps/toolbox/project.json @@ -1,4 +1,5 @@ { + "name": "apps-toolbox", "$schema": "../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "apps/toolbox/src", "projectType": "application", diff --git a/apps/ui/package.json b/apps/ui/package.json index cc657ba98..2790dc201 100644 --- a/apps/ui/package.json +++ b/apps/ui/package.json @@ -14,7 +14,7 @@ "@nativescript/android": "~8.3.0", "@nativescript/ios": "~8.3.0", "@nativescript/webpack": "file:../../dist/packages/nativescript-webpack.tgz", - "typescript": "4.7.3" + "typescript": "4.8.4" }, "gitHead": "8ab7726d1ee9991706069c1359c552e67ee0d1a4", "readme": "NativeScript Application", diff --git a/apps/ui/project.json b/apps/ui/project.json index 1c69b84d3..1558e473b 100644 --- a/apps/ui/project.json +++ b/apps/ui/project.json @@ -1,4 +1,5 @@ { + "name": "apps-ui", "$schema": "../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "apps/ui/src", "projectType": "application", diff --git a/nx.json b/nx.json index fd44f6a26..06c3a4a86 100644 --- a/nx.json +++ b/nx.json @@ -4,13 +4,6 @@ "appsDir": "apps", "libsDir": "packages" }, - "implicitDependencies": { - "workspace.json": "*", - "tsconfig.json": "*", - "tslint.json": "*", - "nx.json": "*", - ".eslintrc.json": "*" - }, "tasksRunnerOptions": { "default": { "runner": "nx/tasks-runners/default", @@ -82,5 +75,18 @@ "affected": { "defaultBase": "master" }, - "$schema": "./node_modules/nx/schemas/nx-schema.json" + "$schema": "./node_modules/nx/schemas/nx-schema.json", + "namedInputs": { + "default": ["{projectRoot}/**/*", "sharedGlobals"], + "sharedGlobals": ["{workspaceRoot}/workspace.json", "{workspaceRoot}/tsconfig.json", "{workspaceRoot}/tslint.json", "{workspaceRoot}/nx.json"], + "production": ["default", "!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)", "!{projectRoot}/tsconfig.spec.json", "!{projectRoot}/jest.config.[jt]s"] + }, + "targetDefaults": { + "build": { + "inputs": ["production", "^production"] + }, + "test": { + "inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"] + } + } } diff --git a/package.json b/package.json index ff509d018..6885c18f8 100644 --- a/package.json +++ b/package.json @@ -23,18 +23,18 @@ "devDependencies": { "@nativescript/hook": "^2.0.0", "@nativescript/nx": "~4.0.0", - "@nrwl/cli": "14.5.4", - "@nrwl/eslint-plugin-nx": "14.5.4", - "@nrwl/jest": "14.5.4", - "@nrwl/node": "14.5.4", - "@nrwl/workspace": "14.5.4", + "@nrwl/cli": "15.0.12", + "@nrwl/eslint-plugin-nx": "15.0.12", + "@nrwl/jest": "15.0.12", + "@nrwl/node": "15.0.12", + "@nrwl/workspace": "15.0.12", "@nstudio/focus": "^14.3.0", "@nstudio/nps-i": "~2.0.0", "@prettier/plugin-xml": "^2.2.0", "@types/chai": "^4.2.11", - "@types/jest": "27.4.1", + "@types/jest": "28.1.8", "@types/mocha": "^7.0.2", - "@types/node": "18.0.0", + "@types/node": "18.7.1", "@typescript-eslint/eslint-plugin": "^5.30.0", "@typescript-eslint/parser": "^5.30.0", "chai": "^4.2.0", @@ -47,7 +47,7 @@ "eslint-config-prettier": "^8.1.0", "gonzales": "^1.0.7", "husky": "^8.0.1", - "jest": "27.5.1", + "jest": "28.1.3", "lint-staged": "^13.0.1", "mocha": "^8.0.1", "mocha-typescript": "^1.1.17", @@ -61,15 +61,15 @@ "sass": "^1.45.2", "shady-css-parser": "^0.1.0", "tree-kill": "^1.2.2", - "ts-jest": "27.1.4", - "ts-node": "10.8.1", + "ts-jest": "28.0.8", + "ts-node": "10.9.1", "ts-patch": "^2.0.1", "tslint": "6.1.3", "tslint-to-eslint-config": "^2.13.0", "typedoc": "^0.22.17", - "typescript": "~4.7.3", + "typescript": "4.8.4", "zx": "^7.0.5", - "nx": "14.5.4" + "nx": "15.0.12" }, "lint-staged": { "**/*": [ diff --git a/packages/core/project.json b/packages/core/project.json index 7450fa30d..0bf1e28d1 100644 --- a/packages/core/project.json +++ b/packages/core/project.json @@ -1,4 +1,5 @@ { + "name": "core", "$schema": "../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/core", "projectType": "library", @@ -16,11 +17,11 @@ "jestConfig": "packages/core/jest.config.ts", "passWithNoTests": true }, - "outputs": ["coverage/packages/core"] + "outputs": ["{workspaceRoot}/coverage/packages/core"] }, "build": { - "executor": "@nrwl/workspace:run-commands", - "outputs": ["dist/packages"], + "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/dist/packages"], "options": { "commands": [ "npx rimraf dist/packages/core", @@ -34,7 +35,7 @@ } }, "unit": { - "executor": "@nrwl/workspace:run-commands", + "executor": "nx:run-commands", "options": { "commands": ["../../../node_modules/.bin/tsc -p tsconfig.json && ../../../node_modules/.bin/mocha --config=.mocharc.yml"], "cwd": "packages/core/__tests__", @@ -42,7 +43,7 @@ } }, "unit.watch": { - "executor": "@nrwl/workspace:run-commands", + "executor": "nx:run-commands", "options": { "commands": ["../../../node_modules/.bin/tsc -p tsconfig.json && ../../../node_modules/.bin/mocha --watch --config=.mocharc.yml"], "cwd": "packages/core/__tests__", diff --git a/packages/core/ui/styling/font.d.ts b/packages/core/ui/styling/font.d.ts index f67607759..d09716371 100644 --- a/packages/core/ui/styling/font.d.ts +++ b/packages/core/ui/styling/font.d.ts @@ -2,37 +2,37 @@ public static default: Font; public fontFamily: string; - public fontStyle: FontStyle; - public fontWeight: FontWeight; + public fontStyle: FontStyleType; + public fontWeight: FontWeightType; public fontSize: number; public fontScale: number; public isBold: boolean; public isItalic: boolean; - constructor(family: string, size: number, style?: FontStyle, weight?: FontWeight, scale?: number); + constructor(family: string, size: number, style?: FontStyleType, weight?: FontWeightType, scale?: number); public getAndroidTypeface(): any /* android.graphics.Typeface */; public getUIFont(defaultFont: any /* UIFont */): any /* UIFont */; public withFontFamily(family: string): Font; - public withFontStyle(style: FontStyle): Font; - public withFontWeight(weight: FontWeight): Font; + public withFontStyle(style: FontStyleType): Font; + public withFontWeight(weight: FontWeightType): Font; public withFontSize(size: number): Font; public withFontScale(scale: number): Font; public static equals(value1: Font, value2: Font): boolean; } -export type FontStyle = 'normal' | 'italic'; +export type FontStyleType = 'normal' | 'italic'; export namespace FontStyle { export const NORMAL: 'normal'; export const ITALIC: 'italic'; export function isValid(value: any): boolean; - export function parse(value: string): FontStyle; + export function parse(value: string): FontStyleType; } -export type FontWeight = '100' | '200' | '300' | 'normal' | '400' | '500' | '600' | 'bold' | '700' | '800' | '900' | number; +export type FontWeightType = '100' | '200' | '300' | 'normal' | '400' | '500' | '600' | 'bold' | '700' | '800' | '900' | number; export namespace FontWeight { export const THIN: '100'; export const EXTRA_LIGHT: '200'; @@ -44,13 +44,13 @@ export namespace FontWeight { export const EXTRA_BOLD: '800'; export const BLACK: '900'; export function isValid(value: any): boolean; - export function parse(value: string): FontWeight; + export function parse(value: string): FontWeightType; } export interface ParsedFont { - fontStyle?: FontStyle; + fontStyle?: FontStyleType; fontVariant?: string; - fontWeight?: FontWeight; + fontWeight?: FontWeightType; lineHeight?: string; fontSize?: string; fontFamily?: string; diff --git a/packages/core/ui/styling/style-properties.ts b/packages/core/ui/styling/style-properties.ts index f4704b64a..d24a5d5f5 100644 --- a/packages/core/ui/styling/style-properties.ts +++ b/packages/core/ui/styling/style-properties.ts @@ -17,6 +17,7 @@ import { CoreTypes } from '../../core-types'; import { parseBackground } from '../../css/parser'; import { LinearGradient } from './linear-gradient'; import { CSSShadow, parseCSSShadow } from './css-shadow'; +import { FontStyleType, FontWeightType } from './font-common'; function equalsCommon(a: CoreTypes.LengthType, b: CoreTypes.LengthType): boolean; function equalsCommon(a: CoreTypes.PercentLengthType, b: CoreTypes.PercentLengthType): boolean; @@ -1362,7 +1363,7 @@ export const fontSizeProperty = new InheritedCssProperty({ }); fontSizeProperty.register(Style); -export const fontStyleProperty = new InheritedCssProperty({ +export const fontStyleProperty = new InheritedCssProperty({ name: 'fontStyle', cssName: 'font-style', affectsLayout: global.isIOS, @@ -1378,7 +1379,7 @@ export const fontStyleProperty = new InheritedCssProperty({ }); fontStyleProperty.register(Style); -export const fontWeightProperty = new InheritedCssProperty({ +export const fontWeightProperty = new InheritedCssProperty({ name: 'fontWeight', cssName: 'font-weight', affectsLayout: global.isIOS, diff --git a/packages/core/ui/styling/style/index.ts b/packages/core/ui/styling/style/index.ts index 0bcfa54ef..dfeae2ea5 100644 --- a/packages/core/ui/styling/style/index.ts +++ b/packages/core/ui/styling/style/index.ts @@ -1,6 +1,6 @@ import { Style as StyleDefinition } from '.'; import { Color } from '../../../color'; -import { Font, FontStyle, FontWeight } from '../font'; +import { Font, FontStyleType, FontWeightType } from '../font'; import { Background } from '../background'; import { ViewBase } from '../../core/view-base'; import { LinearGradient } from '../../styling/linear-gradient'; @@ -150,8 +150,8 @@ export class Style extends Observable implements StyleDefinition { public fontSize: number; public fontFamily: string; - public fontStyle: FontStyle; - public fontWeight: FontWeight; + public fontStyle: FontStyleType; + public fontWeight: FontWeightType; public font: string; public maxLines: CoreTypes.MaxLinesType; diff --git a/packages/core/ui/text-base/formatted-string.ts b/packages/core/ui/text-base/formatted-string.ts index 7bbb34aab..fdb243b47 100644 --- a/packages/core/ui/text-base/formatted-string.ts +++ b/packages/core/ui/text-base/formatted-string.ts @@ -5,7 +5,7 @@ import { ObservableArray, ChangedData } from '../../data/observable-array'; import { AddArrayFromBuilder, AddChildFromBuilder } from '../core/view'; import { ViewBase } from '../core/view-base'; import { Color } from '../../color'; -import { FontStyle, FontWeight } from '../styling/font'; +import { FontStyleType, FontWeightType } from '../styling/font'; import { CoreTypes } from '../../core-types'; export class FormattedString extends ViewBase implements FormattedStringDefinition, AddArrayFromBuilder, AddChildFromBuilder { @@ -31,17 +31,17 @@ export class FormattedString extends ViewBase implements FormattedStringDefiniti this.style.fontSize = value; } - get fontStyle(): FontStyle { + get fontStyle(): FontStyleType { return this.style.fontStyle; } - set fontStyle(value: FontStyle) { + set fontStyle(value: FontStyleType) { this.style.fontStyle = value; } - get fontWeight(): FontWeight { + get fontWeight(): FontWeightType { return this.style.fontWeight; } - set fontWeight(value: FontWeight) { + set fontWeight(value: FontWeightType) { this.style.fontWeight = value; } diff --git a/packages/core/ui/text-base/span.ts b/packages/core/ui/text-base/span.ts index fed0202ff..84bbfe7ae 100644 --- a/packages/core/ui/text-base/span.ts +++ b/packages/core/ui/text-base/span.ts @@ -1,7 +1,7 @@ import { Color } from '../../color'; import { Span as SpanDefinition } from './span'; import { ViewBase } from '../core/view-base'; -import { FontStyle, FontWeight } from '../styling/font'; +import { FontStyleType, FontWeightType } from '../styling/font'; import { CoreTypes } from '../../core-types'; import { EventData } from '../../data/observable'; import { isNullOrUndefined, isString } from '../../utils/types'; @@ -26,18 +26,18 @@ export class Span extends ViewBase implements SpanDefinition { } // Italic - get fontStyle(): FontStyle { + get fontStyle(): FontStyleType { return this.style.fontStyle; } - set fontStyle(value: FontStyle) { + set fontStyle(value: FontStyleType) { this.style.fontStyle = value; } // Bold - get fontWeight(): FontWeight { + get fontWeight(): FontWeightType { return this.style.fontWeight; } - set fontWeight(value: FontWeight) { + set fontWeight(value: FontWeightType) { this.style.fontWeight = value; } diff --git a/packages/types-android/project.json b/packages/types-android/project.json index fce4dd0ad..75684e622 100644 --- a/packages/types-android/project.json +++ b/packages/types-android/project.json @@ -1,23 +1,18 @@ { - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "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 - } - } - } + "name": "types-android", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "packages/types-android/src", + "projectType": "library", + "generators": {}, + "targets": { + "build": { + "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/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 + } + } + } } diff --git a/packages/types-ios/project.json b/packages/types-ios/project.json index 4804cb274..23437e8d8 100644 --- a/packages/types-ios/project.json +++ b/packages/types-ios/project.json @@ -1,24 +1,17 @@ { - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "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 - } - } - } + "name": "types-ios", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "packages/types-ios/src", + "projectType": "library", + "generators": {}, + "targets": { + "build": { + "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/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 + } + } + } } diff --git a/packages/types-minimal/project.json b/packages/types-minimal/project.json index 656bf9099..786ef6a6a 100644 --- a/packages/types-minimal/project.json +++ b/packages/types-minimal/project.json @@ -1,24 +1,17 @@ { - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "packages/types-minimal/src", - "projectType": "library", - "generators": {}, - "targets": { - "build": { - "executor": "@nrwl/workspace:run-commands", - "outputs": [ - "dist/packages" - ], - "options": { - "commands": [ - "./tools/scripts/typings-minimal-copy.sh", - "mkdir -p dist/packages/types-minimal", - "cp -R packages/types-minimal/src/* dist/packages/types-minimal", - "cp packages/types-minimal/package.json dist/packages/types-minimal", - "cp packages/types-minimal/README.md dist/packages/types-minimal/README.md" - ], - "parallel": false - } - } - } + "name": "types-minimal", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "packages/types-minimal/src", + "projectType": "library", + "generators": {}, + "targets": { + "build": { + "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/dist/packages"], + "options": { + "commands": ["./tools/scripts/typings-minimal-copy.sh", "mkdir -p dist/packages/types-minimal", "cp -R packages/types-minimal/src/* dist/packages/types-minimal", "cp packages/types-minimal/package.json dist/packages/types-minimal", "cp packages/types-minimal/README.md dist/packages/types-minimal/README.md"], + "parallel": false + } + } + } } diff --git a/packages/types/project.json b/packages/types/project.json index 59a260e02..3df0ca9ed 100644 --- a/packages/types/project.json +++ b/packages/types/project.json @@ -1,12 +1,13 @@ { + "name": "types", "$schema": "../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/types", "projectType": "library", "generators": {}, "targets": { "build": { - "executor": "@nrwl/workspace:run-commands", - "outputs": ["dist/packages"], + "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/dist/packages"], "options": { "commands": ["mkdir -p ../../dist/packages/types", "cp -R * ../../dist/packages/types"], "cwd": "packages/types", diff --git a/packages/ui-mobile-base/project.json b/packages/ui-mobile-base/project.json index db69e70f7..256b8d0cc 100644 --- a/packages/ui-mobile-base/project.json +++ b/packages/ui-mobile-base/project.json @@ -1,19 +1,17 @@ { - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "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 - } - } - } + "name": "ui-mobile-base", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "packages/ui-mobile-base", + "projectType": "library", + "generators": {}, + "targets": { + "build": { + "executor": "nx:run-commands", + "options": { + "commands": ["./build.sh", "cp -R dist/package/platforms/* ../../packages/core/platforms"], + "cwd": "packages/ui-mobile-base", + "parallel": false + } + } + } } diff --git a/packages/webpack5/package.json b/packages/webpack5/package.json index f4a24eaea..3a3f69515 100644 --- a/packages/webpack5/package.json +++ b/packages/webpack5/package.json @@ -67,7 +67,7 @@ "jest-matcher-utils": "29.1.2", "nativescript-vue-template-compiler": "2.9.3", "ts-jest": "29.0.3", - "typescript": "4.7.4" + "typescript": "4.8.4" }, "peerDependencies": { "nativescript-vue-template-compiler": "^2.8.1" diff --git a/packages/webpack5/project.json b/packages/webpack5/project.json index 11abcb5e9..789c0ceff 100644 --- a/packages/webpack5/project.json +++ b/packages/webpack5/project.json @@ -1,4 +1,5 @@ { + "name": "webpack5", "$schema": "../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "packages/webpack5", "projectType": "library", @@ -11,8 +12,8 @@ } }, "build": { - "executor": "@nrwl/workspace:run-commands", - "outputs": ["dist/packages"], + "executor": "nx:run-commands", + "outputs": ["{workspaceRoot}/dist/packages"], "options": { "command": "npx zx ./tools/scripts/pack-webpack5.mjs" } diff --git a/packages/webpack5/src/transformers/NativeClass/index.ts b/packages/webpack5/src/transformers/NativeClass/index.ts index 71b832c1c..1a8d19a3c 100644 --- a/packages/webpack5/src/transformers/NativeClass/index.ts +++ b/packages/webpack5/src/transformers/NativeClass/index.ts @@ -8,8 +8,9 @@ import ts from 'typescript'; export default function (ctx: ts.TransformationContext) { function isNativeClassExtension(node: ts.ClassDeclaration) { return ( - node.decorators && - node.decorators.filter((d) => { + ts.canHaveDecorators(node) && + ts.getDecorators(node) && + ts.getDecorators(node).filter((d) => { const fullText = d.getFullText().trim(); return fullText.indexOf('@NativeClass') > -1; }).length > 0 @@ -24,14 +25,14 @@ export default function (ctx: ts.TransformationContext) { function createHelper(node: ts.Node) { // we remove the decorator for now! - return ts.createIdentifier( + return ts.factory.createIdentifier( ts .transpileModule( node.getText().replace(/@NativeClass(\((.|\n)*?\))?/gm, ''), { compilerOptions: { noEmitHelpers: true, - module: ts.ModuleKind.CommonJS, + module: ts.ModuleKind.ESNext, target: ts.ScriptTarget.ES5, }, } @@ -44,7 +45,7 @@ export default function (ctx: ts.TransformationContext) { } return (source: ts.SourceFile) => - ts.updateSourceFileNode( + ts.factory.updateSourceFile( source, ts.visitNodes(source.statements, visitNode) ); diff --git a/tools/scripts/project.json b/tools/scripts/project.json index c964b731a..bcbfadb9c 100644 --- a/tools/scripts/project.json +++ b/tools/scripts/project.json @@ -1,12 +1,13 @@ { + "name": "core-api-docs", "$schema": "../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "tools/scripts", "projectType": "library", "generators": {}, "targets": { "build": { - "executor": "@nrwl/workspace:run-commands", - "outputs": ["tools/scripts/dist"], + "executor": "nx:run-commands", + "outputs": ["{projectRoot}/dist"], "options": { "commands": ["./build-docs.sh"], "cwd": "tools/scripts",