Rollup fails on rxjs/Subject imported by @angular/core/src/facade/async.js
See original GitHub issueI’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:
- Created 7 years ago
- Reactions:1
- Comments:12 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Unfortunately this is still an issue in angular 4
@pkozlowski-opensource looks like the issue with rollup config and not directly related to angular. can be closed