Skip to content

Dependency on tns-core-modules #2102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dmytro-gokun opened this issue Dec 26, 2019 · 8 comments
Closed

Dependency on tns-core-modules #2102

dmytro-gokun opened this issue Dec 26, 2019 · 8 comments

Comments

@dmytro-gokun
Copy link

@nativescript/angular 8.20.3 has dependency on tns-core-modules. Is not it supposed to depend only on the scoped package (@nativescript/core)?

The compilation error is:

ERROR in @nativescript/angular/common.ts(26,9): Error during template compile of 'NativeScriptCommonModule'
  Could not resolve tns-core-modules/ui/frame relative to [object Object]. in 'defaultFrameProvider'
    'defaultFrameProvider' contains the error at @nativescript/angular/platform-providers.ts(44,48).
@NickIliev
Copy link

@dmytro-gokun for backward compatibility the latest tns-core-modules are re-exporting the scoped packages. So that said the scoped Angular package should work as expected with both the scoped modules and the compatibility package (which is also using the scoped package).

Can you provide more information about your project like the content of your package.json file.

@dmytro-gokun
Copy link
Author

@NickIliev You are absolutely right that "the scoped Angular package should work as expected with both the scoped modules and the compatibility package". But my understanding is that it should not require both. If I already have "@nativescript/core" in my package.json, it should not require me to have "tns-core-modules" as well. But it does exactly that. As soon as i remove ""tns-core-modules" from package.json, i'm getting the error above.

The easiest way to reproduce is to create a new Angular app using Nativescript CLI and change package.json to use scoped packages instead of 'classic' ones (and repalce 'nativescript-angular' imports with '@nativescript/angular').

So

    "@nativescript/core": "~6.3.0",
    "@nativescript/angular": "~8.20.3",

instead of

    "tns-core-modules": "~6.3.0",
    "nativescript-angular": "~8.20.3",

If you then attempt to build the app, you will get the error above. Plz check the attached zip file for the reproduction project.

reproduction.zip

@NickIliev
Copy link

@dmytro-gokun thanks for the clarification - indeed I can confirm that the behavior is not expected so marking the issue as a big. Probably related to this one as well.

@NickIliev
Copy link

@dmytro-gokun on second thought the issue you are dealing with should be resolved. I've tested the provided project on my side (with the latest CLI) and the project is building as expected (with tns run android).

However,, you had some scoped imports that needed to be fixed in your project.

For example:

app.module.ts

// WRONG import
import { NativeScriptModule } from "@nativescript/angular;

Should become

// OK
import { NativeScriptModule } from "@nativescript/angular/nativescript.module";

and in main.ts

// WRONG IMPORT
import { platformNativeScriptDynamic } from "@nativescript/angular";

should become

import { platformNativeScriptDynamic } from "@nativescript/angular/platform";

@NickIliev NickIliev removed the bug label Dec 27, 2019
@dmytro-gokun
Copy link
Author

@NickIliev

and the project is building as expected (with tns run android).

Try actually building it and not just running.

However,, you had some scoped imports that needed to be fixed in your project.

Well, you know better, that's true. But i thought that one of the objectives of scoped modules was that you did not have to drill down into the package's guts in order to import things. Am I wrong?

Also, if importing stuff from "@nativescript/angular" is incorrect, it should not compile telling there is no such symbol to import. Otherwise, this will confuse users and produce lots of questions like this one.

@NickIliev NickIliev reopened this Dec 28, 2019
@lini
Copy link
Contributor

lini commented Jan 7, 2020

Please try updating your nativescript-dev-webpack dependency to the latest version (1.4.1 at the time of writing this comment) and see if it fixes the app compilation.

@dmytro-gokun
Copy link
Author

@lini That's helped. Thanks!

@asciidiego
Copy link

I have the same issue on [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants