Could not resolve js when building Angular library

Viewed 40

The general task is to wrap up some third party UMD libraries in an Angular library and enhance them with strong typing.

I want to save the user of the library from having to manually add the UMD libraries in his project and include them by <script> tag for example.

Consider the following example project:

project structure

tsconfig.lib.json:

  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "outDir": "../../out-tsc/lib",
    "allowJs": true,
    "declaration": true,
    "declarationMap": true,
    "inlineSources": true,
    "types": []
  },
  "exclude": [
    "src/test.ts",
    "**/*.spec.ts"
  ]
}

test-lib.service.ts:

import { Injectable } from '@angular/core';
import * as extLib from './external/externalLib';

@Injectable({
  providedIn: 'root'
})
export class TestLibService {
  private n: string = '';

  constructor() { }

  getStringFromNumber(n: number) {
    this.n = extLib.getString(n);
  }
}

When executing ng build I get the following error: error

What am I missing?

0 Answers
Related