5

With lots of help from this excellent article by Nikolas LeBlanc, I'm trying to create an Angular 4 component library:

https://medium.com/@nikolasleblanc/building-an-angular-4-component-library-with-the-angular-cli-and-ng-packagr-53b2ade0701e

The problem is this... my library depends on an external JavaScript file - let's call that somefunctions.js.

In a regular Angular 4 application - I've been able to do this by referencing the file in the angular-cli.json file:

  "scripts": [
      "./app/js/somefunctions.js"
  ],

... then declare the variables as type any in the typings.d.ts file.

This makes the JavaScript file available to the application, and it works just fine.

However - my goal is to create an Angular 4 component library, and package/publish it to npm.

When I follow the instructions for creating the library - the feature module is packaged without somefunctions.js.

So - if someone else installs my module, they won't have somefunctions.js, and it obviously won't work.

So, I guess I need to know how to tell ng-packagr to bundle the module so that it includes somefunctions.js, and how to set up my module so that my code can reference that file when the module is installed in other applications.

Thanks in advance!

Eduardo Yáñez Parareda
  • 9,126
  • 4
  • 37
  • 50
mattstuehler
  • 9,040
  • 18
  • 78
  • 108

0 Answers0