Skip to content

Cannot link tns-core-modules in Angular app #7905

@manoldonev

Description

@manoldonev

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 git@github.com: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 android

Expected 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-declarations packages to the app. The errors that the ng compiler producers are with types and exports. I suspect these still happen in the regular ts-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-modules have 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-declarations as 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions