Skip to content

tns preview --bundle doesn't work with ActionBar in Angular projects #3997

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
sebawita opened this issue Oct 9, 2018 · 1 comment · Fixed by NativeScript/nativescript-schematics#127

Comments

@sebawita
Copy link

sebawita commented Oct 9, 2018

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):

✔ Component nativescript has 5.0.0-2018-10-08-12421 version and is up to date.
✔ Component tns-core-modules has 4.2.1 version and is up to date.
✔ Component tns-android has 4.2.0 version and is up to date.
✔ Component tns-ios has 4.2.0 version and is up to date.

Describe the bug
tns preview --bundle breaks in Angular Projects with an error message: ERROR Error: Uncaught (in promise): Error: ActionBar(1) is not a valid View instance.

To Reproduce
I've only tested this on Android.

tns create test --ng
cd test
npm i -D nativescript-dev-webpack@next
tns preview --bundle

However, when I run tns run android --bundle or tns preview, the project runs correctly.

@sis0k0
Copy link
Contributor

sis0k0 commented Oct 9, 2018

The problem is that there are two instances of tns-core-modules - one external, in node_modules and one in vendor.js. We cannot get rid of the external one because it is part of the Preview app by default. To make sure we don't end up with embedded ones, we mark all imports from tns-core-modules as external in the webpack configuration. However, this won't work for any short imports, such as ui/action-bar. That's why all plugins should be migrated to use full imports, such as tns-core-modules/ui/action-bar. This PR in nativescript-angular resolves the problem with the hello-world template - NativeScript/nativescript-angular#1550.

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