moribvndvs / ng2-idle

Responding to idle users in Angular (not AngularJS) applications.
https://moribvndvs.github.io/ng2-idle
Apache License 2.0
315 stars 128 forks source link

import 'zone.js' which may cause duplicate #99

Closed vincent-cm closed 6 years ago

vincent-cm commented 6 years ago

After installing the 6.0.0-beta.1 The AoT build will throw an error at runtime:

Uncaught Error: Zone already loaded.

As ./modules/core/src/interruptsource.ts has zone.js imported which I think it is not necessary

sherlock1982 commented 6 years ago

Well Zone should be loaded prior Angular. So every user should do it for himself before. IMHO no other components should reference Zone directly.

jtcrowson commented 6 years ago

Getting the same error after install 6.0.0-beta.1

● Test suite failed to run

    Zone already loaded.

      at node_modules/zone.js/dist/zone-node.js:32:15
      at node_modules/zone.js/dist/zone-node.js:644:3
      at Object.<anonymous>.FUNCTION (node_modules/zone.js/dist/zone-node.js:9:65)
      at Object.<anonymous> (node_modules/zone.js/dist/zone-node.js:12:2)
      at node_modules/@ng-idle/core/bundles/core.umd.js:2:155
      at Object.<anonymous> (node_modules/@ng-idle/core/bundles/core.umd.js:5:2)
      at Object.<anonymous> (src/app/auth/services/activity-monitor.service.spec.ts:5:14)
          at Generator.next (<anonymous>)
          at new Promise (<anonymous>)
          at Generator.next (<anonymous>)
richie50 commented 6 years ago

@jtcrowson having this same issue. any quick fixes

vincent-cm commented 6 years ago

@richie50 try to comment out all the import 'zone.js' from the source

richie50 commented 6 years ago

@vincent-cm when i comment out zone js from my package.json my app doesn't load at all. I get zone js cannot be found. Did you experience that?

vincent-cm commented 6 years ago

@richie50 I mean the source code from ./node_modules/ng2-idle/ but not recommend, better to download the ng2-idle source and insert into your own project.

richie50 commented 6 years ago

@vincent-cm thanks will do 👍

jtcrowson commented 6 years ago

Appreciate the workaround, but of course, don't want to commit my node_modules to source control. @HackedByChinese is this workaround in consideration for implementation?

sherlock1982 commented 6 years ago

I used patch-package for it. It's amazing for doing small patches in published libs.

jtcrowson commented 6 years ago

Good call @sherlock1982. Thanks!!

richie50 commented 6 years ago

I have a fix. i will be submitting a pull request soon. Works with angular 6.0.3. Pull request submitted please review @sherlock1982 @vincent-cm @jtcrowson @HackedByChinese