diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 810b02be0..000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -name: Bug report -about: 'We really appreciate your effort to provide feedback. Before opening a new - issue, please make sure that this case is not already reported in GitHub as an - issue or in StackOverflow as a question.' - ---- - -**Environment** -Provide version numbers for the following components (information can be retrieved by running `tns info` in your project folder or by inspecting the `package.json` of the project): - - CLI: - - Cross-platform modules: - - Android Runtime: - - iOS Runtime: - - XCode Version: - - Plugin(s): - -**Describe the bug** - - -**To Reproduce** - - -**Expected behavior** - -**Sample project** - - -**Additional context** - diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml new file mode 100644 index 000000000..5b8192ca7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -0,0 +1,114 @@ +name: 🐞 Bug report +description: Create a bug report to help us improve NativeScript +labels: [bug-pending-triage] + +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to report an issue. + + > ## Important! :warning: + > + > The issue list is reserved exclusively for bug reports and feature requests. That means we do not accept usage questions. If you open an issue that does not conform to the requirements, it will be closed. + > + > For usage questions, please refer to the following resources: + > * Search the [docs](https://docs.nativescript.org/) + > * Search or ask in [Discord](https://nativescript.org/discord) + > * Search or ask in [Discussions](https://github.com/NativeScript/NativeScript/discussions) + > * Search or ask on [StackOverflow](https://stackoverflow.com/questions/tagged/nativescript) + > * Watch [video tutorials](https://nativescripting.com/) + + - type: textarea + validations: + required: true + attributes: + label: Issue Description + description: | + A clear and concise description of what the bug is. + Please, explain whether it's a build-time error or a runtime error. + + If you intend to submit a PR for this issue, tell us in the description. + placeholder: | + When I do , happens and I see the following error message: + + ``` + + ``` + + Expected behavior: + + When I do , should happen instead. + + - type: textarea + attributes: + label: Reproduction + description: | + Add commands used or steps taken to reproduce the behaviour. + Include links, references or anything else that will give us more context about the issue you are encountering. + placeholder: | + e.g: + https://github.com/NativeScript/Nativescript + + 1. clone, and run with `ns run ios` + 2. Click on '...' + 3. See error + + - type: textarea + attributes: + label: Relevant log output (if applicable) + description: | + Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + + Using the `--log trace` flag will usuall print more verbose logs that will help identify the issue quicker. + + When pasting verbose logs, please make sure you remove any sensitive information. + render: shell + + - type: textarea + attributes: + label: Environment + description: | + Provide information about your environment. Run + + ```shell + npx -y nativescript-envinfo + ``` + + inside the project and paste the output directly without manual formatting. + placeholder: | + Paste the result of + + npx -y nativescript-envinfo + + - type: markdown + attributes: + value: | + --- + + Before you submit this issue, please confirm the following: + + **1. Is there an existing issue for this?** + + Please search to see if an issue already exists for the bug you encountered or is not already reported on [StackOverflow](https://stackoverflow.com/questions/tagged/nativescript) as a question. + + **2. Confirm you are submitting a bug report** + + Please confirm you are submitting a bug report and not a usage question. + + **3. Code of Conduct** + + By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#coc) + + --- + - type: checkboxes + id: terms + attributes: + label: Please accept these terms + options: + - label: I have searched the [existing issues](https://github.com/NativeScript/NativeScript/issues) as well as [StackOverflow](https://stackoverflow.com/questions/tagged/nativescript) and this has not been posted before + required: true + - label: This is a bug report + required: true + - label: I agree to follow this project's [Code of Conduct](https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#coc) + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 000000000..7c53936a5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,14 @@ +blank_issues_enabled: false +contact_links: + - name: Search the Docs + url: https://docs.nativescript.org + about: Refer to the docs and search for what you are looking for. + - name: Search or ask in Discord + url: https://nativescript.org/discord + about: Ask questions and discuss with other NativeScript users in real-time. + - name: Search or ask in Discussions + url: https://github.com/NativeScript/NativeScript/discussions + about: Use GitHub discussions for message-board style questions and discussions. + - name: Search or ask on StackOverflow + url: https://stackoverflow.com/questions/tagged/nativescript + about: Use StackOverflow to look for answered questions that may be similar to yours. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 397090987..000000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project - ---- - -**Is your feature request related to a problem? Please describe.** - - -**Describe the solution you'd like** - - -**Describe alternatives you've considered** - - -**Additional context** - diff --git a/.github/ISSUE_TEMPLATE/feature_request.yaml b/.github/ISSUE_TEMPLATE/feature_request.yaml new file mode 100644 index 000000000..19c5528be --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yaml @@ -0,0 +1,71 @@ +name: 🚀 Feature request +description: Suggest an idea for NativeScript +labels: ["enhancement-pending-triage"] + +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to request a feature for NativeScript! + + > ## Important! :warning: + > + > The issue list is reserved exclusively for bug reports and feature requests. That means we do not accept usage questions. If you open an issue that does not conform to the requirements, it will be closed. + > + > For usage questions, please refer to the following resources: + > * Search the [docs](https://docs.nativescript.org/) + > * Search or ask in [Discord](https://nativescript.org/discord) + > * Search or ask in [Discussions](https://github.com/NativeScript/NativeScript/discussions) + > * Search or ask on [StackOverflow](https://stackoverflow.com/questions/tagged/nativescript) + > * Watch [video tutorials](https://nativescripting.com/) + + - type: textarea + attributes: + label: Is your feature request related to a problem? Please describe. + description: A clear and concise description of what the problem is. + placeholder: | + I wish I could use NativeScript to do [...] + or + I'm always frustrated when [...] + + - type: textarea + attributes: + label: Describe the solution you'd like + description: A clear and concise description of what you want to happen. + + - type: textarea + attributes: + label: Describe alternatives you've considered + description: A clear and concise description of any alternative solutions or features you've considered. + + - type: textarea + attributes: + label: Anything else? + description: Add any other context, code examples, or references to existing implementations about the feature request here. + + - type: markdown + attributes: + value: | + --- + + Before you submit this feature request, please confirm the following: + + **1. Is there an existing issue for this?** + + Please search to see if an issue related to this feature request already exists. + + **2. Code of Conduct** + + By submitting this feature request, you agree to follow our [Code of Conduct](https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#coc) + + --- + + - type: checkboxes + id: terms + attributes: + label: Please accept these terms + options: + - label: I have searched the [existing issues](https://github.com/NativeScript/NativeScript/issues) as well as [StackOverflow](https://stackoverflow.com/questions/tagged/nativescript) and this has not been posted before + required: true + - label: I agree to follow this project's [Code of Conduct](https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#coc) + required: true diff --git a/.gitignore b/.gitignore index 9143c0795..c29b090ad 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ **/package-lock.json **/yarn.lock **/pnpm-lock.yaml +.npmrc # IDEs and editors .idea diff --git a/CHANGELOG.md b/CHANGELOG.md index e6e70a7c7..89af4f691 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## [8.1.5](https://github.com/NativeScript/NativeScript/compare/8.1.4-core...8.1.5) (2021-10-28) + + +### Bug Fixes + +* **android:** autofillType on apiLevel < 26 ([#9610](https://github.com/NativeScript/NativeScript/issues/9610)) ([8878c3b](https://github.com/NativeScript/NativeScript/commit/8878c3bc6be5c061e95da74249998b51797d71d9)) +* **android:** version Android text-align justify ([#9620](https://github.com/NativeScript/NativeScript/issues/9620)) ([2ad280d](https://github.com/NativeScript/NativeScript/commit/2ad280deb0e9b6098d4ad76ccf703e257196a023)) + + + ## [8.1.4](https://github.com/NativeScript/NativeScript/compare/8.1.3-core...8.1.4) (2021-10-09) diff --git a/README.md b/README.md index e1de911ba..153f98b65 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ We love you and your PR's 🤗. Please follow our [contributing guide](https://g ## Other source repos -Outside of the source centralized in this repo, NativeScript consists of a few other source repos. Here are the major ones: +Outside the source centralized in this repo, NativeScript consists of a few other source repos. Here are the major ones: - **[iOS runtime](https://github.com/NativeScript/ns-v8ios-runtime)** - [![npm](https://img.shields.io/npm/dm/tns-ios.svg)](https://www.npmjs.com/package/@nativescript/ios) diff --git a/apps/automated/.gitignore b/apps/automated/.gitignore index a6a2bfdd5..512c68e15 100644 --- a/apps/automated/.gitignore +++ b/apps/automated/.gitignore @@ -1 +1 @@ -!webpack.custom.config.js +!webpack.config.js diff --git a/apps/automated/nativescript.config.ts b/apps/automated/nativescript.config.ts index e69de915a..043f59c66 100644 --- a/apps/automated/nativescript.config.ts +++ b/apps/automated/nativescript.config.ts @@ -2,10 +2,12 @@ import { NativeScriptConfig } from '@nativescript/core'; export default { id: 'org.nativescript.UnitTestApp', + appPath: 'src', appResourcesPath: '../../tools/assets/App_Resources', - webpackConfigPath: 'webpack.custom.config.js', android: { v8Flags: '--expose_gc', - markingMode: 'none', + }, + cli: { + packageManager: 'npm', }, } as NativeScriptConfig; diff --git a/apps/automated/package.json b/apps/automated/package.json index 2c270a37f..414312b7d 100644 --- a/apps/automated/package.json +++ b/apps/automated/package.json @@ -1,5 +1,5 @@ { - "main": "main.js", + "main": "src/main.ts", "description": "NativeScript Application", "license": "MIT", "repository": { diff --git a/apps/automated/project.json b/apps/automated/project.json new file mode 100644 index 000000000..85cca779e --- /dev/null +++ b/apps/automated/project.json @@ -0,0 +1,42 @@ +{ + "root": "apps/automated/", + "sourceRoot": "apps/automated/app", + "projectType": "application", + "prefix": "nativescript", + "targets": { + "build": { + "executor": "@nativescript/nx:build", + "options": { + "noHmr": true, + "production": true, + "uglify": true, + "release": true, + "forDevice": true + } + }, + "ios": { + "executor": "@nativescript/nx:build", + "options": { + "platform": "ios" + } + }, + "android": { + "executor": "@nativescript/nx:build", + "options": { + "platform": "android" + } + }, + "clean": { + "executor": "@nativescript/nx:build", + "options": { + "clean": true + } + }, + "lint": { + "executor": "@nrwl/linter:eslint", + "options": { + "lintFilePatterns": ["apps/automated/**/*.ts", "apps/automated/src/**/*.html"] + } + } + } +} diff --git a/apps/automated/src/app.css b/apps/automated/src/app.css deleted file mode 100644 index e69de29bb..000000000 diff --git a/apps/automated/src/http/http-string-worker.ts b/apps/automated/src/http/http-string-worker.ts index 629acf1d6..a45ebb62d 100644 --- a/apps/automated/src/http/http-string-worker.ts +++ b/apps/automated/src/http/http-string-worker.ts @@ -1,3 +1,8 @@ +// todo: figure out why this worker is including the whole core and not just the Http module +// ie. tree-shaking is not working as expected here. (same setup works in a separate app) +import { initGlobal } from '@nativescript/core/globals/index'; +initGlobal(); + import { Http } from '@nativescript/core'; declare var postMessage: any; diff --git a/apps/automated/src/http/http-tests.ts b/apps/automated/src/http/http-tests.ts index d60eafbf1..344c6fc25 100644 --- a/apps/automated/src/http/http-tests.ts +++ b/apps/automated/src/http/http-tests.ts @@ -689,15 +689,14 @@ export var test_request_jsonAsContentSentAndReceivedProperly = function (done) { }; export var test_getString_WorksProperlyInWorker = function (done) { - const HttpStringWorker = require('nativescript-worker-loader!./http-string-worker'); - let worker = new HttpStringWorker(); + const worker = new Worker('./http-string-worker'); console.log('Worker Created'); worker.onmessage = function (msg) { console.log('Message received'); done(); }; worker.onerror = function (e) { - console.log('error received'); + console.log('Error received'); done(e); }; }; diff --git a/apps/automated/src/name-resolvers-tests/files/other.xml b/apps/automated/src/name-resolvers-tests/files/other.xml index 07baef738..79919a7a8 100644 --- a/apps/automated/src/name-resolvers-tests/files/other.xml +++ b/apps/automated/src/name-resolvers-tests/files/other.xml @@ -1 +1 @@ -other.xml + diff --git a/apps/automated/src/name-resolvers-tests/files/test.land.xml b/apps/automated/src/name-resolvers-tests/files/test.land.xml index 0f2b16d84..b2a58d383 100644 --- a/apps/automated/src/name-resolvers-tests/files/test.land.xml +++ b/apps/automated/src/name-resolvers-tests/files/test.land.xml @@ -1 +1 @@ -test.minWH300.xml + diff --git a/apps/automated/src/name-resolvers-tests/files/test.minWH600.xml b/apps/automated/src/name-resolvers-tests/files/test.minWH600.xml index a4af10111..c8faaf81d 100644 --- a/apps/automated/src/name-resolvers-tests/files/test.minWH600.xml +++ b/apps/automated/src/name-resolvers-tests/files/test.minWH600.xml @@ -1 +1 @@ -test.monWH450.xml + diff --git a/apps/automated/src/name-resolvers-tests/files/test.xml b/apps/automated/src/name-resolvers-tests/files/test.xml index a6535f35d..492c17a0e 100644 --- a/apps/automated/src/name-resolvers-tests/files/test.xml +++ b/apps/automated/src/name-resolvers-tests/files/test.xml @@ -1 +1 @@ -test.xml + diff --git a/apps/automated/src/package.json b/apps/automated/src/package.json deleted file mode 100644 index a60376465..000000000 --- a/apps/automated/src/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "main": "main.js" -} \ No newline at end of file diff --git a/apps/automated/src/ui/button/button-tests.ts b/apps/automated/src/ui/button/button-tests.ts index 8745d14e7..a2a1f1eb8 100644 --- a/apps/automated/src/ui/button/button-tests.ts +++ b/apps/automated/src/ui/button/button-tests.ts @@ -65,15 +65,15 @@ export var testNativeBackgroundColorFromLocal = function () { helper.buildUIAndRunTest(_createButtonFunc(), _testNativeBackgroundColorFromLocal); }; -export var testMemoryLeak = function (done) { - helper.buildUIWithWeakRefAndInteract( - _createButtonFunc, - function (button) { - buttonTestsNative.performNativeClick(button); - }, - done - ); -}; +// export var testMemoryLeak = function (done) { +// helper.buildUIWithWeakRefAndInteract( +// _createButtonFunc, +// function (button) { +// buttonTestsNative.performNativeClick(button); +// }, +// done +// ); +// }; var _createButtonFunc = function (): Button { // >>button-create diff --git a/apps/automated/src/ui/core/bindable/bindable-tests.ts b/apps/automated/src/ui/core/bindable/bindable-tests.ts index 8e67984a1..10e6b6edb 100644 --- a/apps/automated/src/ui/core/bindable/bindable-tests.ts +++ b/apps/automated/src/ui/core/bindable/bindable-tests.ts @@ -191,60 +191,63 @@ export function test_bindingContext_Change_IsReflected_Properly() { helper.do_PageTest_WithButton(test); } -export function test_WhenBindingIsSetToAnElement_AndElementIsRemoved_ShouldBeCollectedByGC(done) { - let testFinished = false; +// disabled test because in latest v8 engine we rely on built-in WeakRef implementation +// which does not guarantee releasing objects after a GC call. - let page = helper.getCurrentPage(); - let stack = new StackLayout(); +// export function test_WhenBindingIsSetToAnElement_AndElementIsRemoved_ShouldBeCollectedByGC(done) { +// let testFinished = false; - let expectedValue = 'testValue'; - let sourcePropertyName = 'testProperty'; - let targetPropertyName = 'text'; +// let page = helper.getCurrentPage(); +// let stack = new StackLayout(); - stack.on(View.loadedEvent, () => { - const model = new Observable(); - model.set(sourcePropertyName, expectedValue); +// let expectedValue = 'testValue'; +// let sourcePropertyName = 'testProperty'; +// let targetPropertyName = 'text'; - function createButton(bindContext) { - let button = new Button(); - button.bind( - { - sourceProperty: sourcePropertyName, - targetProperty: targetPropertyName, - }, - bindContext - ); +// stack.on(View.loadedEvent, () => { +// const model = new Observable(); +// model.set(sourcePropertyName, expectedValue); - return new WeakRef(button); - } +// function createButton(bindContext) { +// let button = new Button(); +// button.bind( +// { +// sourceProperty: sourcePropertyName, +// targetProperty: targetPropertyName, +// }, +// bindContext +// ); - const weakRef = createButton(model); +// return new WeakRef(button); +// } - try { - stack.addChild(weakRef.get()); - TKUnit.waitUntilReady(() => weakRef.get().isLoaded); +// const weakRef = createButton(model); - TKUnit.assertEqual(weakRef.get().text, expectedValue, 'Binding is not working properly!'); - stack.removeChild(weakRef.get()); - TKUnit.waitUntilReady(() => !weakRef.get().isLoaded); +// try { +// stack.addChild(weakRef.get()); +// TKUnit.waitUntilReady(() => weakRef.get().isLoaded); - utils.GC(); - // Give time for the GC to kick in - setTimeout(() => { - utils.GC(); - TKUnit.assert(!weakRef.get(), 'UIElement is still alive!'); - testFinished = true; - }, 100); - } catch (e) { - done(e); - } - }); +// TKUnit.assertEqual(weakRef.get().text, expectedValue, 'Binding is not working properly!'); +// stack.removeChild(weakRef.get()); +// TKUnit.waitUntilReady(() => !weakRef.get().isLoaded); - page.content = stack; +// utils.GC(); +// // Give time for the GC to kick in +// setTimeout(() => { +// utils.GC(); +// TKUnit.assert(!weakRef.get(), 'UIElement is still alive!'); +// testFinished = true; +// }, 100); +// } catch (e) { +// done(e); +// } +// }); - TKUnit.waitUntilReady(() => testFinished); - done(null); -} +// page.content = stack; + +// TKUnit.waitUntilReady(() => testFinished); +// done(null); +// } export function test_OneBindableToBindMoreThanOneProperty_ToSameSource() { const model = new Observable(); diff --git a/apps/automated/src/ui/core/weak-event-listener/weak-event-listener-tests.ts b/apps/automated/src/ui/core/weak-event-listener/weak-event-listener-tests.ts index 9edb26b7e..d535584d0 100644 --- a/apps/automated/src/ui/core/weak-event-listener/weak-event-listener-tests.ts +++ b/apps/automated/src/ui/core/weak-event-listener/weak-event-listener-tests.ts @@ -93,43 +93,47 @@ function getTargetAsWeakRef(): WeakRef { return new WeakRef(new Target()); } -export function test_listenerDoesNotRetainTarget(done) { - const sourceRef = getSourceAsWeakRef(); - const targetRef = getTargetAsWeakRef(); +// commented out tests because the latest v8 runtime uses the built-in WeakRef implementation +// which does not guarantee releases after a GC call - it uses heuristics to determine when +// a WeakRef should be released - so we don't really need to test this. - // with the v8 6.5 the GC does not release WeakRefs so fast if you pass them to a method - // that's why we are making the call to the addWeakEventListener in a closure so that the WeakRef will be easier released - (function () { - addWeakEventListener(sourceRef.get(), Observable.propertyChangeEvent, emptyHandler, targetRef.get()); - })(); - forceGC(); +// export function test_listenerDoesNotRetainTarget(done) { +// const sourceRef = getSourceAsWeakRef(); +// const targetRef = getTargetAsWeakRef(); - try { - TKUnit.assert(!targetRef.get(), 'Target should be released after GC'); - done(null); - } catch (e) { - done(e); - } -} +// // with the v8 6.5 the GC does not release WeakRefs so fast if you pass them to a method +// // that's why we are making the call to the addWeakEventListener in a closure so that the WeakRef will be easier released +// (function () { +// addWeakEventListener(sourceRef.get(), Observable.propertyChangeEvent, emptyHandler, targetRef.get()); +// })(); +// forceGC(); -export function test_listenerDoesNotRetainSource(done) { - const sourceRef = getSourceAsWeakRef(); - const targetRef = getTargetAsWeakRef(); +// try { +// TKUnit.assert(!targetRef.get(), 'Target should be released after GC'); +// done(null); +// } catch (e) { +// done(e); +// } +// } - // with the v8 6.5 the GC does not release WeakRefs so fast if you pass them to a method - // that's why we are making the call to the addWeakEventListener in a closure so that the WeakRef will be easier released - (function () { - addWeakEventListener(sourceRef.get(), Observable.propertyChangeEvent, targetRef.get().onEvent, targetRef.get()); - })(); - forceGC(); +// export function test_listenerDoesNotRetainSource(done) { +// const sourceRef = getSourceAsWeakRef(); +// const targetRef = getTargetAsWeakRef(); - try { - TKUnit.assert(!sourceRef.get(), 'Source should be released after GC'); - done(null); - } catch (e) { - done(e); - } -} +// // with the v8 6.5 the GC does not release WeakRefs so fast if you pass them to a method +// // that's why we are making the call to the addWeakEventListener in a closure so that the WeakRef will be easier released +// (function () { +// addWeakEventListener(sourceRef.get(), Observable.propertyChangeEvent, targetRef.get().onEvent, targetRef.get()); +// })(); +// forceGC(); + +// try { +// TKUnit.assert(!sourceRef.get(), 'Source should be released after GC'); +// done(null); +// } catch (e) { +// done(e); +// } +// } export function test_handlerIsDetached_WhenAllListenersAreRemoved() { const source = new Observable(); diff --git a/apps/automated/src/ui/label/label-tests-wrong-page.css b/apps/automated/src/ui/label/label-tests-wrong-page.css index 1b71ea07c..860a586f4 100644 --- a/apps/automated/src/ui/label/label-tests-wrong-page.css +++ b/apps/automated/src/ui/label/label-tests-wrong-page.css @@ -1,3 +1,3 @@ -label { +/* label { < !--Test wrong comment-->background-color: red; -} +} */ diff --git a/apps/automated/src/ui/label/label-tests.ts b/apps/automated/src/ui/label/label-tests.ts index a9b28d871..3ad6bafea 100644 --- a/apps/automated/src/ui/label/label-tests.ts +++ b/apps/automated/src/ui/label/label-tests.ts @@ -545,15 +545,15 @@ export class LabelTest extends testModule.UITest { TKUnit.assertEqual(actualResult, this.expectedTextAlignment); } - public testErrorMessageWhenWrongCssIsAddedWithFile() { - const view = this.testView; - const page = this.testPage; - this.waitUntilTestElementIsLoaded(); + // public testErrorMessageWhenWrongCssIsAddedWithFile() { + // const view = this.testView; + // const page = this.testPage; + // this.waitUntilTestElementIsLoaded(); - view.id = 'testLabel'; - page.addCssFile(fs.path.join(testDir, 'label-tests-wrong-page.css')); - TKUnit.assertNotEqual(this.errorMessage, undefined); - } + // view.id = 'testLabel'; + // page.addCssFile(fs.path.join(testDir, 'label-tests-wrong-page.css')); + // TKUnit.assertNotEqual(this.errorMessage, undefined); + // } // public testErrorMessageWhenWrongCssIsAdded() { // const view = this.testView; diff --git a/apps/automated/src/ui/lifecycle/lifecycle-tests.ts b/apps/automated/src/ui/lifecycle/lifecycle-tests.ts index 92f7a8309..7457cc6d9 100644 --- a/apps/automated/src/ui/lifecycle/lifecycle-tests.ts +++ b/apps/automated/src/ui/lifecycle/lifecycle-tests.ts @@ -75,26 +75,29 @@ export function test_setting_one_property_while_suspedned_does_not_call_other_pr TKUnit.assertEqual(btn1.fontInternalSetNativeCount, 2, 'fontInternal.setNative at step4'); } -export function test_css_properties_reset_only_once() { - const page = helper.navigateToModule('ui/lifecycle/pages/page-one'); - const btn2 = page.getViewById('btn2'); +// +// Commented out because in webpack5 css loading has been rewritten, and does not use page.css +// +// export function test_css_properties_reset_only_once() { +// const page = helper.navigateToModule('ui/lifecycle/pages/page-one'); +// const btn2 = page.getViewById('btn2'); - TKUnit.assertEqual(btn2.backgroundInternalSetNativeCount, 1, `Expected ${btn2.id}'s backgroundInternal.setNative to be exactly once when inflating from xml.`); - TKUnit.assertEqual(btn2.fontInternalSetNativeCount, 1, `Expected ${btn2.id}'s fontInternal.setNative to be called exactly once when inflating from xml.`); - TKUnit.assertEqual(btn2.nativeBackgroundRedraws, 1, `Expected ${btn2.id}'s native background to propagated exactly once when inflating from xml.`); +// TKUnit.assertEqual(btn2.backgroundInternalSetNativeCount, 1, `1: Expected ${btn2.id}'s backgroundInternal.setNative to be exactly once when inflating from xml.`); +// TKUnit.assertEqual(btn2.fontInternalSetNativeCount, 1, `1: Expected ${btn2.id}'s fontInternal.setNative to be called exactly once when inflating from xml.`); +// TKUnit.assertEqual(btn2.nativeBackgroundRedraws, 1, `1: Expected ${btn2.id}'s native background to propagated exactly once when inflating from xml.`); - page.css = ''; +// page.css = ''; - TKUnit.assertEqual(btn2.backgroundInternalSetNativeCount, 2, `Expected ${btn2.id}'s backgroundInternal.setNative to be exactly once when inflating from xml.`); - TKUnit.assertEqual(btn2.fontInternalSetNativeCount, 2, `Expected ${btn2.id}'s fontInternal.setNative to be called exactly once when inflating from xml.`); - TKUnit.assertEqual(btn2.nativeBackgroundRedraws, isIOS ? 1 : 2, `Expected ${btn2.id}'s native background to propagated exactly once when inflating from xml.`); +// TKUnit.assertEqual(btn2.backgroundInternalSetNativeCount, 2, `2: Expected ${btn2.id}'s backgroundInternal.setNative to be exactly once when inflating from xml.`); +// TKUnit.assertEqual(btn2.fontInternalSetNativeCount, 2, `2: Expected ${btn2.id}'s fontInternal.setNative to be called exactly once when inflating from xml.`); +// TKUnit.assertEqual(btn2.nativeBackgroundRedraws, isIOS ? 1 : 2, `2: Expected ${btn2.id}'s native background to propagated exactly once when inflating from xml.`); - helper.waitUntilLayoutReady(btn2); +// helper.waitUntilLayoutReady(btn2); - TKUnit.assertEqual(btn2.backgroundInternalSetNativeCount, 2, `Expected ${btn2.id}'s backgroundInternal.setNative to be exactly once when inflating from xml.`); - TKUnit.assertEqual(btn2.fontInternalSetNativeCount, 2, `Expected ${btn2.id}'s fontInternal.setNative to be called exactly once when inflating from xml.`); - TKUnit.assertEqual(btn2.nativeBackgroundRedraws, 2, `Expected ${btn2.id}'s native background to propagated exactly once when inflating from xml.`); -} +// TKUnit.assertEqual(btn2.backgroundInternalSetNativeCount, 2, `3: Expected ${btn2.id}'s backgroundInternal.setNative to be exactly once when inflating from xml.`); +// TKUnit.assertEqual(btn2.fontInternalSetNativeCount, 2, `3: Expected ${btn2.id}'s fontInternal.setNative to be called exactly once when inflating from xml.`); +// TKUnit.assertEqual(btn2.nativeBackgroundRedraws, 2, `3: Expected ${btn2.id}'s native background to propagated exactly once when inflating from xml.`); +// } export function test_navigating_away_does_not_excessively_reset() { const page = helper.navigateToModule('ui/lifecycle/pages/page-one'); diff --git a/apps/automated/src/ui/list-view/list-view-tests.ts b/apps/automated/src/ui/list-view/list-view-tests.ts index a748f44ec..4e32eeef0 100644 --- a/apps/automated/src/ui/list-view/list-view-tests.ts +++ b/apps/automated/src/ui/list-view/list-view-tests.ts @@ -753,19 +753,23 @@ export class ListViewTest extends UITest { private assertNoMemoryLeak(weakRef: WeakRef) { this.tearDown(); - TKUnit.waitUntilReady(() => { - if (isIOS) { - /* tslint:disable:no-unused-expression */ - // Could cause GC on the next call. - // NOTE: Don't replace this with forceGC(); - new ArrayBuffer(4 * 1024 * 1024); - } - Utils.GC(); + // + // commented out because with latest engines we use the built-in v8 WeakRef implementation + // which does not guarantee releases after a GC pass. + // + // TKUnit.waitUntilReady(() => { + // if (isIOS) { + // /* tslint:disable:no-unused-expression */ + // // Could cause GC on the next call. + // // NOTE: Don't replace this with forceGC(); + // new ArrayBuffer(4 * 1024 * 1024); + // } + // Utils.GC(); + // + // return !weakRef.get(); + // }); - return !weakRef.get(); - }); - - TKUnit.assert(!weakRef.get(), weakRef.get() + ' leaked!'); + // TKUnit.assert(!weakRef.get(), weakRef.get() + ' leaked!'); } private loadViewWithItemNumber(args: ItemEventData) { diff --git a/apps/automated/src/ui/root-view/root-modules/custom-component-root.xml b/apps/automated/src/ui/root-view/root-modules/custom-component-root.xml index 5687d7512..9f5185bdc 100644 --- a/apps/automated/src/ui/root-view/root-modules/custom-component-root.xml +++ b/apps/automated/src/ui/root-view/root-modules/custom-component-root.xml @@ -1,2 +1,2 @@ - + diff --git a/apps/automated/src/ui/styling/style-tests.ts b/apps/automated/src/ui/styling/style-tests.ts index a40eb38ba..3a70b7837 100644 --- a/apps/automated/src/ui/styling/style-tests.ts +++ b/apps/automated/src/ui/styling/style-tests.ts @@ -679,21 +679,22 @@ export function test_CSS_isAppliedOnPage_From_Import() { helper.buildUIAndRunTest(testButton, function (views: Array) { const page: Page = views[1]; - page.css = "@import url('ui/styling/test-page.css');"; + // page.css = "@import url('ui/styling/test-page.css');"; + page.addCssFile('ui/styling/test-page.css'); helper.assertViewBackgroundColor(page, '#FF0000'); }); } -export function test_CSS_isAppliedOnPage_From_Import_Without_Url() { - const testButton = new Button(); - testButton.text = 'Test'; +// export function test_CSS_isAppliedOnPage_From_Import_Without_Url() { +// const testButton = new Button(); +// testButton.text = 'Test'; - helper.buildUIAndRunTest(testButton, function (views: Array) { - const page: Page = views[1]; - page.css = "@import 'ui/styling/test-page.css';"; - helper.assertViewBackgroundColor(page, '#FF0000'); - }); -} +// helper.buildUIAndRunTest(testButton, function (views: Array) { +// const page: Page = views[1]; +// page.css = "@import 'ui/styling/test-page.css';"; +// helper.assertViewBackgroundColor(page, '#FF0000'); +// }); +// } export function test_CSS_isAppliedOnPage_From_addCssFile() { const testButton = new Button(); diff --git a/apps/automated/src/ui/tab-view/tab-view-tests-native.ios.ts b/apps/automated/src/ui/tab-view/tab-view-tests-native.ios.ts index 080f36607..080a52220 100644 --- a/apps/automated/src/ui/tab-view/tab-view-tests-native.ios.ts +++ b/apps/automated/src/ui/tab-view/tab-view-tests-native.ios.ts @@ -1,7 +1,6 @@ -import tabViewModule = require('@nativescript/core/ui/tab-view'); -import { Font } from '@nativescript/core/ui/styling/font'; +import { Font, TabView } from '@nativescript/core'; -export function getNativeTabCount(tabView: tabViewModule.TabView): number { +export function getNativeTabCount(tabView: TabView): number { if (!tabView.ios.viewControllers) { return 0; } @@ -9,16 +8,16 @@ export function getNativeTabCount(tabView: tabViewModule.TabView): number { return tabView.ios.viewControllers.count; } -export function selectNativeTab(tabView: tabViewModule.TabView, index: number): void { +export function selectNativeTab(tabView: TabView, index: number): void { tabView.ios.selectedIndex = index; tabView.ios.delegate.tabBarControllerDidSelectViewController(tabView.ios, tabView.ios.selectedViewController); } -export function getNativeSelectedIndex(tabView: tabViewModule.TabView): number { +export function getNativeSelectedIndex(tabView: TabView): number { return tabView.ios.selectedIndex; } -export function getNativeFont(tabView: tabViewModule.TabView): UIFont { +export function getNativeFont(tabView: TabView): UIFont { const tabBar = tabView.ios.tabBar; if (tabBar.items.count > 0) { const currentAttrs = tabBar.items[0].titleTextAttributesForState(UIControlState.Normal); @@ -30,6 +29,6 @@ export function getNativeFont(tabView: tabViewModule.TabView): UIFont { return null; } -export function getOriginalFont(tabView: tabViewModule.TabView): UIFont { +export function getOriginalFont(tabView: TabView): UIFont { return (tabView.style.fontInternal || Font.default).getUIFont(UIFont.systemFontOfSize(10)); } diff --git a/apps/automated/src/ui/text-field/text-field-tests.ts b/apps/automated/src/ui/text-field/text-field-tests.ts index 89ae45ed5..46b656b1a 100644 --- a/apps/automated/src/ui/text-field/text-field-tests.ts +++ b/apps/automated/src/ui/text-field/text-field-tests.ts @@ -619,15 +619,15 @@ export var testNativeTextAlignmentFromLocal = function () { }); }; -export var testMemoryLeak = function (done) { - helper.buildUIWithWeakRefAndInteract( - _createTextFieldFunc, - function (textField) { - typeTextNatively(textField, 'Hello, world!'); - }, - done - ); -}; +// export var testMemoryLeak = function (done) { +// helper.buildUIWithWeakRefAndInteract( +// _createTextFieldFunc, +// function (textField) { +// typeTextNatively(textField, 'Hello, world!'); +// }, +// done +// ); +// }; export var test_WhenFormattedTextPropertyChanges_TextIsUpdated_TextBase = function () { var firstSpan = new Span(); diff --git a/apps/automated/src/ui/text-view/text-view-tests.ts b/apps/automated/src/ui/text-view/text-view-tests.ts index 692269d4f..21996144e 100644 --- a/apps/automated/src/ui/text-view/text-view-tests.ts +++ b/apps/automated/src/ui/text-view/text-view-tests.ts @@ -508,15 +508,15 @@ export var testNativeTextAlignmentFromLocal = function () { }); }; -export var testMemoryLeak = function (done) { - helper.buildUIWithWeakRefAndInteract( - _createTextViewFunc, - function (textView) { - textViewTestsNative.typeTextNatively(textView, 'Hello, world!'); - }, - done - ); -}; +// export var testMemoryLeak = function (done) { +// helper.buildUIWithWeakRefAndInteract( +// _createTextViewFunc, +// function (textView) { +// textViewTestsNative.typeTextNatively(textView, 'Hello, world!'); +// }, +// done +// ); +// }; export function test_watch_listerer_is_removed_at_onDetach() { if (platform.isAndroid) { diff --git a/apps/automated/src/xml-declaration/mymodule/package.json b/apps/automated/src/xml-declaration/mymodule/package.json deleted file mode 100644 index 74604969c..000000000 --- a/apps/automated/src/xml-declaration/mymodule/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "MyControl", - "main": "MyControl.js" -} diff --git a/apps/automated/tsconfig.json b/apps/automated/tsconfig.json index ab1c7ad8b..6230aa69d 100644 --- a/apps/automated/tsconfig.json +++ b/apps/automated/tsconfig.json @@ -1,10 +1,10 @@ { - "extends": "../../tsconfig.json", - "compilerOptions": { - "diagnostics": false, - "paths": { - "~/*": ["src/*"], - "tns-core-modules/*": ["@nativescript/core/*"] - } - } + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "diagnostics": false, + "paths": { + "~/*": ["src/*"], + "tns-core-modules/*": ["@nativescript/core/*"] + } + } } diff --git a/apps/automated/webpack.config.js b/apps/automated/webpack.config.js new file mode 100644 index 000000000..389f19d63 --- /dev/null +++ b/apps/automated/webpack.config.js @@ -0,0 +1,21 @@ +const webpack = require("@nativescript/webpack"); + +module.exports = (env) => { + webpack.init(env); + + webpack.Utils.addCopyRule('ui/web-view/*.html'); + + webpack.chainWebpack(config => { + config.plugin('DefinePlugin').tap(args => { + Object.assign(args[0], { + __CI__: !!process.env.CI, + }) + + return args + }) + }) + + return webpack.resolveConfig(); +}; + + diff --git a/apps/automated/webpack.custom.config.js b/apps/automated/webpack.custom.config.js deleted file mode 100644 index 02e1478d4..000000000 --- a/apps/automated/webpack.custom.config.js +++ /dev/null @@ -1,22 +0,0 @@ -const webpack = require('webpack'); -const CopyWebpackPlugin = require('copy-webpack-plugin'); - -const webpackConfig = require('./webpack.config'); - -module.exports = (env) => { - env = env || {}; - const baseConfig = webpackConfig(env); - - baseConfig.plugins.push(new CopyWebpackPlugin([ - { from: { glob: 'ui/web-view/*.html', dot: false } } - ])) - - baseConfig.plugins.push(new webpack.DefinePlugin({ - __CI__: !!process.env.CI, - __UI_USE_XML_PARSER__: true, - __UI_USE_EXTERNAL_RENDERER__: false, - __CSS_PARSER__: JSON.stringify('css-tree') - })) - - return baseConfig; -}; diff --git a/apps/toolbox/.gitignore b/apps/toolbox/.gitignore index b5d843b53..604359893 100644 --- a/apps/toolbox/.gitignore +++ b/apps/toolbox/.gitignore @@ -40,4 +40,4 @@ app/app.scss package-lock.json !tools/** -!webpack.custom.config.js +!webpack.config.js diff --git a/apps/toolbox/nativescript.config.ts b/apps/toolbox/nativescript.config.ts index 5b3e82b55..e6bcbc6d0 100644 --- a/apps/toolbox/nativescript.config.ts +++ b/apps/toolbox/nativescript.config.ts @@ -2,11 +2,13 @@ import { NativeScriptConfig } from '@nativescript/core'; export default { id: 'org.nativescript.ToolBox', + appPath: 'src', appResourcesPath: '../../tools/assets/App_Resources', - webpackConfigPath: 'webpack.custom.config.js', android: { v8Flags: '--expose_gc', - markingMode: 'none', suppressCallJSMethodExceptions: false, }, + cli: { + packageManager: 'npm', + }, } as NativeScriptConfig; diff --git a/apps/toolbox/package.json b/apps/toolbox/package.json index f265e7dfa..778084d24 100644 --- a/apps/toolbox/package.json +++ b/apps/toolbox/package.json @@ -1,5 +1,5 @@ { - "main": "main.js", + "main": "src/main.ts", "description": "NativeScript Application", "license": "MIT", "repository": { diff --git a/apps/toolbox/project.json b/apps/toolbox/project.json new file mode 100644 index 000000000..cbd4bc8dc --- /dev/null +++ b/apps/toolbox/project.json @@ -0,0 +1,42 @@ +{ + "root": "apps/toolbox/", + "sourceRoot": "apps/toolbox/src", + "projectType": "application", + "prefix": "nativescript", + "targets": { + "build": { + "executor": "@nativescript/nx:build", + "options": { + "noHmr": true, + "production": true, + "uglify": true, + "release": true, + "forDevice": true + } + }, + "ios": { + "executor": "@nativescript/nx:build", + "options": { + "platform": "ios" + } + }, + "android": { + "executor": "@nativescript/nx:build", + "options": { + "platform": "android" + } + }, + "clean": { + "executor": "@nativescript/nx:build", + "options": { + "clean": true + } + }, + "lint": { + "executor": "@nrwl/linter:eslint", + "options": { + "lintFilePatterns": ["apps/toolbox/**/*.ts", "apps/toolbox/src/**/*.html"] + } + } + } +} diff --git a/apps/toolbox/src/app-platform.android.css b/apps/toolbox/src/_app-platform.android.css similarity index 100% rename from apps/toolbox/src/app-platform.android.css rename to apps/toolbox/src/_app-platform.android.css diff --git a/apps/toolbox/src/app-platform.ios.css b/apps/toolbox/src/_app-platform.ios.css similarity index 100% rename from apps/toolbox/src/app-platform.ios.css rename to apps/toolbox/src/_app-platform.ios.css diff --git a/apps/toolbox/src/app.css b/apps/toolbox/src/app.css index b8800b7a5..e52432cd1 100644 --- a/apps/toolbox/src/app.css +++ b/apps/toolbox/src/app.css @@ -1,5 +1,5 @@ -@import '~nativescript-theme-core/css/core.light.css'; -@import './app-platform.css'; +@import 'nativescript-theme-core/css/core.light.css'; +@import './_app-platform.css'; /* The following CSS rule changes the font size of all UI diff --git a/apps/toolbox/tsconfig.json b/apps/toolbox/tsconfig.json index 27d27ebd9..0d0dc494b 100644 --- a/apps/toolbox/tsconfig.json +++ b/apps/toolbox/tsconfig.json @@ -1,9 +1,9 @@ { - "extends": "../../tsconfig.json", - "compilerOptions": { - "diagnostics": false, - "paths": { - "~/*": ["src/*"] - } - } + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "diagnostics": false, + "paths": { + "~/*": ["src/*"] + } + } } diff --git a/apps/toolbox/webpack.config.js b/apps/toolbox/webpack.config.js new file mode 100644 index 000000000..509672c37 --- /dev/null +++ b/apps/toolbox/webpack.config.js @@ -0,0 +1,19 @@ +const webpack = require("@nativescript/webpack"); + +module.exports = (env) => { + webpack.init(env); + + webpack.chainWebpack(config => { + config.plugin('DefinePlugin').tap(args => { + Object.assign(args[0], { + __CI__: !!process.env.CI, + }) + + return args + }) + }) + + return webpack.resolveConfig(); +}; + + diff --git a/apps/toolbox/webpack.custom.config.js b/apps/toolbox/webpack.custom.config.js deleted file mode 100644 index b6ffd7b43..000000000 --- a/apps/toolbox/webpack.custom.config.js +++ /dev/null @@ -1,18 +0,0 @@ -const webpack = require('webpack'); -const CopyWebpackPlugin = require('copy-webpack-plugin'); - -const webpackConfig = require('./webpack.config'); - -module.exports = (env) => { - env = env || {}; - const baseConfig = webpackConfig(env); - - baseConfig.plugins.push(new webpack.DefinePlugin({ - __CI__: !!process.env.CI, - __UI_USE_XML_PARSER__: true, - __UI_USE_EXTERNAL_RENDERER__: false, - __CSS_PARSER__: JSON.stringify('css-tree') - })) - - return baseConfig; -}; diff --git a/apps/ui/.gitignore b/apps/ui/.gitignore index 9eccb5027..901706c8e 100644 --- a/apps/ui/.gitignore +++ b/apps/ui/.gitignore @@ -1 +1 @@ -!webpack.custom.config.js \ No newline at end of file +!webpack.config.js \ No newline at end of file diff --git a/apps/ui/README.md b/apps/ui/README.md index 56395869e..96c6addbb 100644 --- a/apps/ui/README.md +++ b/apps/ui/README.md @@ -1,7 +1,7 @@ ***e2e tests execution*** 1. Local setup - - install appium and all requirments related to `nativescript-dev-appium` plugin usage + - install appium and all requirements related to `nativescript-dev-appium` plugin usage - download images: ```npm run load-images Emulator-Api23-Default "iPhone X 12"``` @@ -36,7 +36,7 @@ - Run: `npm run e2e-debug [android|ios]` -run in separate console and don't kill it. This command will start appium server and driver and use the installed app on the device but it will not execute tests. +run in separate console and don't kill it. This command will start appium server and driver and use the installed app on the device, but it will not execute tests. - Go to vs code debugging and use a config like: ``` diff --git a/apps/ui/nativescript.config.ts b/apps/ui/nativescript.config.ts index 0ffc08f2f..3303902b2 100644 --- a/apps/ui/nativescript.config.ts +++ b/apps/ui/nativescript.config.ts @@ -2,10 +2,12 @@ import { NativeScriptConfig } from '@nativescript/core'; export default { id: 'org.nativescript.uitestsapp', + appPath: 'src', appResourcesPath: '../../tools/assets/App_Resources', - webpackConfigPath: 'webpack.custom.config.js', android: { v8Flags: '--expose_gc', - markingMode: 'none', + }, + cli: { + packageManager: 'npm', }, } as NativeScriptConfig; diff --git a/apps/ui/package.json b/apps/ui/package.json index 07ed191df..4ea1009e3 100644 --- a/apps/ui/package.json +++ b/apps/ui/package.json @@ -1,5 +1,5 @@ { - "main": "main.js", + "main": "src/main.ts", "description": "NativeScript Application", "license": "MIT", "repository": { diff --git a/apps/ui/project.json b/apps/ui/project.json new file mode 100644 index 000000000..01150a335 --- /dev/null +++ b/apps/ui/project.json @@ -0,0 +1,42 @@ +{ + "root": "apps/ui/", + "sourceRoot": "apps/ui/src", + "projectType": "application", + "prefix": "nativescript", + "targets": { + "build": { + "executor": "@nativescript/nx:build", + "options": { + "noHmr": true, + "production": true, + "uglify": true, + "release": true, + "forDevice": true + } + }, + "ios": { + "executor": "@nativescript/nx:build", + "options": { + "platform": "ios" + } + }, + "android": { + "executor": "@nativescript/nx:build", + "options": { + "platform": "android" + } + }, + "clean": { + "executor": "@nativescript/nx:build", + "options": { + "clean": true + } + }, + "lint": { + "executor": "@nrwl/linter:eslint", + "options": { + "lintFilePatterns": ["apps/ui/**/*.ts", "apps/ui/src/**/*.html"] + } + } + } +} diff --git a/apps/ui/src/css/styles-page.css b/apps/ui/src/css/styles-page.css index 1bd47cec9..e6bfaeacd 100644 --- a/apps/ui/src/css/styles-page.css +++ b/apps/ui/src/css/styles-page.css @@ -1,5 +1,6 @@ -#page { +@import url("../css/import.css"); + +#page { background-color: lightcoral; } -@import url("../css/import.css"); diff --git a/apps/ui/tsconfig.json b/apps/ui/tsconfig.json index d216e662b..6d0ed95c0 100644 --- a/apps/ui/tsconfig.json +++ b/apps/ui/tsconfig.json @@ -1,11 +1,11 @@ { - "extends": "../../tsconfig.json", - "compilerOptions": { - "diagnostics": false, - "paths": { - "~/*": ["src/*"] - } - }, - "include": ["src/**/*", "references.d.ts"], - "exclude": ["node_modules", "tmp", "platforms", "__tests__", "e2"] + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "diagnostics": false, + "paths": { + "~/*": ["src/*"], + "tns-core-modules/*": ["@nativescript/core/*"] + } + }, + "exclude": ["e2e"] } diff --git a/apps/ui/webpack.config.js b/apps/ui/webpack.config.js new file mode 100644 index 000000000..97dc89508 --- /dev/null +++ b/apps/ui/webpack.config.js @@ -0,0 +1,20 @@ +const webpack = require("@nativescript/webpack"); +const { ContextExclusionPlugin } = require('webpack') + +module.exports = (env) => { + webpack.init(env); + + webpack.chainWebpack(config => { + config.plugin('DefinePlugin').tap(args => { + Object.assign(args[0], { + __CI__: !!process.env.CI, + }) + + return args + }) + }) + + return webpack.resolveConfig(); +}; + + diff --git a/apps/ui/webpack.custom.config.js b/apps/ui/webpack.custom.config.js deleted file mode 100644 index b6ffd7b43..000000000 --- a/apps/ui/webpack.custom.config.js +++ /dev/null @@ -1,18 +0,0 @@ -const webpack = require('webpack'); -const CopyWebpackPlugin = require('copy-webpack-plugin'); - -const webpackConfig = require('./webpack.config'); - -module.exports = (env) => { - env = env || {}; - const baseConfig = webpackConfig(env); - - baseConfig.plugins.push(new webpack.DefinePlugin({ - __CI__: !!process.env.CI, - __UI_USE_XML_PARSER__: true, - __UI_USE_EXTERNAL_RENDERER__: false, - __CSS_PARSER__: JSON.stringify('css-tree') - })) - - return baseConfig; -}; diff --git a/jest.config.js b/jest.config.js index 8c858feaf..d08e9812c 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,3 +1,3 @@ -module.exports = { - projects: ['/packages/core'], -}; +const { getJestProjects } = require('@nrwl/jest'); + +module.exports = { projects: getJestProjects() }; diff --git a/nx.json b/nx.json index 4de54dd12..e92f224f4 100644 --- a/nx.json +++ b/nx.json @@ -15,39 +15,74 @@ "nx.json": "*", ".eslintrc.json": "*" }, - "projects": { - "apps-automated": { - "tags": [] + "targetDependencies": { + "build": [ + { + "target": "build", + "projects": "dependencies" + } + ] + }, + "cli": { + "defaultCollection": "@nrwl/workspace" + }, + "generators": { + "@nrwl/workspace": { + "library": { + "linter": "eslint" + } }, - "apps-toolbox": { - "tags": [] + "@nrwl/cypress": { + "cypress-project": { + "linter": "eslint" + } }, - "apps-ui": { - "tags": [] + "@nrwl/react": { + "application": { + "linter": "eslint" + }, + "library": { + "linter": "eslint" + } }, - "core": { - "tags": [] + "@nrwl/next": { + "application": { + "linter": "eslint" + } }, - "core-api-docs": { - "tags": [] + "@nrwl/web": { + "application": { + "linter": "eslint" + } }, - "types": { - "tags": [] + "@nrwl/node": { + "application": { + "linter": "eslint" + }, + "library": { + "linter": "eslint" + } }, - "types-ios": { - "tags": [] + "@nrwl/nx-plugin": { + "plugin": { + "linter": "eslint" + } }, - "types-android": { - "tags": [] + "@nrwl/nest": { + "application": { + "linter": "eslint" + } }, - "ui-mobile-base": { - "tags": [] - }, - "webpack": { - "tags": [] - }, - "webpack5": { - "tags": [] + "@nrwl/express": { + "application": { + "linter": "eslint" + }, + "library": { + "linter": "eslint" + } } + }, + "affected": { + "defaultBase": "master" } } diff --git a/package.json b/package.json index e2860588f..b31d31c21 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nativescript", - "version": "8.1.4", + "version": "8.1.5", "license": "MIT", "config": { "npm_alias": "npm" @@ -10,7 +10,7 @@ "setup": "npm run clean && npm install --legacy-peer-deps", "setup:yarn": "yarn clean && yarn", "setup:pnpm": "pnpm run clean && pnpm install", - "postinstall": "ts-patch install && husky install && nx run core:setup", + "postinstall": "ts-patch install && husky install && nx run webpack5:build", "start": "nps", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s", "apps-automated:ios": "cd apps/automated && tns debug ios --no-hmr --emulator --env.testing", @@ -50,17 +50,18 @@ "devDependencies": { "@nativescript/eslint-plugin": "~0.0.4", "@nativescript/hook": "^2.0.0", - "@nrwl/cli": "12.0.8", - "@nrwl/eslint-plugin-nx": "12.0.8", - "@nrwl/jest": "12.0.8", - "@nrwl/node": "12.0.8", - "@nrwl/tao": "12.0.8", - "@nrwl/workspace": "12.0.8", - "@nstudio/focus": "~11.1.0", + "@nativescript/nx": "~2.0.8", + "@nrwl/cli": "13.3.12", + "@nrwl/eslint-plugin-nx": "13.3.12", + "@nrwl/jest": "13.3.12", + "@nrwl/node": "13.3.12", + "@nrwl/tao": "13.3.12", + "@nrwl/workspace": "13.3.12", + "@nstudio/focus": "~13.0.1", "@nstudio/nps-i": "~1.1.0", "@prettier/plugin-xml": "^0.13.1", "@types/chai": "^4.2.11", - "@types/jest": "~26.0.8", + "@types/jest": "27.0.2", "@types/mocha": "^7.0.2", "@types/node": "14.14.33", "@typescript-eslint/eslint-plugin": "4.19.0", @@ -71,37 +72,38 @@ "cpy-cli": "^3.1.1", "css": "^3.0.0", "css-tree": "^1.0.0-alpha.39", - "dotenv": "8.2.0", + "dotenv": "10.0.0", "eslint": "7.22.0", "eslint-config-prettier": "8.1.0", "eslint-plugin-prettier": "^3.3.1", "gonzales": "^1.0.7", "husky": "^5.1.3", - "jest": "~26.2.2", + "jest": "27.2.3", "lint-staged": "^10.5.0", "mocha": "^8.0.1", "mocha-typescript": "^1.1.17", "module-alias": "^2.2.2", - "nativescript": "~8.1.3", + "nativescript": "~8.1.5", "nativescript-typedoc-theme": "1.1.0", "parse-css": "git+https://github.com/tabatkins/parse-css.git", "parserlib": "^1.1.1", - "prettier": "~2.2.1", + "prettier": "2.5.1", "reduce-css-calc": "~2.1.7", "rimraf": "3.0.2", "sass": "~1.32.8", "shady-css-parser": "^0.1.0", "terser-webpack-plugin": "~3.0.6", "tree-kill": "^1.2.2", - "ts-jest": "26.4.0", + "ts-jest": "27.0.5", "ts-node": "9.1.1", "ts-patch": "^1.3.0", "tslib": "2.1.0", "tslint": "6.1.3", "typedoc": "^0.20.14", - "typescript": "4.1.4", + "typescript": "4.3.5", "webpack": "~4.44.1", - "webpack-cli": "~3.3.12" + "webpack-cli": "~3.3.12", + "zx": "^4.2.0" }, "lint-staged": { "**/*": [ @@ -109,3 +111,4 @@ ] } } + diff --git a/packages/core/config/config.interface.ts b/packages/core/config/config.interface.ts index 6cf425b79..996979e6c 100644 --- a/packages/core/config/config.interface.ts +++ b/packages/core/config/config.interface.ts @@ -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[]; } diff --git a/packages/core/debugger/dom-node.ts b/packages/core/debugger/dom-node.ts index 21d4909e9..f7f229ffb 100644 --- a/packages/core/debugger/dom-node.ts +++ b/packages/core/debugger/dom-node.ts @@ -175,7 +175,7 @@ export class DOMNode { dispose() { unregisterNode(this); - this.viewRef.clear(); + // this.viewRef.clear(); } public toObject() { diff --git a/packages/core/package.json b/packages/core/package.json index 4f66b8c55..376d5a3b0 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -3,7 +3,7 @@ "main": "index", "types": "index.d.ts", "description": "A JavaScript library providing an easy to use api for interacting with iOS and Android platform APIs.", - "version": "8.1.4", + "version": "8.1.5", "homepage": "https://nativescript.org", "repository": { "type": "git", diff --git a/packages/core/project.json b/packages/core/project.json new file mode 100644 index 000000000..06a72f824 --- /dev/null +++ b/packages/core/project.json @@ -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 + } + } + } +} diff --git a/packages/core/timer/Readme.md b/packages/core/timer/Readme.md index 1f96d1bb8..bbb1384a4 100644 --- a/packages/core/timer/Readme.md +++ b/packages/core/timer/Readme.md @@ -1,4 +1,4 @@ -Timer module. Functions also can be availble in the global context if you require *globals* module. +Timer module. Functions also can be available in the global context if you require *globals* module. ```js require("globals"); diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json index e9722048f..d1689fde9 100644 --- a/packages/core/tsconfig.json +++ b/packages/core/tsconfig.json @@ -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__"] } diff --git a/packages/core/tsconfig.lib.json b/packages/core/tsconfig.lib.json index 0871411be..8476ca0f9 100644 --- a/packages/core/tsconfig.lib.json +++ b/packages/core/tsconfig.lib.json @@ -22,6 +22,6 @@ } ] }, - "exclude": ["**/*.spec.ts", "dist", "__tests__"], + "exclude": ["**/*.spec.ts", "**/*.test.ts", "dist", "__tests__"], "include": ["**/*.ts", "./references.d.ts"] } diff --git a/packages/core/tsconfig.spec.json b/packages/core/tsconfig.spec.json index 559410b96..3d95b817d 100644 --- a/packages/core/tsconfig.spec.json +++ b/packages/core/tsconfig.spec.json @@ -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"] } diff --git a/packages/core/ui/builder/xml2ui.ts b/packages/core/ui/builder/xml2ui.ts index f0f041d78..5dc732311 100644 --- a/packages/core/ui/builder/xml2ui.ts +++ b/packages/core/ui/builder/xml2ui.ts @@ -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; - parser?: { value: any; }; + parser?: { value: any }; } } } diff --git a/packages/core/ui/core/bindable/index.ts b/packages/core/ui/core/bindable/index.ts index e94b0019e..3bbd42d12 100644 --- a/packages/core/ui/core/bindable/index.ts +++ b/packages/core/ui/core/bindable/index.ts @@ -162,9 +162,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(); diff --git a/packages/core/ui/core/view/index.ios.ts b/packages/core/ui/core/view/index.ios.ts index a5c472944..456a21c4f 100644 --- a/packages/core/ui/core/view/index.ios.ts +++ b/packages/core/ui/core/view/index.ios.ts @@ -871,7 +871,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) { diff --git a/packages/core/ui/styling/style-scope.ts b/packages/core/ui/styling/style-scope.ts index b1bde3826..d3fedc25f 100644 --- a/packages/core/ui/styling/style-scope.ts +++ b/packages/core/ui/styling/style-scope.ts @@ -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 { diff --git a/packages/core/ui/web-view/index.d.ts b/packages/core/ui/web-view/index.d.ts index 8a60f1e3a..9a4c15c75 100644 --- a/packages/core/ui/web-view/index.d.ts +++ b/packages/core/ui/web-view/index.d.ts @@ -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). */ diff --git a/packages/types-android/project.json b/packages/types-android/project.json new file mode 100644 index 000000000..d7a1a62bc --- /dev/null +++ b/packages/types-android/project.json @@ -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 + } + } + } +} diff --git a/packages/types-ios/project.json b/packages/types-ios/project.json new file mode 100644 index 000000000..6ba53b059 --- /dev/null +++ b/packages/types-ios/project.json @@ -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 + } + } + } +} diff --git a/packages/types/project.json b/packages/types/project.json new file mode 100644 index 000000000..3616cfddc --- /dev/null +++ b/packages/types/project.json @@ -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 + } + } + } +} diff --git a/packages/ui-mobile-base/project.json b/packages/ui-mobile-base/project.json new file mode 100644 index 000000000..46f6fd7b6 --- /dev/null +++ b/packages/ui-mobile-base/project.json @@ -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 + } + } + } +} diff --git a/packages/webpack/project.json b/packages/webpack/project.json new file mode 100644 index 000000000..3d87956c2 --- /dev/null +++ b/packages/webpack/project.json @@ -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 + } + } + } +} diff --git a/packages/webpack5/__tests__/configuration/__snapshots__/angular.spec.ts.snap b/packages/webpack5/__tests__/configuration/__snapshots__/angular.spec.ts.snap index c888c2aad..51ea03a17 100644 --- a/packages/webpack5/__tests__/configuration/__snapshots__/angular.spec.ts.snap +++ b/packages/webpack5/__tests__/configuration/__snapshots__/angular.spec.ts.snap @@ -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 */ } + } + ] ] } } @@ -372,14 +400,15 @@ exports[`angular configuration for android 1`] = ` new AngularWebpackPlugin( { tsconfig: '__jest__/tsconfig.json', - directTemplateLoading: false + directTemplateLoading: false, + jitMode: false } ) ], 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 +501,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 +514,13 @@ exports[`angular configuration for ios 1`] = ` } ] }, + /* config.module.rule('js') */ + { + test: /\\\\.js$/, + exclude: [ + /node_modules/ + ] + }, /* config.module.rule('xml') */ { test: /\\\\.xml$/, @@ -532,7 +554,12 @@ exports[`angular configuration for ios 1`] = ` options: { postcssOptions: { plugins: [ - 'postcss-import' + [ + 'postcss-import', + { + resolve: function () { /* omitted long function */ } + } + ] ] } } @@ -562,7 +589,12 @@ exports[`angular configuration for ios 1`] = ` options: { postcssOptions: { plugins: [ - 'postcss-import' + [ + 'postcss-import', + { + resolve: function () { /* omitted long function */ } + } + ] ] } } @@ -573,6 +605,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 +686,12 @@ exports[`angular configuration for ios 1`] = ` options: { postcssOptions: { plugins: [ - 'postcss-import' + [ + 'postcss-import', + { + resolve: function () { /* omitted long function */ } + } + ] ] } } @@ -760,14 +817,15 @@ exports[`angular configuration for ios 1`] = ` new AngularWebpackPlugin( { tsconfig: '__jest__/tsconfig.json', - directTemplateLoading: false + directTemplateLoading: false, + jitMode: false } ) ], 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 +838,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 +848,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 +856,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", ] `; diff --git a/packages/webpack5/__tests__/configuration/__snapshots__/base.spec.ts.snap b/packages/webpack5/__tests__/configuration/__snapshots__/base.spec.ts.snap index 9209dd850..658a93148 100644 --- a/packages/webpack5/__tests__/configuration/__snapshots__/base.spec.ts.snap +++ b/packages/webpack5/__tests__/configuration/__snapshots__/base.spec.ts.snap @@ -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': [ diff --git a/packages/webpack5/__tests__/configuration/__snapshots__/javascript.spec.ts.snap b/packages/webpack5/__tests__/configuration/__snapshots__/javascript.spec.ts.snap index 8e642f69f..22ba2df01 100644 --- a/packages/webpack5/__tests__/configuration/__snapshots__/javascript.spec.ts.snap +++ b/packages/webpack5/__tests__/configuration/__snapshots__/javascript.spec.ts.snap @@ -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': [ diff --git a/packages/webpack5/__tests__/configuration/__snapshots__/react.spec.ts.snap b/packages/webpack5/__tests__/configuration/__snapshots__/react.spec.ts.snap index 10de0bf00..501497ffe 100644 --- a/packages/webpack5/__tests__/configuration/__snapshots__/react.spec.ts.snap +++ b/packages/webpack5/__tests__/configuration/__snapshots__/react.spec.ts.snap @@ -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': [ diff --git a/packages/webpack5/__tests__/configuration/__snapshots__/svelte.spec.ts.snap b/packages/webpack5/__tests__/configuration/__snapshots__/svelte.spec.ts.snap index f17a1d443..e55821c56 100644 --- a/packages/webpack5/__tests__/configuration/__snapshots__/svelte.spec.ts.snap +++ b/packages/webpack5/__tests__/configuration/__snapshots__/svelte.spec.ts.snap @@ -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': [ diff --git a/packages/webpack5/__tests__/configuration/__snapshots__/typescript.spec.ts.snap b/packages/webpack5/__tests__/configuration/__snapshots__/typescript.spec.ts.snap index c3ccd94a5..e5cad4940 100644 --- a/packages/webpack5/__tests__/configuration/__snapshots__/typescript.spec.ts.snap +++ b/packages/webpack5/__tests__/configuration/__snapshots__/typescript.spec.ts.snap @@ -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': [ diff --git a/packages/webpack5/__tests__/configuration/__snapshots__/vue.spec.ts.snap b/packages/webpack5/__tests__/configuration/__snapshots__/vue.spec.ts.snap index 4282ea2d1..87bf13417 100644 --- a/packages/webpack5/__tests__/configuration/__snapshots__/vue.spec.ts.snap +++ b/packages/webpack5/__tests__/configuration/__snapshots__/vue.spec.ts.snap @@ -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': [ diff --git a/packages/webpack5/__tests__/loaders/xml-namespace-loader.spec.ts b/packages/webpack5/__tests__/loaders/xml-namespace-loader.spec.ts index adcde7dc9..d1a27eedf 100644 --- a/packages/webpack5/__tests__/loaders/xml-namespace-loader.spec.ts +++ b/packages/webpack5/__tests__/loaders/xml-namespace-loader.spec.ts @@ -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 = ` - `; diff --git a/packages/webpack5/package.json b/packages/webpack5/package.json index 4c04c162b..589e5f9e2 100644 --- a/packages/webpack5/package.json +++ b/packages/webpack5/package.json @@ -1,6 +1,6 @@ { "name": "@nativescript/webpack", - "version": "5.0.0", + "version": "5.0.4", "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", @@ -37,7 +37,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", @@ -54,6 +54,7 @@ "webpack-virtual-modules": "^0.4.0" }, "devDependencies": { + "@angular-devkit/build-angular": "^13.1.2", "@types/css": "0.0.33", "@types/jest": "27.0.1", "@types/loader-utils": "2.0.3", diff --git a/packages/webpack5/project.json b/packages/webpack5/project.json new file mode 100644 index 000000000..b83ad29cd --- /dev/null +++ b/packages/webpack5/project.json @@ -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" + } + } + } +} diff --git a/packages/webpack5/src/configuration/angular.ts b/packages/webpack5/src/configuration/angular.ts index c50754244..8b9b5e498 100644 --- a/packages/webpack5/src/configuration/angular.ts +++ b/packages/webpack5/src/configuration/angular.ts @@ -1,10 +1,12 @@ import { extname, resolve } from 'path'; -import { merge } from 'webpack-merge'; import Config from 'webpack-chain'; import { existsSync } from 'fs'; +import { getTypescript, readTsConfig } from '../helpers/typescript'; +import { getDependencyPath } from '../helpers/dependencies'; import { getProjectFilePath } from '../helpers/project'; import { env as _env, IWebpackEnv } from '../index'; +import { warnOnce } from '../helpers/log'; import { getEntryDirPath, getEntryPath, @@ -22,6 +24,8 @@ export default function (config: Config, env: IWebpackEnv = _env): Config { getProjectFilePath('tsconfig.json'), ].find((path) => existsSync(path)); + const disableAOT = !!env.disableAOT; + // remove default ts rule config.module.rules.delete('ts'); @@ -148,7 +152,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); }; @@ -156,6 +162,7 @@ export default function (config: Config, env: IWebpackEnv = _env): Config { { tsconfig: tsConfigPath, directTemplateLoading: false, + jitMode: disableAOT, }, ]); @@ -167,6 +174,41 @@ export default function (config: Config, env: IWebpackEnv = _env): Config { .use('angular-hot-loader') .loader('angular-hot-loader'); }); + + const buildAngularPath = getDependencyPath('@angular-devkit/build-angular'); + if (buildAngularPath) { + const tsConfig = readTsConfig(tsConfigPath); + const { ScriptTarget } = getTypescript(); + const scriptTarget = tsConfig.options.target ?? ScriptTarget.ESNext; + const buildAngularOptions: any = { + scriptTarget, + aot: !disableAOT, + }; + if (disableAOT) { + buildAngularOptions.optimize = false; + } + // 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(buildAngularOptions); + } else { + warnOnce( + 'build-angular-missing', + ` + @angular-devkit/build-angular is missing! Some features may not work as expected. Please install it manually to get rid of this warning. + ` + ); + } } // look for platform specific polyfills first @@ -182,10 +224,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); diff --git a/packages/webpack5/src/configuration/base.ts b/packages/webpack5/src/configuration/base.ts index 37d85c86d..0c2659f6d 100644 --- a/packages/webpack5/src/configuration/base.ts +++ b/packages/webpack5/src/configuration/base.ts @@ -1,10 +1,11 @@ +import { extname, resolve } from 'path'; import { ContextExclusionPlugin, DefinePlugin, HotModuleReplacementPlugin, } 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'; @@ -86,8 +87,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 @@ -126,6 +127,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', @@ -198,12 +200,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 @@ -249,12 +263,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 @@ -270,7 +278,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; + }, + }, + ], ], }, }; diff --git a/packages/webpack5/src/configuration/javascript.ts b/packages/webpack5/src/configuration/javascript.ts index 0696e9b7b..914036eb2 100644 --- a/packages/webpack5/src/configuration/javascript.ts +++ b/packages/webpack5/src/configuration/javascript.ts @@ -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; } diff --git a/packages/webpack5/src/configuration/svelte.ts b/packages/webpack5/src/configuration/svelte.ts index e5feea09e..4d4f239e0 100644 --- a/packages/webpack5/src/configuration/svelte.ts +++ b/packages/webpack5/src/configuration/svelte.ts @@ -1,4 +1,3 @@ -import { merge } from 'webpack-merge'; import Config from 'webpack-chain'; import { getProjectFilePath } from '../helpers/project'; @@ -19,6 +18,10 @@ export default function (config: Config, env: IWebpackEnv = _env): Config { // electron-main sneaks us past the target == 'node' check and gets us HMR config.target('electron-main'); + // turns out this isn't enough now. svelte uses "node" of which "electron-main" is a subset in its export map forcing imports + // for 'svelte' to 'ssr.mjs'. We define an alias here to force it back. + config.resolve.alias.set('svelte$', 'svelte/internal'); + // svelte-hmr still references tns-core-modules, so we shim it here for compat. config.resolve.alias.set('tns-core-modules', '@nativescript/core'); diff --git a/packages/webpack5/src/configuration/typescript.ts b/packages/webpack5/src/configuration/typescript.ts index b8b9492a2..4513af52d 100644 --- a/packages/webpack5/src/configuration/typescript.ts +++ b/packages/webpack5/src/configuration/typescript.ts @@ -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; } diff --git a/packages/webpack5/src/helpers/index.ts b/packages/webpack5/src/helpers/index.ts index a06c98579..6f43a0b7a 100644 --- a/packages/webpack5/src/helpers/index.ts +++ b/packages/webpack5/src/helpers/index.ts @@ -19,6 +19,7 @@ import { getPlatform, getPlatformName, } from './platform'; +import { readTsConfig } from './typescript'; // intentionally populated manually // as this generates nicer typings @@ -59,4 +60,7 @@ export default { getPlatform, getPlatformName, }, + tsconfig: { + readTsConfig, + }, }; diff --git a/packages/webpack5/src/helpers/typescript.ts b/packages/webpack5/src/helpers/typescript.ts new file mode 100644 index 000000000..8e1cccc05 --- /dev/null +++ b/packages/webpack5/src/helpers/typescript.ts @@ -0,0 +1,54 @@ +import { dirname } from 'path'; +import { env } from '..'; + +import { warnOnce } from './log'; + +/** + * @internal + */ +let typescript: typeof import('typescript'); + +/** + * Helper used to import typescript. + * + * The reason this exists is that not all flavors use Typescript, and + * in those cases just importing this helper will throw an exception. + */ +export function getTypescript(): typeof import('typescript') { + if (typescript) { + return typescript; + } + + try { + typescript = require('typescript'); + return typescript; + } catch (err) { + warnOnce( + 'typescript-missing', + `TypeScript is not installed in this project, but a config is trying to use it.`, + env.verbose + ? new Error().stack + : 'Run with --env.verbose to log a stack trace to help debug this further.' + ); + + return {} as any; + } +} + +export function readTsConfig(path: string) { + const { readConfigFile, parseJsonConfigFileContent, sys } = getTypescript(); + const f = readConfigFile(path, sys.readFile); + + const parsed = parseJsonConfigFileContent( + f.config, + { + fileExists: sys.fileExists, + readFile: sys.readFile, + readDirectory: sys.readDirectory, + useCaseSensitiveFileNames: true, + }, + dirname(path) + ); + + return parsed; +} diff --git a/packages/webpack5/src/loaders/xml-namespace-loader/index.ts b/packages/webpack5/src/loaders/xml-namespace-loader/index.ts index f3bff1a83..edb3fbf68 100644 --- a/packages/webpack5/src/loaders/xml-namespace-loader/index.ts +++ b/packages/webpack5/src/loaders/xml-namespace-loader/index.ts @@ -78,6 +78,10 @@ async function parseXML(content: string): Promise { `${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 { 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() - 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() + // 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 { distinctNamespaces.set(name, path.replace(/\\/g, '/')); }); + DEBUG && console.log({ distinctNamespaces }); + distinctNamespaces.forEach((path, name) => { moduleRegisters.push(dedent` global.registerModule( diff --git a/tools/notes/CONTRIBUTING-webpack.md b/tools/notes/CONTRIBUTING-webpack.md index f65a4183d..1750d3ab9 100644 --- a/tools/notes/CONTRIBUTING-webpack.md +++ b/tools/notes/CONTRIBUTING-webpack.md @@ -23,7 +23,7 @@ Before starting, make yourself familiar with the `@nativescript/webpack`'s [docu ## Project Structure The repository contains several ingredients: -* `installer.js` - combination of postinstall scripts for adding or removing webpack configurations and necessary dependecies when installing the plugin. +* `installer.js` - combination of postinstall scripts for adding or removing webpack configurations and necessary dependencies when installing the plugin. * `templates/` - webpack config templates for different types of projects - NativeScript with JavaScript, NativeScript with TypeScript and NativeScript Angular projects. * `plugins/` - several [Webpack plugins](https://webpack.js.org/concepts/plugins/) necessary for bundling NativeScript applications. * `snapshot/android/` - tools used with the `NativeScriptSnapshot` plugin for generating V8 Heap Snapshots. @@ -164,7 +164,7 @@ git checkout release && git pull git merge --ff-only origin/master ``` *** Note: If there are commits in release branch which are not merged in master branch '-ff-merge' command will fail. -In this case the commits should be merge firstly from release in master branch as explained in section 'Merge changes from release into master' and then repeat step 1. +In this case the commits should be merged firstly from release in master branch as explained in section 'Merge changes from release into master' and then repeat step 1. 2. Execute `npm i` to install dependencies: ``` @@ -233,7 +233,7 @@ git commit git push ``` -6. Create pull request. Replace replace env ${MERGE_BRANCH} with its value +6. Create pull request. Replace env ${MERGE_BRANCH} with its value ``` curl -d '{"title": "chore: merge release in master","body": "chore: merge release in master","head": "merge-release-in-master","base": "master"}' -X POST https://api.github.com/repos/NativeScript/NativeScript/pulls -H "Authorization: token ${GIT_TOKEN}" ``` @@ -244,4 +244,4 @@ git checkout origin/master tns-platform-declarations/package.json tns-core-modul git commit --amend git push --force-with-lease ``` -This will require to repeat steps from 1 to 4, since we need to keep the branches with the same history +This will require repeating steps from 1 to 4, since we need to keep the branches with the same history diff --git a/tools/notes/CONTRIBUTING.md b/tools/notes/CONTRIBUTING.md index a0f9abb1c..3453fbcbb 100644 --- a/tools/notes/CONTRIBUTING.md +++ b/tools/notes/CONTRIBUTING.md @@ -94,12 +94,12 @@ When you click on the button, you will be redirected to the report page. On the > Note: Each item name consists of the application name, type of device and platform version: `pr-e2e-tests-[application-name]-[device-type]-[platform-version]`. Usually, the test applications, that are executed for PRs are part of NativeScript repository. -Based on the executed suite, one of the following or all of the following files will be generated: `mochawesome.html` | `index.html` | `unit-tests.log`. Some of the reports also might include `*.png`, `*.logs` or `[page source].xml` files that can help in understanding where is the problem. +Based on the executed suite, one of the following or all of the following files will be generated: `mochawesome.html` | `index.html` | `unit-tests.log`. Some reports also might include `*.png`, `*.logs` or `[page source].xml` files that can help in understanding where is the problem. For example: 1. When you select the `index.html` page, an additional `TestNG Results` sidebar will be displayed. There you can find a list of all failures. 2. When you select one of them, you will see on the right side all tests, that have been executed. The problematic ones will be coloured in red. -3. If you click on one of them, detailed info or error log will be displayed. As we've mentioned above in some of the test reports, you will also find screenshots, that demonstrates the problem visually. Those images can be found below the info/ error log. +3. If you click on one of them, detailed info or error log will be displayed. As we've mentioned above in some test reports, you will also find screenshots, that demonstrates the problem visually. Those images can be found below the info/ error log. ## Commit Message Guidelines @@ -248,7 +248,7 @@ git checkout release git merge --ff-only origin/master ``` *** Note: If there are commits in release branch which are not merged in master branch '-ff-merge' command will fail. -In this case the commits should be merge firstly from release in master branch as explained in section 'Merge changes from release into master' and then repeat step 1. +In this case the commits should be merged firstly from release in master branch as explained in section 'Merge changes from release into master' and then repeat step 1. 2. Execute `npm i` to install dependencies: ``` @@ -277,7 +277,7 @@ npm --no-git-tag-version version [major|minor|patch] -m "release: cut the %s rel cd .. ``` 6. Set correct version of **tns-core-modules-widgets** in tns-core-modules/package.json. -Usually tns-core-modules-widgets should already have been released and we need to set the official version. +Usually tns-core-modules-widgets should already have been released, and we need to set the official version. 7. Create release-branch with change log ``` @@ -333,7 +333,7 @@ git commit git push ``` -6. Create pull request. Replace replace env ${MERGE_BRANCH} with its value +6. Create pull request. Replace env ${MERGE_BRANCH} with its value ``` curl -d '{"title": "chore: merge release in master","body": "chore: merge release in master","head": "merge-release-in-master","base": "master"}' -X POST https://api.github.com/repos/NativeScript/NativeScript/pulls -H "Authorization: token ${GIT_TOKEN}" ``` @@ -344,4 +344,4 @@ git checkout origin/master tns-platform-declarations/package.json tns-core-modul git commit --amend git push --force-with-lease ``` -This will require to repeat steps from 1 to 4, since we need to keep the branches with the same history +This will require repeating steps from 1 to 4, since we need to keep the branches with the same history diff --git a/tools/notes/CodingConvention.md b/tools/notes/CodingConvention.md index 4ac32c31c..e20320c82 100644 --- a/tools/notes/CodingConvention.md +++ b/tools/notes/CodingConvention.md @@ -509,7 +509,7 @@ class Foo { ``` ## TypeScript optional parameters -**Do not** use optional parameters in IMPLEMENTATION files. This is because the TS compiler generates additional array and populates its from the **arguments** object. Still, it is OK to use these in a definition file (as declarations ONLY). +**Do not** use optional parameters in IMPLEMENTATION files. This is because the TS compiler generates additional array and populates it from the **arguments** object. Still, it is OK to use these in a definition file (as declarations ONLY). *Right:* ```TypeScript diff --git a/tools/notes/DevelopmentWorkflow.md b/tools/notes/DevelopmentWorkflow.md index 8cbe0c277..17d449523 100644 --- a/tools/notes/DevelopmentWorkflow.md +++ b/tools/notes/DevelopmentWorkflow.md @@ -50,7 +50,7 @@ You can do changes in the test app and `nativescript-core` and rely on HMR to re ## Running the `e2e` Test Apps -There are couple of application used for development and testing. +There are a couple of application used for development and testing. The `ui-test-app` is the more frequently used for development and validation. It is an ordinary NativeScript app that logs the test results on the go. After the [initial setup](#initial-setup) run the e2e apps with: diff --git a/tools/notes/HandlingErrors.md b/tools/notes/HandlingErrors.md index fca8056bf..37278fc9b 100644 --- a/tools/notes/HandlingErrors.md +++ b/tools/notes/HandlingErrors.md @@ -10,7 +10,7 @@ The `tns-core-modules/trace` utility module provides a good way to streamline er Here are the guidelines how to use this when contributing to core-modules or creating your own plugins. ### Use `trace.write()` -Use trace.write() with the appropriate type to log non critical errors. +Use trace.write() with the appropriate type to log non-critical errors. >Note: For the `error` message level all loggers will be notified unconditionally, for all other levels (`log`,`info`,`warn`), tracing should be enabled and the corresponding categories should be added. @@ -21,7 +21,7 @@ Use the `error()` when an error has occurred which compromises the stability of After calling `trace.error()` consider just returning from the function you are currently in without completing. -There are cases when code execution jumps between native code (ex. Android/iOS SDKs) and JavaScript trough callbacks. In those cases it is most difficult to determine if an error (ex. expected argument is `undefined` or current state of components is invalid) is critical or not. Although, it seems that error is unrecoverable, it might be the case that the callback is called when the app has gone to the background or trough activity/window that is not longer visible. So just reporting the error with `write()` or `error()` is a good option in such cases. +There are cases when code execution jumps between native code (ex. Android/iOS SDKs) and JavaScript trough callbacks. In those cases it is most difficult to determine if an error (ex. expected argument is `undefined` or current state of components is invalid) is critical or not. Although, it seems that error is unrecoverable, it might be the case that the callback is called when the app has gone to the background or trough activity/window that is no longer visible. So just reporting the error with `write()` or `error()` is a good option in such cases. ## Throw the Error directly in code @@ -31,6 +31,6 @@ Avoid throwing errors directly, especially in code that is not directly called f 2. Obviously misused public APIs (ex. wrong arguments types) which developers will call directly. ## Clearing Legacy Code -Not all the code in the `tns-core-modules` might conform to this guide as it might be written before some of the improvements of the trace modules (ex. `error()`). If you came across to such code you can always [give us a PR](CONTRIBUTING.md) referencing [this issue](https://github.com/NativeScript/NativeScript/issues/5914). +Not all the code in the `tns-core-modules` might conform to this guide as it might be written before some improvements of the trace modules (ex. `error()`). If you came across to such code you can always [give us a PR](CONTRIBUTING.md) referencing [this issue](https://github.com/NativeScript/NativeScript/issues/5914). diff --git a/tools/scripts/pack-webpack5.mjs b/tools/scripts/pack-webpack5.mjs new file mode 100755 index 000000000..bceb93c17 --- /dev/null +++ b/tools/scripts/pack-webpack5.mjs @@ -0,0 +1,25 @@ +#!/usr/bin/env zx +import 'zx/globals'; + +import path from 'path'; + +const webpack5Path = path.resolve(__dirname, '../../packages/webpack5'); +const distPath = path.resolve(__dirname, '../../dist/packages'); + +const packageJSON = await fs.readJSON(`${webpack5Path}/package.json`); +const tgzName = `nativescript-webpack-${packageJSON.version}.tgz`; + +cd(webpack5Path); + +await $`npm install`; +await $`npm pack`; + +const from = path.join(webpack5Path, tgzName); +const to = path.join(distPath, 'nativescript-webpack.tgz'); + +await fs.move(from, to, { + overwrite: true, +}); + +console.log(chalk.green(`@nativescript/webpack has been built and packed.\n`)); +console.log(to); \ No newline at end of file diff --git a/tools/scripts/project.json b/tools/scripts/project.json new file mode 100644 index 000000000..a5aa21ebd --- /dev/null +++ b/tools/scripts/project.json @@ -0,0 +1,17 @@ +{ + "root": "tools/scripts", + "sourceRoot": "tools/scripts", + "projectType": "library", + "generators": {}, + "targets": { + "build": { + "executor": "@nrwl/workspace:run-commands", + "outputs": ["tools/scripts/dist"], + "options": { + "commands": ["./build-docs.sh"], + "cwd": "tools/scripts", + "parallel": false + } + } + } +} diff --git a/tools/scripts/tsconfig.typedoc.json b/tools/scripts/tsconfig.typedoc.json index 290e69cf6..1e04a3340 100644 --- a/tools/scripts/tsconfig.typedoc.json +++ b/tools/scripts/tsconfig.typedoc.json @@ -1,5 +1,5 @@ { - "extends": "../../tsconfig.json", + "extends": "../../tsconfig.base.json", "compilerOptions": { "outDir": "../../dist/packages/core", "target": "es5", diff --git a/tools/tsconfig.tools.json b/tools/tsconfig.tools.json index 82bd1f098..600c137a6 100644 --- a/tools/tsconfig.tools.json +++ b/tools/tsconfig.tools.json @@ -1,11 +1,11 @@ { - "extends": "../tsconfig.json", - "compilerOptions": { - "outDir": "../dist/out-tsc/tools", - "rootDir": ".", - "module": "commonjs", - "target": "es5", - "types": ["node"] - }, - "include": ["**/*.ts"] + "extends": "../tsconfig.base.json", + "compilerOptions": { + "outDir": "../dist/out-tsc/tools", + "rootDir": ".", + "module": "commonjs", + "target": "es5", + "types": ["node"] + }, + "include": ["**/*.ts"] } diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 000000000..b3dfa14cd --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,28 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "rootDir": ".", + "target": "ES2017", + "module": "esnext", + "sourceMap": true, + "declaration": true, + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "noEmitOnError": true, + "noEmitHelpers": true, + "diagnostics": true, + "skipLibCheck": true, + "skipDefaultLibCheck": true, + "lib": ["es2017", "dom"], + "types": ["node", "jest"], + "baseUrl": ".", + "paths": { + "@nativescript/core": ["packages/core/index.ts"], + "@nativescript/core/*": ["packages/core/*"], + "@nativescript/types-android": ["packages/types-android/src/index.ts"], + "@nativescript/types-ios": ["packages/types-ios/src/index.ts"] + } + }, + "exclude": ["node_modules", "tmp", "platforms", "__tests__"] +} diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json index 5d8f21e45..6ca1bac23 100644 --- a/tsconfig.eslint.json +++ b/tsconfig.eslint.json @@ -1,4 +1,4 @@ { - "extends": "./tsconfig.json", + "extends": "./tsconfig.base.json", "include": ["packages/**/*"] } diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index 84a284c7c..000000000 --- a/tsconfig.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "compileOnSave": false, - "compilerOptions": { - "rootDir": ".", - "target": "ES2017", - "module": "esnext", - "sourceMap": true, - "declaration": true, - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "noEmitOnError": true, - "noEmitHelpers": true, - "diagnostics": true, - "skipLibCheck": true, - "skipDefaultLibCheck": true, - "lib": ["es2017", "dom"], - "types": ["node", "jest"], - "baseUrl": ".", - "paths": { - "@nativescript/core": ["packages/core/index.ts"], - "@nativescript/core/*": ["packages/core/*"], - "@nativescript/types-ios": ["packages/types-ios/src/index.ts"], - "@nativescript/types-android": ["packages/types-android/src/index.ts"] - } - }, - "exclude": ["node_modules", "tmp", "platforms", "__tests__"] -} diff --git a/workspace.json b/workspace.json index 547b38396..528c22834 100644 --- a/workspace.json +++ b/workspace.json @@ -1,358 +1,16 @@ { - "version": 1, + "version": 2, "projects": { - "apps-automated": { - "root": "apps/automated/", - "sourceRoot": "apps/automated/app", - "projectType": "application", - "prefix": "nativescript", - "architect": { - "ios": { - "builder": "@nrwl/workspace:run-commands", - "options": { - "commands": ["ns debug ios --no-hmr --emulator --env.testing"], - "cwd": "apps/automated", - "parallel": false - } - }, - "android": { - "builder": "@nrwl/workspace:run-commands", - "options": { - "commands": ["ns debug android --no-hmr --emulator --env.testing"], - "cwd": "apps/automated", - "parallel": false - } - }, - "clean": { - "builder": "@nrwl/workspace:run-commands", - "options": { - "commands": ["npx rimraf -- hooks node_modules platforms package-lock.json webpack.config.js", "npm i --legacy-peer-deps", "npx rimraf -- package-lock.json"], - "cwd": "apps/automated", - "parallel": false - } - } - } - }, - "apps-toolbox": { - "root": "apps/toolbox/", - "sourceRoot": "apps/toolbox/src", - "projectType": "application", - "prefix": "nativescript", - "architect": { - "ios": { - "builder": "@nrwl/workspace:run-commands", - "options": { - "commands": ["ns debug ios --no-hmr --emulator --env.testing"], - "cwd": "apps/toolbox", - "parallel": false - } - }, - "android": { - "builder": "@nrwl/workspace:run-commands", - "options": { - "commands": ["ns debug android --no-hmr --emulator --env.testing"], - "cwd": "apps/toolbox", - "parallel": false - } - }, - "clean": { - "builder": "@nrwl/workspace:run-commands", - "options": { - "commands": ["npx rimraf -- hooks node_modules platforms package-lock.json webpack.config.js", "npm i --legacy-peer-deps", "npx rimraf -- package-lock.json"], - "cwd": "apps/toolbox", - "parallel": false - } - } - } - }, - "apps-ui": { - "root": "apps/ui/", - "sourceRoot": "apps/ui/src", - "projectType": "application", - "prefix": "nativescript", - "architect": { - "ios": { - "builder": "@nrwl/workspace:run-commands", - "options": { - "commands": ["ns debug ios --no-hmr --emulator --env.testing"], - "cwd": "apps/ui", - "parallel": false - } - }, - "android": { - "builder": "@nrwl/workspace:run-commands", - "options": { - "commands": ["ns debug android --no-hmr --emulator --env.testing"], - "cwd": "apps/ui", - "parallel": false - } - }, - "clean": { - "builder": "@nrwl/workspace:run-commands", - "options": { - "commands": ["npx rimraf -- hooks node_modules platforms package-lock.json webpack.config.js", "npm i --legacy-peer-deps", "npx rimraf -- package-lock.json"], - "cwd": "apps/ui", - "parallel": false - } - } - } - }, - "core": { - "root": "packages/core", - "sourceRoot": "packages/core", - "projectType": "library", - "schematics": {}, - "architect": { - "lint": { - "builder": "@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": { - "builder": "@nrwl/jest:jest", - "options": { - "jestConfig": "packages/core/jest.config.js", - "passWithNoTests": true - }, - "outputs": ["coverage/packages/core"] - }, - "setup": { - "builder": "@nrwl/workspace:run-commands", - "options": { - "commands": ["nx run webpack:build"] - } - }, - "build": { - "builder": "@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": { - "builder": "@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": { - "builder": "@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 - } - } - } - }, - "core-api-docs": { - "root": "tools/scripts", - "sourceRoot": "tools/scripts", - "projectType": "library", - "schematics": {}, - "architect": { - "build": { - "builder": "@nrwl/workspace:run-commands", - "outputs": ["tools/scripts/dist"], - "options": { - "commands": ["./build-docs.sh"], - "cwd": "tools/scripts", - "parallel": false - } - } - } - }, - "types": { - "root": "packages/types", - "sourceRoot": "packages/types", - "projectType": "library", - "schematics": {}, - "architect": { - "build": { - "builder": "@nrwl/workspace:run-commands", - "outputs": ["dist/packages"], - "options": { - "commands": ["mkdir -p ../../dist/packages/types", "cp -R * ../../dist/packages/types"], - "cwd": "packages/types", - "parallel": false - } - } - } - }, - "types-ios": { - "root": "packages/types-ios", - "sourceRoot": "packages/types-ios/src", - "projectType": "library", - "schematics": {}, - "architect": { - "build": { - "builder": "@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 - } - } - } - }, - "types-android": { - "root": "packages/types-android", - "sourceRoot": "packages/types-android/src", - "projectType": "library", - "schematics": {}, - "architect": { - "build": { - "builder": "@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 - } - } - } - }, - "ui-mobile-base": { - "root": "packages/ui-mobile-base", - "sourceRoot": "packages/ui-mobile-base", - "projectType": "library", - "schematics": {}, - "architect": { - "build": { - "builder": "@nrwl/workspace:run-commands", - "options": { - "commands": ["./build.sh", "cp -R dist/package/platforms/* ../../packages/core/platforms"], - "cwd": "packages/ui-mobile-base", - "parallel": false - } - } - } - }, - "webpack": { - "root": "packages/webpack", - "sourceRoot": "packages/webpack", - "projectType": "library", - "schematics": {}, - "architect": { - "lint": { - "builder": "@nrwl/linter:eslint", - "options": { - "lintFilePatterns": [] - } - }, - "test": { - "builder": "@nrwl/workspace:run-commands", - "options": { - "commands": ["npm run tsc", "npm run jasmine"], - "cwd": "packages/webpack", - "parallel": false - } - }, - "build": { - "builder": "@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 - } - } - } - }, - "webpack5": { - "root": "packages/webpack5", - "sourceRoot": "packages/webpack5", - "projectType": "library", - "schematics": {}, - "architect": { - "lint": { - "builder": "@nrwl/linter:eslint", - "options": { - "lintFilePatterns": [] - } - }, - "build": { - "builder": "@nrwl/workspace:run-commands", - "outputs": ["dist/packages"], - "options": { - "commands": ["npm run build"], - "cwd": "packages/webpack5", - "parallel": false - } - } - } - } - }, - "cli": { - "defaultCollection": "@nrwl/workspace" - }, - "schematics": { - "@nrwl/workspace": { - "library": { - "linter": "eslint" - } - }, - "@nrwl/cypress": { - "cypress-project": { - "linter": "eslint" - } - }, - "@nrwl/react": { - "application": { - "linter": "eslint" - }, - "library": { - "linter": "eslint" - } - }, - "@nrwl/next": { - "application": { - "linter": "eslint" - } - }, - "@nrwl/web": { - "application": { - "linter": "eslint" - } - }, - "@nrwl/node": { - "application": { - "linter": "eslint" - }, - "library": { - "linter": "eslint" - } - }, - "@nrwl/nx-plugin": { - "plugin": { - "linter": "eslint" - } - }, - "@nrwl/nest": { - "application": { - "linter": "eslint" - } - }, - "@nrwl/express": { - "application": { - "linter": "eslint" - }, - "library": { - "linter": "eslint" - } - } + "apps-automated": "apps/automated", + "apps-toolbox": "apps/toolbox", + "apps-ui": "apps/ui", + "core": "packages/core", + "core-api-docs": "tools/scripts", + "types": "packages/types", + "types-android": "packages/types-android", + "types-ios": "packages/types-ios", + "ui-mobile-base": "packages/ui-mobile-base", + "webpack": "packages/webpack", + "webpack5": "packages/webpack5" } }