gonzofish / angular-librarian

An Angular 2+ scaffolding setup for creating libraries
https://www.npmjs.com/package/angular-librarian
MIT License
91 stars 9 forks source link

[Migration] Rollup bundling fails with: Cannot read property 'slice' of undefined #89

Closed tommueller closed 6 years ago

tommueller commented 6 years ago

As I mentioned here I ran into another bug after fixing the node-version problem https://github.com/gonzofish/angular-librarian/issues/88#issuecomment-356261787

The build fails now when rollup is executed with:

Generating bundles via rollup
[Librarian]: > Build failed

TypeError: Cannot read property 'slice' of undefined
    at startsWith (/home/tom/workspace-angular/ng-core/node_modules/rollup-plugin-commonjs/dist/rollup-plugin-commonjs.cjs.js:612:13)
    at resolveId (/home/tom/workspace-angular/ng-core/node_modules/rollup-plugin-commonjs/dist/rollup-plugin-commonjs.cjs.js:653:23)
    at Object.options (/home/tom/workspace-angular/ng-core/node_modules/rollup-plugin-commonjs/dist/rollup-plugin-commonjs.cjs.js:711:27)
    at Bundle$$1.options.plugins.reduce (/home/tom/workspace-angular/ng-core/node_modules/rollup/dist/rollup.js:17905:42)
    at Array.reduce (<anonymous>)
    at new Bundle$$1 (/home/tom/workspace-angular/ng-core/node_modules/rollup/dist/rollup.js:17904:26)
    at Object.rollup (/home/tom/workspace-angular/ng-core/node_modules/rollup/dist/rollup.js:18720:18)
    at bundles.map.config (/home/tom/workspace-angular/ng-core/tasks/rollup.js:73:16)
    at Array.map (<anonymous>)
    at doRollup (/home/tom/workspace-angular/ng-core/tasks/rollup.js:72:7)
gonzofish commented 6 years ago

On line 73 rollup.rollup(config) is called--what does config look like when you run build?

tommueller commented 6 years ago

Ok, I fixed the error accidentally by changing the code to log the config ... adding curly braces around the rollup.rollup(config)-call fixed it ...

    const bundles = [
        fesm2015Config,
        fesm5Config,
        minUmdConfig,
        umdConfig
    ].map(config =>{
        console.log(config)
        rollup.rollup(config)
            .then(bundle => bundle.write({
                file: config.output.file,
                format: config.output.format,
                ...config
            }))}
        );

edit: sorry was on wrong branch, but still the error got fixed like this

Now I only get some warnings:

[Librarian]: (node:23287) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 5): TypeError: Cannot read property 'slice' of undefined
(node:23287) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:23287) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 6): TypeError: Cannot read property 'slice' of undefined
(node:23287) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 7): TypeError: Cannot read property 'slice' of undefined
(node:23287) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 8): TypeError: Cannot read property 'slice' of undefined

And this is the output of the config:

