Repository navigation
Cannot link tns-core-modules in Angular app #7905
Description
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: 6.1.2
- Cross-platform modules: 6.1.1
- Android Runtime: 6.1.2
- iOS Runtime: 6.1.1
Describe the bug
When trying to contribute to tns-core-modules and using an external NS Angular app to develop / test these contributions, the compile step fails when following the instructions currently outlined in DevelopmentWorkflow.md (Running Another App).
To Reproduce
git clone [email protected]:NativeScript/NativeScript.git
cd NativeScript
tns create blank-ng --template tns-template-blank-ng
cd blank ng
npm install ../tns-core-modules --save
tns run ios # or tns run androidExpected behavior
Application should run successfully but instead generates the following log https://gist.github.com/rynop/5156d00932b17937cc8889f2a0581f03
Additional context
@bundyo discovered a workaround:
The problem with linking is that Angular/TS project tend to grab the linked TS files in core modules and try to compile them without the references needed. I've only managed to run it by compiling the core modules with outDir and linking that (.d.ts, package.json and other files, except TS ones should be copied over too). Maybe the team can consider moving to an outDir compilation. Another way would be dev-webpack to forbid Angular/ts-loader for traversing node_modules.
But as noted by @MartoYankov here:
@bundyo I followed the steps from "running another app" plus one additional step - adding the
tns-platform-declarationspackages to the app. The errors that the ng compiler producers are with types and exports. I suspect these still happen in the regularts-loader, but as warnings. The ng compiler is producing them as errors.The reason why we don't want to promote alternative dev setups is because we can't support them. We adhere to the dev setup in the nativescript plugin seed to make sure the
tns-core-moduleshave a similar setup to all plugins. What I mean is, we should fix the current setup or if not possible - change the dev setup in the plugin seed first.
So addressing this issue is two-fold:
- Update dev workflow to require
tns-platform-declarationsas a dev dependency in the Angular app in this scenario (alongside with a references.d.ts in the app root) - Address the remaining errors that the Angular compiler produces with types and exports
Activity
bundyo commentedon Oct 4, 2019
I only suspect that if we require tns-platform-declarations in the already bloated Angular projects, VSCode will crash and WebStorm will index several minutes while eating memory for breakfast. Been there, done that in Kinvey Studio apps... 😉
MartoYankov commentedon Oct 8, 2019
@bundyo Angular is typescript only, so you can't do platform specific code without the platform declarations anyway.
bundyo commentedon Oct 8, 2019
This is true, but they still manage to crash VSCode sometimes. 🙂
NathanaelA commentedon Oct 9, 2019
MartoYankov commentedon Oct 9, 2019
@NathanaelA Everything is possible given the need, but having types in typescript is by design. I don't think we can drop
tns-platform-declarationsin the core modules.NathanWalker commentedon Oct 23, 2026
Closing as obsolete: this covered linking
tns-core-modulesinto an Angular app withnativescript-dev-webpack. Core development now happens in the Nx monorepo with theapps/toolboxandapps/automatedapps (seetools/notes/DevelopmentWorkflow.md).