Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

External Libraries

Amin Pakseresht edited this page Oct 24, 2017 · 3 revisions

Note: This feature is experimental

This happens often that libraries such as lodash or any other node modules are being used to facilitate the process of development. You have two choices to deal with external libraries/modules:

  1. You make these libs/modules dependencies and they must be imported along with your library once they are being consumed by an app. Currently bundler using an algorithm to automatically find these external modules inside of your library's source code. And you don't need to do anything, but in case that something went wrong you can define them explicitly for bundler.
    Create a new section called externalModules in bundlerOptions and define them manually as following example:

    {
      "bundlerOptions": {
        ...
        "externalModules": {
          "angular2-jwt": "angular2JWT",
          "lodash": "_"
        }
      }
    }

    Note: Since v0.1.0 this is the default behaviour and all imported node modules are treated as external.
    Info: The key (for example lodash) is the name of module and the value (in this example underscore -> _) is the name used to define the module in CommonJS build that will be included only for UMD bundles.

  2. You want to include their source with your code and ship them all together.
    Set false to externalModules to include all imported node modules. Bundler will import all these libs/modules and include them all in your library output bundle:

    {
      "bundlerOptions": {
        ...
        "externalModules": false
      }
    }

    Or in case you want to pick set false only to those that you want to ship them with your library

    {
      "bundlerOptions": {
        ...
        "externalModules": {
          "lodash": false // Only lodash will be included
        }
      }
    }

    Important note: This feature won't work well with CommonJs modules. In case that you faced an error message saying a specific element is not exported by a module you may defined them based on Rollup CommonJs plugin as following example:

    {
      "bundlerOptions": {
        ...
        "externalModules": false,
        "commonJsSettings": {
          "namedExports": {
            "lodash": ["chain", "merge"]
          }
        }
      }
    }
Clone this wiki locally