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.

Make rxjs a side-effect free package (for webpack v4)

See original GitHub issue

Webpack 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:closed
  • Created 6 years ago
  • Reactions:12
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
IgorMinarcommented, Jan 4, 2018

btw the credit for the extra package and redirect idea goes to @jasonaden. I think it’s a pretty rad idea.

0reactions
lock[bot]commented, Jun 5, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What Does Webpack 4 Expect From A Package With sideEffects
The "sideEffects": false flag in big-module's package.json indicates that the package's modules have no side effects (on evaluation) and only ...
Read more >
Tree Shaking - webpack
The new webpack 4 release expands on this capability with a way to provide hints to the compiler via the "sideEffects" package.json property...
Read more >
Angular package format
The recommendation is for all packages to claim the side-effect free status by setting the sideEffects property to false , and that developers...
Read more >
How to configure Webpack 4 with Angular 7: a complete guide
Angular 7: setup a basic app. Create a new package.json file and add the following lines to install Angular and its dependencies. "dependencies" ......
Read more >
webpack 4: released today!! . Codename: Legato - Medium
Today we're happy to release that webpack 4 (Legato) is available today! ... popular library's like lodash-es, RxJS are supporting the sideEffects flag, ......
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