{ input: '/home/tom/workspace-angular/ng-core/out-tsc/lib-es5/ng-core.js',
  external:
   [ '@angular/animations',
     '@angular/core',
     '@angular/common',
     '@angular/common/http',
     '@angular/forms',
     '@angular/http',
     '@angular/platform-browser',
     '@angular/platform-browser-dynamic',
     '@angular/platform-browser/animations',
     '@angular/router',
     'rxjs/AnonymousSubject',
     'rxjs/AsyncSubject',
     'rxjs/BehaviorSubject',
     'rxjs/Notifiction',
     'rxjs/ObservableInput',
     'rxjs/Observable',
     'rxjs/Observer',
     'rxjs/ReplaySubject',
     'rxjs/Scheduler',
     'rxjs/Subject',
     'rxjs/SubjectSubscriber',
     'rxjs/SubscribableOrPromise',
     'rxjs/Subscriber',
     'rxjs/Subscription',
     'rxjs/TeardownLogic',
     'rxjs/add/observable/bindCallback',
     'rxjs/add/observable/bindNodeCallback',
     'rxjs/add/observable/combineLatest',
     'rxjs/add/observable/concat',
     'rxjs/add/observable/create',
     'rxjs/add/observable/defer',
     'rxjs/add/observable/empty',
     'rxjs/add/observable/forkJoin',
     'rxjs/add/observable/from',
     'rxjs/add/observable/fromEvent',
     'rxjs/add/observable/fromEventPattern',
     'rxjs/add/observable/fromPromise',
     'rxjs/add/observable/interval',
     'rxjs/add/observable/merge',
     'rxjs/add/observable/never',
     'rxjs/add/observable/of',
     'rxjs/add/observable/range',
     'rxjs/add/observable/throw',
     'rxjs/add/observable/timer',
     'rxjs/add/observable/webSocket',
     'rxjs/add/observable/zip',
     'rxjs/add/operator/audit',
     'rxjs/add/operator/auditTime',
     'rxjs/add/operator/buffer',
     'rxjs/add/operator/bufferCount',
     'rxjs/add/operator/bufferTime',
     'rxjs/add/operator/bufferToggle',
     'rxjs/add/operator/bufferWhen',
     'rxjs/add/operator/catch',
     'rxjs/add/operator/combineAll',
     'rxjs/add/operator/combineLatest',
     'rxjs/add/operator/concat',
     'rxjs/add/operator/concatAll',
     'rxjs/add/operator/concatMap',
     'rxjs/add/operator/concatMapTo',
     'rxjs/add/operator/count',
     'rxjs/add/operator/debounce',
     'rxjs/add/operator/debounceTime',
     'rxjs/add/operator/defaultIfEmpty',
     'rxjs/add/operator/delay',
     'rxjs/add/operator/delayWhen',
     'rxjs/add/operator/dematerialize',
     'rxjs/add/operator/distinct',
     'rxjs/add/operator/distinctUntilChanged',
     'rxjs/add/operator/distinctUntilKeyChanged',
     'rxjs/add/operator/do',
     'rxjs/add/operator/elementAt',
     'rxjs/add/operator/every',
     'rxjs/add/operator/exhaust',
     'rxjs/add/operator/exhaustMap',
     'rxjs/add/operator/expand',
     'rxjs/add/operator/filter',
     'rxjs/add/operator/finally',
     'rxjs/add/operator/find',
     'rxjs/add/operator/findIndex',
     'rxjs/add/operator/first',
     'rxjs/add/operator/forEach',
     'rxjs/add/operator/groupBy',
     'rxjs/add/operator/ignoreElements',
     'rxjs/add/operator/isEmpty',
     'rxjs/add/operator/last',
     'rxjs/add/operator/let',
     'rxjs/add/operator/letProto',
     'rxjs/add/operator/lift',
     'rxjs/add/operator/map',
     'rxjs/add/operator/materialize',
     'rxjs/add/operator/max',
     'rxjs/add/operator/merge',
     'rxjs/add/operator/mergeAll',
     'rxjs/add/operator/mergeMap',
     'rxjs/add/operator/mergeMapTo',
     'rxjs/add/operator/mergeScan',
     'rxjs/add/operator/min',
     'rxjs/add/operator/multicast',
     'rxjs/add/operator/observeOn',
     ... 176 more items ],
  globals:
   { '@angular/animations': 'ng.animations',
     '@angular/cdk': 'ng.cdk',
     '@angular/compiler': 'ng.compiler',
     '@angular/forms': 'ng.forms',
     '@angular/http': 'ng.http',
     '@angular/material': 'ng.material',
     '@angular/platform-browser': 'ng.platformBrowser',
     '@angular/platform-browser-dynamic': 'ng.platformBrowserDynamic',
     '@angular/router': 'ng.router',
     lodash: '_',
     'stacktrace-js': 'stacktrace-js',
     '@angular/core': 'ng.core',
     '@angular/common': 'ng.common',
     '@angular/common/http': 'ng.common.http',
     '@angular/platform-browser/animations': 'ng.platformBrowser.animations',
     'rxjs/AnonymousSubject': 'Rx',
     'rxjs/AsyncSubject': 'Rx',
     'rxjs/BehaviorSubject': 'Rx',
     'rxjs/Notifiction': 'Rx',
     'rxjs/ObservableInput': 'Rx',
     'rxjs/Observable': 'Rx',
     'rxjs/Observer': 'Rx',
     'rxjs/ReplaySubject': 'Rx',
     'rxjs/Scheduler': 'Rx',
     'rxjs/Subject': 'Rx',
     'rxjs/SubjectSubscriber': 'Rx',
     'rxjs/SubscribableOrPromise': 'Rx',
     'rxjs/Subscriber': 'Rx',
     'rxjs/Subscription': 'Rx',
     'rxjs/TeardownLogic': 'Rx',
     'rxjs/add/observable/bindCallback': 'Rx.Observable',
     'rxjs/add/observable/bindNodeCallback': 'Rx.Observable',
     'rxjs/add/observable/combineLatest': 'Rx.Observable',
     'rxjs/add/observable/concat': 'Rx.Observable',
     'rxjs/add/observable/create': 'Rx.Observable',
     'rxjs/add/observable/defer': 'Rx.Observable',
     'rxjs/add/observable/empty': 'Rx.Observable',
     'rxjs/add/observable/forkJoin': 'Rx.Observable',
     'rxjs/add/observable/from': 'Rx.Observable',
     'rxjs/add/observable/fromEvent': 'Rx.Observable',
     'rxjs/add/observable/fromEventPattern': 'Rx.Observable',
     'rxjs/add/observable/fromPromise': 'Rx.Observable',
     'rxjs/add/observable/interval': 'Rx.Observable',
     'rxjs/add/observable/merge': 'Rx.Observable',
     'rxjs/add/observable/never': 'Rx.Observable',
     'rxjs/add/observable/of': 'Rx.Observable',
     'rxjs/add/observable/range': 'Rx.Observable',
     'rxjs/add/observable/throw': 'Rx.Observable',
     'rxjs/add/observable/timer': 'Rx.Observable',
     'rxjs/add/observable/webSocket': 'Rx.Observable',
     'rxjs/add/observable/zip': 'Rx.Observable',
     'rxjs/add/operator/audit': 'Rx.Observable.prototype',
     'rxjs/add/operator/auditTime': 'Rx.Observable.prototype',
     'rxjs/add/operator/buffer': 'Rx.Observable.prototype',
     'rxjs/add/operator/bufferCount': 'Rx.Observable.prototype',
     'rxjs/add/operator/bufferTime': 'Rx.Observable.prototype',
     'rxjs/add/operator/bufferToggle': 'Rx.Observable.prototype',
     'rxjs/add/operator/bufferWhen': 'Rx.Observable.prototype',
     'rxjs/add/operator/catch': 'Rx.Observable.prototype',
     'rxjs/add/operator/combineAll': 'Rx.Observable.prototype',
     'rxjs/add/operator/combineLatest': 'Rx.Observable.prototype',
     'rxjs/add/operator/concat': 'Rx.Observable.prototype',
     'rxjs/add/operator/concatAll': 'Rx.Observable.prototype',
     'rxjs/add/operator/concatMap': 'Rx.Observable.prototype',
     'rxjs/add/operator/concatMapTo': 'Rx.Observable.prototype',
     'rxjs/add/operator/count': 'Rx.Observable.prototype',
     'rxjs/add/operator/debounce': 'Rx.Observable.prototype',
     'rxjs/add/operator/debounceTime': 'Rx.Observable.prototype',
     'rxjs/add/operator/defaultIfEmpty': 'Rx.Observable.prototype',
     'rxjs/add/operator/delay': 'Rx.Observable.prototype',
     'rxjs/add/operator/delayWhen': 'Rx.Observable.prototype',
     'rxjs/add/operator/dematerialize': 'Rx.Observable.prototype',
     'rxjs/add/operator/distinct': 'Rx.Observable.prototype',
     'rxjs/add/operator/distinctUntilChanged': 'Rx.Observable.prototype',
     'rxjs/add/operator/distinctUntilKeyChanged': 'Rx.Observable.prototype',
     'rxjs/add/operator/do': 'Rx.Observable.prototype',
     'rxjs/add/operator/elementAt': 'Rx.Observable.prototype',
     'rxjs/add/operator/every': 'Rx.Observable.prototype',
     'rxjs/add/operator/exhaust': 'Rx.Observable.prototype',
     'rxjs/add/operator/exhaustMap': 'Rx.Observable.prototype',
     'rxjs/add/operator/expand': 'Rx.Observable.prototype',
     'rxjs/add/operator/filter': 'Rx.Observable.prototype',
     'rxjs/add/operator/finally': 'Rx.Observable.prototype',
     'rxjs/add/operator/find': 'Rx.Observable.prototype',
     'rxjs/add/operator/findIndex': 'Rx.Observable.prototype',
     'rxjs/add/operator/first': 'Rx.Observable.prototype',
     'rxjs/add/operator/forEach': 'Rx.Observable.prototype',
     'rxjs/add/operator/groupBy': 'Rx.Observable.prototype',
     'rxjs/add/operator/ignoreElements': 'Rx.Observable.prototype',
     'rxjs/add/operator/isEmpty': 'Rx.Observable.prototype',
     'rxjs/add/operator/last': 'Rx.Observable.prototype',
     'rxjs/add/operator/let': 'Rx.Observable.prototype',
     'rxjs/add/operator/letProto': 'Rx.Observable.prototype',
     'rxjs/add/operator/lift': 'Rx.Observable.prototype',
     'rxjs/add/operator/map': 'Rx.Observable.prototype',
     'rxjs/add/operator/materialize': 'Rx.Observable.prototype',
     'rxjs/add/operator/max': 'Rx.Observable.prototype',
     'rxjs/add/operator/merge': 'Rx.Observable.prototype',
     'rxjs/add/operator/mergeAll': 'Rx.Observable.prototype',
     'rxjs/add/operator/mergeMap': 'Rx.Observable.prototype',
     'rxjs/add/operator/mergeMapTo': 'Rx.Observable.prototype',
     'rxjs/add/operator/mergeScan': 'Rx.Observable.prototype',
     'rxjs/add/operator/min': 'Rx.Observable.prototype',
     'rxjs/add/operator/multicast': 'Rx.Observable.prototype',
     'rxjs/add/operator/observeOn': 'Rx.Observable.prototype',
     'rxjs/add/operator/pairwise': 'Rx.Observable.prototype',
     'rxjs/add/operator/partition': 'Rx.Observable.prototype',
     'rxjs/add/operator/pluck': 'Rx.Observable.prototype',
     'rxjs/add/operator/publish': 'Rx.Observable.prototype',
     'rxjs/add/operator/publishBehavior': 'Rx.Observable.prototype',
     'rxjs/add/operator/publishLast': 'Rx.Observable.prototype',
     'rxjs/add/operator/publishReplay': 'Rx.Observable.prototype',
     'rxjs/add/operator/race': 'Rx.Observable.prototype',
     'rxjs/add/operator/reduce': 'Rx.Observable.prototype',
     'rxjs/add/operator/repeat': 'Rx.Observable.prototype',
     'rxjs/add/operator/repeatWhen': 'Rx.Observable.prototype',
     'rxjs/add/operator/retry': 'Rx.Observable.prototype',
     'rxjs/add/operator/retryWhen': 'Rx.Observable.prototype',
     'rxjs/add/operator/sample': 'Rx.Observable.prototype',
     'rxjs/add/operator/sampleTime': 'Rx.Observable.prototype',
     'rxjs/add/operator/scan': 'Rx.Observable.prototype',
     'rxjs/add/operator/sequenceEqual': 'Rx.Observable.prototype',
     'rxjs/add/operator/share': 'Rx.Observable.prototype',
     'rxjs/add/operator/single': 'Rx.Observable.prototype',
     'rxjs/add/operator/skip': 'Rx.Observable.prototype',
     'rxjs/add/operator/skipUntil': 'Rx.Observable.prototype',
     'rxjs/add/operator/skipWhile': 'Rx.Observable.prototype',
     'rxjs/add/operator/startWith': 'Rx.Observable.prototype',
     'rxjs/add/operator/subscribeOn': 'Rx.Observable.prototype',
     'rxjs/add/operator/switch': 'Rx.Observable.prototype',
     'rxjs/add/operator/switchMap': 'Rx.Observable.prototype',
     'rxjs/add/operator/switchMapTo': 'Rx.Observable.prototype',
     'rxjs/add/operator/take': 'Rx.Observable.prototype',
     'rxjs/add/operator/takeLast': 'Rx.Observable.prototype',
     'rxjs/add/operator/takeUntil': 'Rx.Observable.prototype',
     'rxjs/add/operator/takeWhile': 'Rx.Observable.prototype',
     'rxjs/add/operator/throttle': 'Rx.Observable.prototype',
     'rxjs/add/operator/throttleTime': 'Rx.Observable.prototype',
     'rxjs/add/operator/timeInterval': 'Rx.Observable.prototype',
     'rxjs/add/operator/timeout': 'Rx.Observable.prototype',
     'rxjs/add/operator/timeoutWith': 'Rx.Observable.prototype',
     'rxjs/add/operator/timestamp': 'Rx.Observable.prototype',
     'rxjs/add/operator/toArray': 'Rx.Observable.prototype',
     'rxjs/add/operator/toPromise': 'Rx.Observable.prototype',
     'rxjs/add/operator/window': 'Rx.Observable.prototype',
     'rxjs/add/operator/windowCount': 'Rx.Observable.prototype',
     'rxjs/add/operator/windowToggle': 'Rx.Observable.prototype',
     'rxjs/add/operator/windowWhen': 'Rx.Observable.prototype',
     'rxjs/add/operator/withLatestFrom': 'Rx.Observable.prototype',
     'rxjs/add/operator/zipAll': 'Rx.Observable.prototype',
     'rxjs/add/operator/zipProto': 'Rx.Observable.prototype',
     'rxjs/observable/bindCallback': 'Rx.Observable',
     'rxjs/observable/bindNodeCallback': 'Rx.Observable',
     'rxjs/observable/combineLatest': 'Rx.Observable',
     'rxjs/observable/concat': 'Rx.Observable',
     'rxjs/observable/defer': 'Rx.Observable',
     'rxjs/observable/empty': 'Rx.Observable',
     'rxjs/observable/forkJoin': 'Rx.Observable',
     'rxjs/observable/from': 'Rx.Observable',
     'rxjs/observable/fromEvent': 'Rx.Observable',
     'rxjs/observable/fromEventPattern': 'Rx.Observable',
     'rxjs/observable/fromPromise': 'Rx.Observable',
     'rxjs/observable/if': 'Rx.Observable',
     'rxjs/observable/interval': 'Rx.Observable',
     'rxjs/observable/merge': 'Rx.Observable',
     'rxjs/observable/never': 'Rx.Observable',
     'rxjs/observable/of': 'Rx.Observable',
     'rxjs/observable/pairs': 'Rx.Observable',
     'rxjs/observable/range': 'Rx.Observable',
     'rxjs/observable/throw': 'Rx.Observable',
     'rxjs/observable/timer': 'Rx.Observable',
     'rxjs/observable/using': 'Rx.Observable',
     'rxjs/observable/zip': 'Rx.Observable',
     'rxjs/operator/audit': 'Rx.Observable.prototype',
     'rxjs/operator/auditTime': 'Rx.Observable.prototype',
     'rxjs/operator/buffer': 'Rx.Observable.prototype',
     'rxjs/operator/bufferCount': 'Rx.Observable.prototype',
     'rxjs/operator/bufferTime': 'Rx.Observable.prototype',
     'rxjs/operator/bufferToggle': 'Rx.Observable.prototype',
     'rxjs/operator/bufferWhen': 'Rx.Observable.prototype',
     'rxjs/operator/catch': 'Rx.Observable.prototype',
     'rxjs/operator/combineAll': 'Rx.Observable.prototype',
     'rxjs/operator/combineLatest': 'Rx.Observable.prototype',
     'rxjs/operator/concat': 'Rx.Observable.prototype',
     'rxjs/operator/concatAll': 'Rx.Observable.prototype',
     'rxjs/operator/concatMap': 'Rx.Observable.prototype',
     'rxjs/operator/concatMapTo': 'Rx.Observable.prototype',
     'rxjs/operator/count': 'Rx.Observable.prototype',
     'rxjs/operator/debounce': 'Rx.Observable.prototype',
     'rxjs/operator/debounceTime': 'Rx.Observable.prototype',
     'rxjs/operator/defaultIfEmpty': 'Rx.Observable.prototype',
     'rxjs/operator/delay': 'Rx.Observable.prototype',
     'rxjs/operator/delayWhen': 'Rx.Observable.prototype',
     'rxjs/operator/dematerialize': 'Rx.Observable.prototype',
     'rxjs/operator/distinct': 'Rx.Observable.prototype',
     'rxjs/operator/distinctUntilChanged': 'Rx.Observable.prototype',
     'rxjs/operator/distinctUntilKeyChanged': 'Rx.Observable.prototype',
     'rxjs/operator/do': 'Rx.Observable.prototype',
     'rxjs/operator/elementAt': 'Rx.Observable.prototype',
     'rxjs/operator/every': 'Rx.Observable.prototype',
     'rxjs/operator/exhaust': 'Rx.Observable.prototype',
     'rxjs/operator/exhaustMap': 'Rx.Observable.prototype',
     'rxjs/operator/expand': 'Rx.Observable.prototype',
     'rxjs/operator/filter': 'Rx.Observable.prototype',
     'rxjs/operator/finally': 'Rx.Observable.prototype',
     'rxjs/operator/find': 'Rx.Observable.prototype',
     'rxjs/operator/findIndex': 'Rx.Observable.prototype',
     'rxjs/operator/first': 'Rx.Observable.prototype',
     'rxjs/operator/forEach': 'Rx.Observable.prototype',
     'rxjs/operator/groupBy': 'Rx.Observable.prototype',
     'rxjs/operator/ignoreElements': 'Rx.Observable.prototype',
     'rxjs/operator/isEmpty': 'Rx.Observable.prototype',
     'rxjs/operator/last': 'Rx.Observable.prototype',
     'rxjs/operator/let': 'Rx.Observable.prototype',
     'rxjs/operator/letProto': 'Rx.Observable.prototype',
     'rxjs/operator/lift': 'Rx.Observable.prototype',
     'rxjs/operator/map': 'Rx.Observable.prototype',
     'rxjs/operator/materialize': 'Rx.Observable.prototype',
     'rxjs/operator/max': 'Rx.Observable.prototype',
     'rxjs/operator/merge': 'Rx.Observable.prototype',
     'rxjs/operator/mergeAll': 'Rx.Observable.prototype',
     'rxjs/operator/mergeMap': 'Rx.Observable.prototype',
     'rxjs/operator/mergeMapTo': 'Rx.Observable.prototype',
     'rxjs/operator/mergeScan': 'Rx.Observable.prototype',
     'rxjs/operator/min': 'Rx.Observable.prototype',
     'rxjs/operator/multicast': 'Rx.Observable.prototype',
     'rxjs/operator/observeOn': 'Rx.Observable.prototype',
     'rxjs/operator/pairwise': 'Rx.Observable.prototype',
     'rxjs/operator/partition': 'Rx.Observable.prototype',
     'rxjs/operator/pluck': 'Rx.Observable.prototype',
     'rxjs/operator/publish': 'Rx.Observable.prototype',
     'rxjs/operator/publishBehavior': 'Rx.Observable.prototype',
     'rxjs/operator/publishLast': 'Rx.Observable.prototype',
     'rxjs/operator/publishReplay': 'Rx.Observable.prototype',
     'rxjs/operator/race': 'Rx.Observable.prototype',
     'rxjs/operator/reduce': 'Rx.Observable.prototype',
     'rxjs/operator/repeat': 'Rx.Observable.prototype',
     'rxjs/operator/repeatWhen': 'Rx.Observable.prototype',
     'rxjs/operator/retry': 'Rx.Observable.prototype',
     'rxjs/operator/retryWhen': 'Rx.Observable.prototype',
     'rxjs/operator/sample': 'Rx.Observable.prototype',
     'rxjs/operator/sampleTime': 'Rx.Observable.prototype',
     'rxjs/operator/scan': 'Rx.Observable.prototype',
     'rxjs/operator/sequenceEqual': 'Rx.Observable.prototype',
     'rxjs/operator/share': 'Rx.Observable.prototype',
     'rxjs/operator/single': 'Rx.Observable.prototype',
     'rxjs/operator/skip': 'Rx.Observable.prototype',
     'rxjs/operator/skipUntil': 'Rx.Observable.prototype',
     'rxjs/operator/skipWhile': 'Rx.Observable.prototype',
     'rxjs/operator/startWith': 'Rx.Observable.prototype',
     'rxjs/operator/subscribeOn': 'Rx.Observable.prototype',
     'rxjs/operator/switch': 'Rx.Observable.prototype',
     'rxjs/operator/switchMap': 'Rx.Observable.prototype',
     'rxjs/operator/switchMapTo': 'Rx.Observable.prototype',
     'rxjs/operator/take': 'Rx.Observable.prototype',
     'rxjs/operator/takeLast': 'Rx.Observable.prototype',
     'rxjs/operator/takeUntil': 'Rx.Observable.prototype',
     'rxjs/operator/takeWhile': 'Rx.Observable.prototype',
     'rxjs/operator/throttle': 'Rx.Observable.prototype',
     'rxjs/operator/throttleTime': 'Rx.Observable.prototype',
     'rxjs/operator/timeInterval': 'Rx.Observable.prototype',
     'rxjs/operator/timeout': 'Rx.Observable.prototype',
     'rxjs/operator/timeoutWith': 'Rx.Observable.prototype',
     'rxjs/operator/timestamp': 'Rx.Observable.prototype',
     'rxjs/operator/toArray': 'Rx.Observable.prototype',
     'rxjs/operator/toPromise': 'Rx.Observable.prototype',
     'rxjs/operator/window': 'Rx.Observable.prototype',
     'rxjs/operator/windowCount': 'Rx.Observable.prototype',
     'rxjs/operator/windowToggle': 'Rx.Observable.prototype',
     'rxjs/operator/windowWhen': 'Rx.Observable.prototype',
     'rxjs/operator/withLatestFrom': 'Rx.Observable.prototype',
     'rxjs/operator/zipAll': 'Rx.Observable.prototype',
     'rxjs/operator/zipProto': 'Rx.Observable.prototype',
     'rxjs/symbol/iterator': 'Rx.Symbol',
     'rxjs/symbol/observable': 'Rx.Symbol',
     'rxjs/symbol/rxSubscriber': 'Rx.Symbol' },
  name: 'ngCore',
  onwarn: [Function: rollupOnWarn],
  plugins:
   [ { name: 'commonjs',
       options: [Function: options],
       resolveId: [Function: resolveId],
       load: [Function: load],
       transform: [Function: transform] },
     { name: 'node-resolve', resolveId: [Function: resolveId$1] },
     { name: 'sourcemaps', load: [Function: load] } ],
  sourcemap: true,
  output:
   { file: '/home/tom/workspace-angular/ng-core/dist/bundles/ng-core.umd.js',
     format: 'umd' } }
