angularsystemjsangular2-aot

AOT build trying to import from @types instead of actual module


When trying to add a service from the auth0-js package to the DI container the build attempts to load the index.js file from the node_modules/@types/auth0-js/index.js directory instead of node_modules/auth0-js/index.js.

[21:50:57] 'build.bundles.app.aot' errored after 784 ms
[21:50:57] Error on fetch for @types/auth0-js/index.js at file:///Users/llwt/src/testing/angular-seed-advanced/node_modules/@types/auth0-js/index.js
    Loading dist/tmp/web.module.ngfactory.js
    Loading dist/tmp/main.web.prod.js
    Error: ENOENT: no such file or directory, open '/Users/llwt/src/testing/angular-seed-advanced/node_modules/@types/auth0-js/index.js'
    at Error (native)

I feel like I must be missing something basic here. I've reproduced the issue in a fork of the Angular-Advanced-Seed by Nathan walker which can be found here.

The package is being imported like so:

import { WebAuth } from 'auth0-js';
// ...
export function authHttp() {
  return new WebAuth({
    domain: 'foo',
    clientID: 'bar',
  });
}
// ...
@NgModule({
//...
  providers: [
    { provide: WebAuth, useFactory: (authHttp) },
    // ...

Let me know if there is any more specific info I can provide to help debug this.


Solution

  • For anyone stumbling across this in the future, it turned out that there was an error in the type definition of the auth0-js library that was causing the build to fail.

    Edit: For anyone looking at this now. The issue is still there and being tracked in this Definitely Typed issue.