question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to configure "lib.externals" in ng-package.json ('BusyModule' is not exported)

See original GitHub issue

Type of Issue

  • Bug Report
  • Feature Request
  • Question, I guess

Description

I’m trying to create a simple angular library in which I use angular2-busy as an npm package, I import it normally and everything works when compiling my source with webpack or directly with tsc.

But I alway get the error when using ng-packagr 'BusyModule' is not exported by ..\..\node_modules\angular2-busy\index.js

the file looks like

"use strict";
function __export(m) {
    for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./build/index"));
//# sourceMappingURL=index.js.map

Since I’m fairly new to the JS-World, my question is: Can I solve this on my side or is this something ng-packagr has to solve. Or is this this something I have to bring to angular2-busy’s authors attention?

How To Reproduce

include angular2-busy as dependency and import it somewhere.

Expected Behaviour

compile it

Version Information

ng-packagr: v1.0.1
node: v8.4.0
@angular: v4.3.6

please include any version information that might be relevant, e.g. other third-party libraries

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
dhergescommented, Sep 7, 2017

These are the external and globals properties passed thru to rollup.

Rollup says for external:

  • the name of an external dependency
  • a resolved ID (like an absolute path to a file)

Globals is essentially the same but being used for the UMD bundle:

…we want to tell Rollup that the jquery module ID equates to the global $ variable:

https://rollupjs.org/#big-list-of-options

I try to re-phrase how to set the externals of ng-packagr: lib.externals is key-value pair of external dependencies of an Angular library. The key should be the import path (as used in TypeScript import {} from "" statement. The value should be the module ID for the UMD bundle. In rxjs, this is Rx.Classname or the Rx.Classname.prototype. In @angular packages, this is the token that they have configured in their build chain.

3reactions
dhergescommented, Sep 7, 2017

Do you have externals set in ng-package.json?

{
  "$schema": "./node_modules/ng-packagr/ng-package.schema.json",
  "lib": {
    "entryFile": "public_api.ts".
    "externals": {
      /* ... *(
    }
  }
}

See https://github.com/dherges/ng-packagr/issues/85#issuecomment-321256775

We should have better documentation in ng-packagr for this… Oo

Read more comments on GitHub >

github_iconTop Results From Across the Web

ng-package.json Data path ".lib" should NOT have additional ...
I am updated my npm package from angular 7.2 to angular 8.2, the problem I have now in my ng-package.json is that Property...
Read more >
Build an Angular Library With NgPackagr - Fireship
Inside this the lib folder create the following elements. src/ source code; package.json package definition; public_api.ts to export your ...
Read more >
ng-packagr - npm
Create one package.json per npm package, run ng-packagr for each! ... of a library are treated as external dependencies and thus are not...
Read more >
Extract an Angular Module into a separate library with ng ...
They group together a set of logically connected code which can be imported and used by other modules within an Angular application.
Read more >
ng-packagr/ng-package.schema.json - UNPKG
5, "description": "JSON Schema for `ng-package.json` description file", ... Read the NPM Blog on 'Package install scripts vulnerability' ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found