tommueller commented 6 years ago

Ok, this is not getting better. A short summary what I tried today ...

These changes let me compile the project without errors, just some (I think unproblematic, because they were there before) warnings where issued from rollup:

[Librarian]: 'default' is not exported by 'node_modules/rxjs/add/operator/toPromise.js'
'MatSelect' is imported from external module '@angular/material' but never used
'default' is not exported by 'node_modules/rxjs/add/operator/toPromise.js'
'MatSelect' is imported from external module '@angular/material' but never used
'default' is not exported by 'node_modules/rxjs/add/operator/toPromise.js'
'MatSelect' is imported from external module '@angular/material' but never used
'default' is not exported by 'node_modules/rxjs/add/operator/toPromise.js'
'MatSelect' is imported from external module '@angular/material' but never used

BUT importing the compiled library does not work now. I get errors in my IDE that the module could not be found. Again I was able to hack-fix this by changing the modules package.json in my node_modules folder. I changed:

  - "main": "./ng-core.umd.js"
  + "main": "./bundles/ng-core.umd.js"

Which lets my compile my angular-cli project, importing my library, BUT it does not start. The browsers console throws the following error:

Unhandled Promise rejection: StaticInjectorError[Injector]: 
  StaticInjectorError[Injector]: 
    NullInjectorError: No provider for Injector! ; Zone: <root> ; Task: Promise.then ; Value: Error: StaticInjectorError[Injector]: 
  StaticInjectorError[Injector]: 
    NullInjectorError: No provider for Injector!
    at _NullInjector.get (core.js:993)
    at resolveToken (core.js:1281)
    at tryResolveToken (core.js:1223)
    at StaticInjector.get (core.js:1094)
    at resolveToken (core.js:1281)
    at tryResolveToken (core.js:1223)
    at StaticInjector.get (core.js:1094)
    at resolveNgModuleDep (core.js:10878)
    at _createClass (core.js:10915)
    at _createProviderInstance$1 (core.js:10889) Error: StaticInjectorError[Injector]: 
  StaticInjectorError[Injector]: 
    NullInjectorError: No provider for Injector!
    at _NullInjector.get (webpack-internal:///../../../core/esm5/core.js:1189:19)
    at resolveToken (webpack-internal:///../../../core/esm5/core.js:1477:24)
    at tryResolveToken (webpack-internal:///../../../core/esm5/core.js:1419:16)
    at StaticInjector.get (webpack-internal:///../../../core/esm5/core.js:1290:20)
    at resolveToken (webpack-internal:///../../../core/esm5/core.js:1477:24)
    at tryResolveToken (webpack-internal:///../../../core/esm5/core.js:1419:16)
    at StaticInjector.get (webpack-internal:///../../../core/esm5/core.js:1290:20)
    at resolveNgModuleDep (webpack-internal:///../../../core/esm5/core.js:11074:25)
    at _createClass (webpack-internal:///../../../core/esm5/core.js:11111:29)
    at _createProviderInstance$1 (webpack-internal:///../../../core/esm5/core.js:11085:26)

And that is how far I got with this today. I really wonder what's different in your code then in mine ... Do you maybe have a different version of rollup installed globally? Don't really now what else to check anymore ...

tommueller commented 6 years ago

I tested more today and also upgraded the project to Angular 5.2.0 and now the export works with my mentioned changes ... I think the it works regardless of the Angular update, as I did not publish the library correctly, but here is my current state in more detail:

So I hope this fixes the problems, I will test now if it also works without the Angular upgrade and publish a PR if so.

edit: yep also works without the Angular update! PR is coming!

Best! Tom

tommueller commented 6 years ago

Ok, I give up ... After some more work on the project the build failed again and I had to reset the paths of es5Dir and es2015Dir back to your version ... Right now I use the latest rollup version and it works with your code. I have no idea what I changed though ...

SirDarquan commented 6 years ago

I ran into this problem a couple days ago as well. To see if there was a problem with ngl, I created a brand new empty library and performed a build. Of course it worked perfectly which led me to wonder what was different about my real library. To make a long story short, the package-lock.json was keeping specific versions of packages that ngl relied on at pre-update versions. It's designed to do this if the direct dependencies don't change. So the easiest solution was to just delete my package-lock.json file and do an npm install. everything updated and the build began to work.

I'm sure that there's a more 'official' way to tell npm to update indirect dependencies but I didn't really feel like searching to understand what it was. Maybe the migration docs should make a mention of this as a possible fix if it works for most projects, that is.

gonzofish commented 6 years ago

Thank you so much for figuring this out! I’ll see if I can investigate and give an official solution. In the meantime I’ll put a note in the migration document. On Sat, Feb 3, 2018 at 10:35 AM SirDarquan notifications@github.com wrote:

I ran into this problem a couple days ago as well. To see if there was a problem with ngl, I created a brand new empty library and performed a build. Of course it worked perfectly which led me to wonder what was different about my real library. To make a long story short, the package-lock.json was keeping specific versions of packages that ngl relied on at pre-update versions. It's designed to do this if the direct dependencies don't change. So the easiest solution was to just delete my package-lock.json file and do an npm install. everything updated and the build began to work.

I'm sure that there's a more 'official' way to tell npm to update indirect dependencies but I didn't really feel like searching to understand what it was. Maybe the migration docs should make a mention of this as a possible fix if it works for most projects, that is.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gonzofish/angular-librarian/issues/89#issuecomment-362822908, or mute the thread https://github.com/notifications/unsubscribe-auth/AAYjrm4X918lNi6UEpx2H8Yhd4JeMZk4ks5tRHy3gaJpZM4RX2Cy .

gonzofish commented 6 years ago

Btw, I've added a note to the MIGRATION.md file with @SirDarquan's mitigation

gonzofish commented 6 years ago

Closing this with the MIGRATION.md addition