Make rxjs a side-effect free package (for webpack v4)
See original GitHub issueWebpack is going to introduce a new feature called side-effect free module optimization in v4 (currently in alpha).
This optimization requires packages to opt-in to it and promise to contain only side-effect free ES modules by adding side-effects: false
flag into the package.json. More info: https://github.com/webpack/webpack/tree/next/examples/side-effects
This is mostly true for rxjs except for the special modules that monkey patch the prototype (specifically rxjs
, rxjs/add/operator/*
, rxjs/add/observable/*
). These modules are being deprecated anyway in v6 in favor of lettable operators and creation functions (observable factories), so we should just move that code into a separate package with reexports from the rxjs
package to avoid breaking the world.
The redirects could look something like this:
rxjs/add/operator/foo
in the rxjs package (marked as side-effect free)
import from 'rxjs-deprecations/add/operator/foo';
rxjs-deprecations/add/operator/foo
in the rxjs-deprecations package (not marked as side-effect free)
import {Observable} from 'rxjs'
Obeservable.prototype.foo = ....
This way webpack does it’s magic for people that use the new module ids (see #3145) and for people that still require old paths due to legacy code, all they have to do is to install rxjs-deprecations into their app (we could also consider making it a dependency of rxjs and auto installing it but that could cause issues and would promote the bad side-effecty behavior which is dangerous, so for that reason alone I’d prefer the legacy package to be an opt-in)
Note: this issue came out of discussion in https://github.com/angular/angular-cli/issues/9069#issuecomment-355394912
Issue Analytics
- State:
- Created 6 years ago
- Reactions:12
- Comments:16 (6 by maintainers)
btw the credit for the extra package and redirect idea goes to @jasonaden. I think it’s a pretty rad idea.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.