-
Notifications
You must be signed in to change notification settings - Fork 1
External Libraries
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:
-
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 calledexternalModules
inbundlerOptions
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 examplelodash
) 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. -
You want to include their source with your code and ship them all together.
Setfalse
toexternalModules
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"] } } } }