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.

Rollup fails on rxjs/Subject imported by @angular/core/src/facade/async.js

See original GitHub issue

I’m submitting a … (check one with “x”)

[ x ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior angular.io describes using Rollup for treeshaking and bundling, but Rollup fails with this message: Error: 'Subject' is not exported by node_modules\rxjs\Subject.js (imported by node_modules\@angular\core\src\facade\async.js).

Supposedly, the solution is to use the namedExports option, but that doesn’t make any difference at all…

My rollup-config.js looks like this:

import rollup from 'rollup';
import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify';

export default {
  entry: 'aot/client.aot.js',
  dest: 'dist/build.js', // output a single application bundle
  sourceMap: false,
  format: 'iife',
  plugins: [
    nodeResolve({
      jsnext: true,
      module: true
    }),
    commonjs({
      include: 'node_modules/rxjs/**',
      namedExports: {
        'node_modules/rxjs/Subject.js': [ 'Subject' ]
      }
    }),
    uglify()
  ]
}

Expected behavior

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Please tell us about your environment: OS: Windows 10, IDE: VSCode, package manager: npm

  • Angular version: 2.2.4

  • Browser: [all]

  • Language: [ES2015]

  • Node (for AoT issues): node --version = v6.9.2

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
hamzahamidicommented, Aug 25, 2017

Unfortunately this is still an issue in angular 4

2reactions
DzmitryShylovichcommented, Feb 1, 2017

@pkozlowski-opensource looks like the issue with rollup config and not directly related to angular. can be closed

Read more comments on GitHub >

github_iconTop Results From Across the Web

'Subject' is not exported by rxjs in rollup.js - Stack Overflow
This gives an "Duplicate export 'Subject'" error until the namedExport is removed. Then it works. For me at least. – DarkNeuron. Oct 11,...
Read more >
Installation Instructions - RxJS
When RxJS 7.x is used on Node.js regardless of whether it is consumed via require or import ... To import only what you...
Read more >
RxJS - Working with Subjects - Tutorialspoint
To work with subject, we need to import Subject as shown below − import { Subject } from 'rxjs';. You can create a...
Read more >
[Solved]-'Subject' is not exported by rxjs in rollup.js-rx.js
I finally figured this out on my system. The named export solution is wrong since rollup-plugin-commonjs will handle the exports in Subject.js just...
Read more >
BehaviorSubject - Learn RxJS
Example 1: Simple BehaviorSubject. ( Stackblitz ). // RxJS v6+. import { BehaviorSubject } from 'rxjs';. ​. const subject = new BehaviorSubject(123);.
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