-
Notifications
You must be signed in to change notification settings - Fork 3k
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 and/or FESM bundles - now tractable with 6.0.0 #3463
Comments
+1 for not wanting to bundle rxjs just for my development environment. |
I'm trying to understand the use case and the work this would entail. Given the hoops we jump through to produce just one UMD bundle, it sounds really awful to have to support this for every module, if that's what you want. So my initial reaction is 👎 |
If this is all that is required for a system.config.json then I am OK with the current state of the build. Do you see a problem with this @kylecordes ? This is a huge improvement from 5.5 IMHO.
|
@steveblue As I understand from that snippet, that looks like this type of configuration you would use if you are planning to load RxJS from its large number of individual JS files for each bit of functionality; whereas what I am looking for (and have been doing all along with a System bundle) is to load all of RxJS with a single HTTP request, or at most a small handful. It seems in this thread that I might be the only person that cares about this though. Though I wonder - if few care about this for (for example) RxJS, why all the effort expended to load things like Angular as one or a small number of requests, rather than as numerous small individual files? |
@benlesh the only way I have found so far to bundle rxjs with closure compiler is when the rxjs entry points are bundled as FESM. I included an additional step in my build to do this, but it seems like a hack. It would probably be easy to implement as you just have to rollup the es2015 modules into FESM. Understood if UMD is hard. angular/closure-demo#32 @kylecordes with 6.0.0 the number of entry points is way less than 5.5. I think it is just a handful of requests. |
@steveblue Yes, the number of modules from which one imports is just a handful, hence this feature request. The work you did to build your FESMs, that's what I am hoping will happen in RxJS's build process. I think UMD output would be not much more complex than FESM output, though of course much less shakable. I think these two use cases are worth a small amount of additional Rollup configuration/script?
|
@kylecordes ... with RxJS 6.0.0-tactical-rc.1 I tried to re-bundle to get an usable single RxJS file to load and work with SystemJS loader + Angular 6.0.0-rc.3. I used this Gulp script:
and use with this config:
Everything works as expected and the only problem to solve is the necessity to manually re-write:
in all places in the final re-bundled Do you have any idea how to get the same without this manual re-write, just using some type of configuration for re-bundling? |
@mlc-mlapis For the use case where I make a RxJS System bundle, I am currently (for another week or two...) working with
I suspect the bit of hackery in their to turn on |
@kylecordes ... yeap, thanks for your comment. I'll try probably something similar as you. It looks like this is the only option. The pleasing is, that the re-bundled RxJS 6 works without any problem. 😄 |
@kylecordes @mlc-mlapis @steveblue [email protected] const Builder = require('systemjs-builder');
const promisify = require('util').promisify;
const fs = require('fs');
module.exports = done => {
const options = {
normalize: true,
runtime: false,
sourceMaps: true,
sourceMapContents: false,
minify: true,
mangle: false
};
const builder = new Builder('./');
builder.config({
paths: {
'n:*': 'node_modules/*',
'rxjs/*': 'node_modules/rxjs/*.js',
"rxjs-compat/*": "node_modules/rxjs-compat/*.js",
"rxjs/internal-compatibility": "node_modules/rxjs/internal-compatibility/index.js",
"rxjs/testing": "node_modules/rxjs/testing/index.js",
"rxjs/ajax": "node_modules/rxjs/ajax/index.js",
"rxjs/operators": "node_modules/rxjs/operators/index.js",
"rxjs/webSocket": "node_modules/rxjs/webSocket/index.js",
},
map: {
'rxjs': 'n:rxjs',
'rxjs-compat': 'n:rxjs-compat'
},
packages: {
'rxjs': {
main: 'index.js',
defaultExtension: 'js'
},
"rxjs-compat": {
main: "index.js",
defaultExtension: "js"
}
}
});
return builder.bundle('rxjs + rxjs/Rx', 'node_modules/.tmp/Rx.min.js', options)
.then(output => {
const writeFile = promisify(fs.writeFile);
const code = output.source.replace(/rxjs\/index/gm, 'rxjs');
return writeFile('node_modules/.tmp/Rx.min.js',
(options.sourceMaps)
? code + `\n//# sourceMappingURL=Rx.min.js.map`
: code);
})
.then(() => done())
.catch(error => done(error));
}; My SystemJS Config "bundles": {
"node_modules/.tmp/Rx.min.js": [ "rxjs", "rxjs/*" ]
} So far this works for me. :) |
I wrote a little node script that uses Rollup to bundle rxjs into FESM so Closure Compiler produces smaller bundles. It's kinda messy because I needed to edit the package.json of each rxjs package to make closure compiler happy. I'm used to doing this though now with ES2015 packages that don't have named exports (not rxjs). Closure Compiler can't handle
rollup.rxjs.js
|
@aelbore How to make this work for development with systemjs without bundling? Thanks |
This was discussed ages ago, and we decided against it at the time. I'll close this, and if someone else comes across this need again, please file a new issue. |
RxJS version:
6
Expected behavior:
Ship a small number of UMD and/or FESM bundles, one for each of the small number of import targets under RxJS 6.
Actual behavior:
For the moment (v6 beta) it looks like there is just a single UMD bundle provided, which can't support multiple important targets. Please many small files, suitable for application-level bundling.
Additional information:
This thing has been discussed in the past, but there was never a tenable solution (other than SystemJS bundle format, which has less wide use) to ship a small number of bundles that contain the RxJSs code, while still supporting:
(i.e., how things were through version 5)
But with the new, much smaller number of import targets, for example see this in the current README:
It is now possible to ship a small number of UMD or FESM bundles, one for each of the handful of imports (
rxjs
,rxjs/operators
, etc.).This would take care of use cases for those of us with use cases that consume RxJS directly from something like a CDN, without having to create and publish such a bundle ourselves (as me and a number of others had done historically with SystemJS).
/cc pleading my case to @benlesh @IgorMinar etc ;-)
The text was updated successfully, but these errors were encountered: