Skip to content
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

not AoT compatible? (no exported member 'IDLE_PROVIDERS') #22

Closed
sublime392 opened this issue Oct 14, 2016 · 7 comments
Closed

not AoT compatible? (no exported member 'IDLE_PROVIDERS') #22

sublime392 opened this issue Oct 14, 2016 · 7 comments

Comments

@sublime392
Copy link

Hi this works fine in dev mode and regular peoduction mode but AoT does not compile. It gives node_modules/ng2-idle/core"' has no exported member 'IDLE_PROVIDERS'. and node_modules/ng2-idle-keepalive/core"' has no exported member 'KEEPALIVE_PROVIDERS'

This is with angular 2.1.0

@sublime392
Copy link
Author

I got it working following an answer in another issue here.
I made an idle.hack.ts file with

import { Injectable } from '@angular/core';
import { Idle, SimpleExpiry } from 'ng2-idle/core';

@Injectable()
export class PalIdle extends Idle {
    constructor(expiry: SimpleExpiry) {
        super(expiry, undefined);
    }
}

and then in my app.module

import { SimpleExpiry, IdleExpiry } from 'ng2-idle/core';
import { PalIdle } from './idle.hack';
...
providers: [
    PalIdle,
    SimpleExpiry,
    { provide: IdleExpiry, useExisting: SimpleExpiry },
  ],
...

and finally injecting the new class where needed

constructor(
    private idle: PalIdle,
  ) {}

@spicywhitefish
Copy link

I also had difficulty with the "Optional" Keepalive provider.

export const ALL_IDLE_PROVIDERS = [
    LocalExpiry,
    {provide: IdleExpiry, useExisting: LocalExpiry},
    // The following hack is required to avoid DI errors
    {provide: KeepaliveSvc, useValue: undefined},
    Idle
];

Maybe the JS in the current release is compiled incorrectly?

@mdsauer
Copy link

mdsauer commented Oct 18, 2016

I am having the same issue but the fix above is not working for me. I am getting 'SimpleExpiry' is not exported by node_modules\ng2-idle\core.js (imported by app\app.module.js)'
I should mention that I am getting this error while executing rollup so I am facing this issue at another point in my build process.

@Tiuser4567
Copy link

@mdsauer can you try import { SimpleExpiry } from 'ng2-idle/simpleexpiry';

@mdsauer
Copy link

mdsauer commented Oct 24, 2016

@Tiuser4567 That worked!
I changed my idle.hack.ts to:

    import { Injectable } from '@angular/core';
    import { Idle } from 'ng2-idle/idle';
    import { SimpleExpiry } from 'ng2-idle/simpleexpiry';
    @Injectable()
    export class PalIdle extends Idle {
        constructor(expiry: SimpleExpiry) {
          super(expiry, undefined);
        }
    }

I made similar changes to my app.module.ts:

import { SimpleExpiry } from 'ng2-idle/simpleexpiry';
import { IdleExpiry } from 'ng2-idle/idleexpiry';

I then also added ng2-idle to the commonjs rollup plugin:

        include: [
          'node_modules/rxjs/**',
          'node_modules/angular-in-memory-web-api/**',
          'node_modules/ng2-idle/**'
          ],

Thanks for the help!

@mdsauer
Copy link

mdsauer commented Oct 25, 2016

@dasis You are able to do the AOT compile? I am still getting Error: Error at .../aot/app/app.module.ngfactory.ts:72:32: Module '".../node_modules/ng2-idle/core"' has no exported member 'IDLE_PROVIDERS'. Are you doing anything special regarding ng2-idle in you systemjs.config.js or anywhere else?

@TheSniper102
Copy link

grbsk added a commit that referenced this issue Nov 4, 2016
This commit adds support for NgModule and replaces the old ng2-idle/core approach. Use
Ng2IdleModule.forRoot() in your app module imports to use the new module.

Fixes #3, #10, #22, #23, #24
@grbsk grbsk closed this as completed Nov 4, 2016
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

6 participants