shlomiassaf / ngx-modialog

Modal / Dialog for Angular
http://shlomiassaf.github.io/ngx-modialog
MIT License
686 stars 242 forks source link

Build AoT is not working with Could not resolve ngx-modialog/plugins/bootstrap with latest Angular 4 version #400

Closed almothafar closed 6 years ago

almothafar commented 6 years ago

IMPORTANT: Please provide a sample using: http://plnkr.co/edit/lV7zsw7Yqossgs9JOfQU?p=preview

Simply: Install ngx-modialog to angular project and try to build it with AoT, try use this starter:

  1. https://github.com/AngularClass/angular-starter then run npm install
  2. npm install ngx-modialog --save
  3. try to run npm run build:aot:prod.
Starting compilation using the angular compiler.
Angular compilation done, starting webpack bundling.
Error: Error encountered resolving symbol values statically. Could not resolve ngx-modialog/plugins/bootstrap relative to D:/Sources/xxxxxxxxxx/providers.ts.,
achimha commented 6 years ago

This is caused by TypeScript 2.5.3. If you go back to 2.5.1, it will work.

I am not sure what the actual cause is.

almothafar commented 6 years ago

@achimha wow thanks, you saved my day, really It is worked, I rolled back to 2.5.2 and worked.

achimha commented 6 years ago

Now find out why please :smile: I have had an half eye on the Typescript issue tracker but not seen anything that would point to a bug there.

mpeguero commented 6 years ago

go back to Typescript 2.5.1 solved the problem to me, thanks achimba

almothafar commented 6 years ago

@achimha If I were now I would be opened this for Typescript 🔨

achimha commented 6 years ago

I've run into this issue again, this time I don't find an easy solution. Going back to TypeScript 2.5.2 or even the officially supported 2.3.4 does not cure it. Difference is that I used yarn to get the dependencies.

Something wrong here... Angular 4.4.6, Node 8.8.0.

shlomiassaf commented 6 years ago

I'm overloaded with fixes and adaption to the new compiler in angular 5

Lots of my libs will not compile due to the change and how I create libraries. So if someone can dig deep here it will be great!

Thanks

shlomiassaf commented 6 years ago

Hi,

There is a new version, 5, that matches angular 5.

Can you try the new version and update if this persists?

Also, while working on version 5 i've noticed that it is important to use the supported TS version and not a greater one, this is mandatory when compiling libraries but I guess some edge cases will also pop up on app bundling.

achimha commented 6 years ago

Angular 5.1.2 and angular-cli 1.6.2 default to typescript 2.5.x which is 2.5.3 as of today. This means that we run into this error. With typescript 2.5.1 I run into another build error.

With typescript 2.6.2, there are no compilation errors but it is not supported.

neoncube2 commented 6 years ago

@achimha, If I use TypeScript 2.5.3 with Angular CLI 5.1.2, I get the error @angular/compiler-cli@5.1.2 requires typescript@'>=2.4.2 <2.5.0' but 2.5.3 was found instead.

Are you sure that TypeScript 2.5.3 is supported with Angular 5.2.1?

neoncube2 commented 6 years ago

Update Using Angular 5.1.2 and TypeScript 2.5.3, I'm able to compile with --aot.

However, I get this runtime error on the page that's supposed to have Modal injected into my constructor:

core.js:1427 ERROR Error: Uncaught (in promise): Error: StaticInjectorError[OverlayRenderer]: 
  StaticInjectorError[OverlayRenderer]: 
    NullInjectorError: No provider for OverlayRenderer!
Error: StaticInjectorError[OverlayRenderer]: 
  StaticInjectorError[OverlayRenderer]: 
    NullInjectorError: No provider for OverlayRenderer!
    at _NullInjector.webpackJsonp.../../../core/esm5/core.js._NullInjector.get (core.js:993)
    at resolveToken (core.js:1281)
    at tryResolveToken (core.js:1223)
    at StaticInjector.webpackJsonp.../../../core/esm5/core.js.StaticInjector.get (core.js:1094)
    at resolveToken (core.js:1281)
    at tryResolveToken (core.js:1223)
    at StaticInjector.webpackJsonp.../../../core/esm5/core.js.StaticInjector.get (core.js:1094)
    at resolveNgModuleDep (core.js:10878)
    at _createClass (core.js:10917)
    at _createProviderInstance$1 (core.js:10889)
    at _NullInjector.webpackJsonp.../../../core/esm5/core.js._NullInjector.get (core.js:993)
    at resolveToken (core.js:1281)
    at tryResolveToken (core.js:1223)
    at StaticInjector.webpackJsonp.../../../core/esm5/core.js.StaticInjector.get (core.js:1094)
    at resolveToken (core.js:1281)
    at tryResolveToken (core.js:1223)
    at StaticInjector.webpackJsonp.../../../core/esm5/core.js.StaticInjector.get (core.js:1094)
    at resolveNgModuleDep (core.js:10878)
    at _createClass (core.js:10917)
    at _createProviderInstance$1 (core.js:10889)
    at resolvePromise (zone.js:824)
    at resolvePromise (zone.js:795)
    at zone.js:873
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:425)
    at Object.onInvokeTask (core.js:4744)
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:424)
    at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask (zone.js:192)
    at drainMicroTaskQueue (zone.js:602)
    at ZoneTask.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (zone.js:503)
    at invokeTask (zone.js:1540)
