NativeScript / nativescript-angular

Integrating NativeScript with Angular
http://docs.nativescript.org/angular/tutorial/ng-chapter-0
Apache License 2.0
1.21k stars 241 forks source link

Creating a sample app with AoT enabled - can't find 3rd party plugins. #655

Closed dxshindeo closed 7 years ago

dxshindeo commented 7 years ago

Trying to create a sample app with AoT enabled. It works, if I don't add 3rd party plugins, but fails, when I add something trivial:

  1. tns create test --ng
  2. tns plugin add nativescript-vibrate

In docs(http://docs.nativescript.org/angular/tooling/bundling-with-webpack.html) NS says, that one would specify the plugin upon app bootstraping like so:

// app.module.ts
..

require("globals");
global.registerModule("nativescript-vibrate", function() { return require("nativescript-vibrate"); });

@NgModule({
...

However, getting error:

ERROR in ./app.module.ts
Module not found: Error: Can't resolve 'nativescript-vibrate' in 'C:\projects\test\app'
 @ ./app.module.ts 16:67-98
 @ ./app.module.ngfactory.ts
 @ ./main.aot.ts

What am I doing wrong?

hdeshev commented 7 years ago

It seems nativescript-vibrate needs to be updated in order to be resolvable by webpack. Its package.json/main field needs to drop the .js suffix:

http://docs.nativescript.org/angular/tooling/bundling-with-webpack.html#recommendations-for-plugin-authors

patrickpereira commented 7 years ago

The same issue is happening to me trying to add 'nativescript-taptic-engine', which has been updated the way the docs show.

Any clue what might be causing that?

PS. I'm using lazyloaded modules in my app.