angular-library-starter icon indicating copy to clipboard operation
angular-library-starter copied to clipboard

Add @angular-redux library in npm package

Open Miguelkode opened this issue 7 years ago • 1 comments

Note: for support questions, please use one of these channels: Chat: AngularClass.slack or Twitter: @AngularClass

  • I'm submitting a ... [ ] bug report [ ] feature request [ X ] question about the decisions made in the repository

We have a component, which uses "rxjs". We are trying to add this Angular library in the build_hooks.js file to construct the npm package using "npm run lib:build". But we obtain the next error:

Error: 'Observable' is not exported by node_modules/rxjs/Observable.js

We do not know if this the way to add this library. Can you help us?

Thank you so much.

Miguelkode avatar Oct 06 '17 12:10 Miguelkode

Not exactly sure this is right but:

build_hooks.js (at the package level, not root. Mine's at @my-scope/myModule/build_hooks.js)

const globals = {
    'rxjs/Observable': 'Observable'
};

module.exports.rollupFESM = function (config) {
    if (config.external) {
        config.external = config.external.concat(Object.keys(globals));
    } else {
        config.external = Object.keys(globals);
    }
};

module.exports.rollupUMD = function (config) {
    if (config.external) {
        config.external = config.external.concat(Object.keys(globals));
    } else {
        config.external = Object.keys(globals);
    }

    config.globals = Object.assign(config.globals || {}, globals);
};

It seems to work for me so far. I'm using rxjs/Subject and ng2-toastr/ToastModule in mine and I've gotten them up and running.

mcaden avatar Dec 01 '17 08:12 mcaden