defaultErrorLogger @ core.js:1427
webpackJsonp.../../../core/esm5/core.js.ErrorHandler.handleError @ core.js:1488
next @ core.js:5498
schedulerFn @ core.js:4339
webpackJsonp.../../../../rxjs/_esm5/Subscriber.js.SafeSubscriber.__tryOrUnsub @ Subscriber.js:240
webpackJsonp.../../../../rxjs/_esm5/Subscriber.js.SafeSubscriber.next @ Subscriber.js:187
webpackJsonp.../../../../rxjs/_esm5/Subscriber.js.Subscriber._next @ Subscriber.js:128
webpackJsonp.../../../../rxjs/_esm5/Subscriber.js.Subscriber.next @ Subscriber.js:92
webpackJsonp.../../../../rxjs/_esm5/Subject.js.Subject.next @ Subject.js:56
webpackJsonp.../../../core/esm5/core.js.EventEmitter.emit @ core.js:4319
(anonymous) @ core.js:4775
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:392
webpackJsonp.../../../../zone.js/dist/zone.js.Zone.run @ zone.js:142
webpackJsonp.../../../core/esm5/core.js.NgZone.runOutsideAngular @ core.js:4701
onHandleError @ core.js:4775
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.handleError @ zone.js:396
webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runGuarded @ zone.js:158
_loop_1 @ zone.js:702
api.microtaskDrainDone @ zone.js:711
drainMicroTaskQueue @ zone.js:610
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneTask.invokeTask @ zone.js:503
invokeTask @ zone.js:1540
globalZoneAwareCallback @ zone.js:1566
XMLHttpRequest.send (async)
scheduleTask @ zone.js:2933
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.scheduleTask @ zone.js:411
onScheduleTask @ zone.js:301
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.scheduleTask @ zone.js:405
webpackJsonp.../../../../zone.js/dist/zone.js.Zone.scheduleTask @ zone.js:236
webpackJsonp.../../../../zone.js/dist/zone.js.Zone.scheduleMacroTask @ zone.js:259
(anonymous) @ zone.js:2966
proto.(anonymous function) @ zone.js:1366
(anonymous) @ http.js:2366
webpackJsonp.../../../../rxjs/_esm5/Observable.js.Observable._trySubscribe @ Observable.js:172
webpackJsonp.../../../../rxjs/_esm5/Observable.js.Observable.subscribe @ Observable.js:160
subscribeToResult @ subscribeToResult.js:23
webpackJsonp.../../../../rxjs/_esm5/operators/mergeMap.js.MergeMapSubscriber._innerSub @ mergeMap.js:138
webpackJsonp.../../../../rxjs/_esm5/operators/mergeMap.js.MergeMapSubscriber._tryNext @ mergeMap.js:135
webpackJsonp.../../../../rxjs/_esm5/operators/mergeMap.js.MergeMapSubscriber._next @ mergeMap.js:118
webpackJsonp.../../../../rxjs/_esm5/Subscriber.js.Subscriber.next @ Subscriber.js:92
webpackJsonp.../../../../rxjs/_esm5/observable/ScalarObservable.js.ScalarObservable._subscribe @ ScalarObservable.js:51
webpackJsonp.../../../../rxjs/_esm5/Observable.js.Observable._trySubscribe @ Observable.js:172
webpackJsonp.../../../../rxjs/_esm5/Observable.js.Observable.subscribe @ Observable.js:160
webpackJsonp.../../../../rxjs/_esm5/operators/mergeMap.js.MergeMapOperator.call @ mergeMap.js:92
webpackJsonp.../../../../rxjs/_esm5/Observable.js.Observable.subscribe @ Observable.js:157
webpackJsonp.../../../../rxjs/_esm5/operators/filter.js.FilterOperator.call @ filter.js:61
webpackJsonp.../../../../rxjs/_esm5/Observable.js.Observable.subscribe @ Observable.js:157
webpackJsonp.../../../../rxjs/_esm5/operators/map.js.MapOperator.call @ map.js:57
webpackJsonp.../../../../rxjs/_esm5/Observable.js.Observable.subscribe @ Observable.js:157
webpackJsonp.../../../../../src/app/not-logged-in/index/index.component.ts.NotLoggedInIndexComponent.logIn @ index.component.ts:46
(anonymous) @ index.component.html:18
handleEvent @ core.js:13581
callWithDebugContext @ core.js:15090
debugHandleEvent @ core.js:14677
dispatchEvent @ core.js:9990
(anonymous) @ core.js:12332
schedulerFn @ core.js:4351
webpackJsonp.../../../../rxjs/_esm5/Subscriber.js.SafeSubscriber.__tryOrUnsub @ Subscriber.js:240
webpackJsonp.../../../../rxjs/_esm5/Subscriber.js.SafeSubscriber.next @ Subscriber.js:187
webpackJsonp.../../../../rxjs/_esm5/Subscriber.js.Subscriber._next @ Subscriber.js:128
webpackJsonp.../../../../rxjs/_esm5/Subscriber.js.Subscriber.next @ Subscriber.js:92
webpackJsonp.../../../../rxjs/_esm5/Subject.js.Subject.next @ Subject.js:56
webpackJsonp.../../../core/esm5/core.js.EventEmitter.emit @ core.js:4319
webpackJsonp.../../../forms/esm5/forms.js.NgForm.onSubmit @ forms.js:5751
(anonymous) @ index.component.html:18
handleEvent @ core.js:13581
callWithDebugContext @ core.js:15090
debugHandleEvent @ core.js:14677
dispatchEvent @ core.js:9990
(anonymous) @ core.js:10611
(anonymous) @ platform-browser.js:2628
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:425
onInvokeTask @ core.js:4744
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:424
webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask @ zone.js:192
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneTask.invokeTask @ zone.js:499
invokeTask @ zone.js:1540
globalZoneAwareCallback @ zone.js:1566
tluanga34 commented 6 years ago

Hey Guys, Instead of downgrading the typescript, I update it to the latest i.e @2.7.2 and the problem seems to disappear.