-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UMD bundle cannot be used for RxJS #9359
Comments
+1. I had the same issue |
There are direct imports of Rx sub module in @anguard/http which may lead to this issue. If @angular/http start using rxjs from umd module then this could be resolved. |
@robwormald this might a bigger issue than what I thought and is caused by deep imports into rxjs which won't work with umd. System.register format would handle this well, but that has other issues. |
One solution I came up with is that loading |
@pavandv That solution does not seem to work; systemjs still attempts to load the individual script files. |
Is there something new related to the problem with using RxJS bundle? |
Is there any workaround until the issue is fixed. I tried loading through script and delete all rxjs entries in systemjs file. Still, systemjs tries to download the individual rxjs operator files. Its impacting the initial load performance |
You should use individual operators import (deep import). This will reduce the requests to 70-80 ( depending upon how heavily you use RxJS) from 275 by bundle like import |
Hi - When can we expect a fix on this? |
It has a milestone related to RC5 upcoming release. |
I don't think it is worth to use the umd bundle anyway. It seems Rxjs folks have broken down the components into smaller pieces, then you need to explicitly reference what you want to use. This have reduced the amount of files being downloaded a lot from previous versions. At my company I switched to a different approach, where I copy all the .js files from the npm folder into a vendor folder using a gulp task:
And then map it using system.js.config: At first I didn't like the solution, but later it proved to be acceptable. |
Agreed. Loading individual files are only a problem in development mode with SystemJS loader. For production we bundle them into a single file for fast loading. But even if we get this to work (Rx UMD) we still have yet hundreds of files to deal with (on-the-fly typescript). So I believe the definitive answer for all of this is migration to webpack and angular-cli (I hope so). TLDR: rxjs UMD is not helpful |
try to use a relative path instead of |
this is my system.config.js, works very well:
if it's not work for you, then, I'm pretty sure the problem is yours only. and try to update rxjs to rc.4, few things have changed after beta.12. here is my spec: |
@unlight thx - your solution works for me, too. But only if I do change my imports to use From a JS beginners perspective this is kind of a bummer as the Angular tutorial leads straight to Observables and the code does indeed work but one has to fiddle with this import/dependency. |
Updated version of system.config.js config -> should be added line "rxjs/symbol/*" to:
for spec:
|
@mlc-mlapis Where does the file assets/global/plugins/Rx.min.js (declared in the bundles configuration of systemjs) come from ? Is it the file provided in the npm package, or is it a file rebuilt by yourself using SystemBuilder ? |
The second is right. This is the file which represents the re-bundled version of RxJS. You can save it where you want. I am saving it at "assets/rxjs-bundle/Rx.min.js". |
for the solutions that are using systemjs-builder, is part of the reason the compiled file is so large because the node_modules/rxjs/bundles folder is included, or do those files not impact the final result? |
Tried everything out here. Nothing works for me. I built the Rx.min.js as suggested.
Here what I get as an output: What am I doing wrong? |
@guest73 You can see the exact config I use to create a System bundle of RxJS here: https://github.com/OasisDigital/rxjs-system-bundle You can see it in use, here: https://plnkr.co/edit/Fy0jvu?p=preview Offhand, the main difference I see between my config and yours is a bit in the systemjs config:
... but there could be something else also, of course. |
Thanks @kylecordes, it kind of helped. The problem, seems to me, was in a way we referenced RxJS stuff in our own project.
and also something like this
I removed the operator imports and made everything to be like import { Observable } from 'rxjs/Rx'; |
@guest73 The problem with this form:
is that it imports https://unpkg.com/rxjs@5.2.0/Rx.js I think the current "best" form to use is:
This form:
https://github.com/angular/angular/search?utf8=%E2%9C%93&q=from+%27rxjs%2FObservable%27&type= |
please guys, this doesn't make any sense on a production build, you'll always use a bundler to build all scripts with aot, and trust me, I've spent 4 days to try to figure out how to use webpack and systemjs together, and still there are some problems, and after turning to @angular/cli, it only takes me about 15mins to make a aot bundles. and with angular 4.0, it seems systemjs way won't work any more, I've tried with some different settings, and none of those works, and that take me a whole day, and with @angular/cli, it's really about just few keystrokes, then everything is done, dev build with sourcemap and watch, and production build with aot, everything works like a charm. please guys, don't waste any more time on this, unless of course, you must stick to angular 2 version forever. angular/cli is FAR MORE easier than this systemjs way. Now in my setup, I use angular/cli to pack everything, and with systemjs to load any scripts dynamically, or just leave this work to angular/cli to pack a whole bunch of 3rd-party jquery plugins. after move to angular/cli, my system.config.js only contains these
|
Webpack worked for me as well. It took way less time to learn webpack from scratch and add it to my project than I spent trying to get systemjs bundling working |
the problem in bundles please copy this configjs or change it like this code
its will works perfectly |
@abu7midan: How is that going to help? The systemjs loader will stick pick up the single files instead of the bundle in single request to the |
Thank you for this information. I was using the bundled rxjs without any issues. Today wanted to use angular material and when I use that, i get error, |
@jeshcalls ... can you show the exact error message? |
Please find the error below. ERROR Error: Uncaught (in promise): Error: Error: XHR error (404 Not Found) loading http://localhost:8000/rxjs |
@jeshcalls ... it means that there is nothing on URL http://localhost:8000/rxjs What loader are you using? SystemJS? |
yeah I am using SystemJS, when I add a map entry in System.config.js to have rxjs: npm:rxjs, it is fetching from http://localhost:8000/node_modules/rxjs which has the folder but obviously individual js files of rxjs is fetched. |
@jeshcalls ... for re-bundled RxJS 5.5.x you should have the following if your
|
@jeshcalls: SystemJS is dead. Angular moved away from it long ago to webpack and angular-cli now |
@mlc-mlapis : Thanks so much. I read through your previous posts on this and missed this. This bundle did not work but I added a map attribute as 'rxjs': 'npm:./tmp/Rx.js' and it worked. |
@TsengSR : You are absolutely right. Is there a web link that compares the system js and webpack modes. Have to show a consolidated presentation to my bosses to make them agree to make the shift. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a ... (check one with "x")
Current behavior
I updated system-config.ts file to download umd file for rxjs I.e rxjs\bundles\Rx.umd.js. This worked. But I still see in dev tools a lot of individual JS being load like rxjs\observer.js
Expected/desired behavior
When using UMD for rxjs it should not download individual files
Reproduction of the problem
See this plunker when you riun in full screen mode observe the files being loaded in dev tools. http://plnkr.co/edit/TvjW2YK3NVJ7sDb7cHV4?p=preview
No community response on question: http://stackoverflow.com/questions/37881825/using-rxjs-umd-bundles
What is the expected behavior?
When using UMD for rxjs it should not download individual files
What is the motivation / use case for changing the behavior?
To reduce load request when angular app starting up
Please tell us about your environment:
Tested only on chrome
Tested with Typescript only
The text was updated successfully, but these errors were encountered: