Skip to content
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

issues when using rxjs/fetch in create-react-app or webpack #4999

Closed
kambing86 opened this issue Sep 3, 2019 · 3 comments
Closed

issues when using rxjs/fetch in create-react-app or webpack #4999

kambing86 opened this issue Sep 3, 2019 · 3 comments
Labels
bug Confirmed bug

Comments

@kambing86
Copy link
Contributor

kambing86 commented Sep 3, 2019

Bug Report

Current Behavior

the default behaviour of using

import { Observable } from "rxjs";

it will be using the source file in ./node_modules/rxjs/_esm5/index.js because of the module defined in ./node_modules/rxjs/package.json

but if we are using some other stuffs like

import { fromFetch } from "rxjs/fetch";

it will be using the source file in ./node_modules/rxjs/fetch/index.js

this is causing a lot of bugs which I filed it here #4820

I have to use

import { fromFetch } from "rxjs/_esm5/fetch";

then everything works fine

Reproduction
https://github.com/kambing86/test-from-fetch
fix repo https://github.com/kambing86/test-from-fetch/tree/fix/import-fromFetch

Expected behavior
should be using just one type of source?

Environment

  • Runtime: Node 10 / 12, Chrome 76
  • RxJS version: 6.5.2
  • (If bug is related) Loader, build configuration: create-react-app
  • built in macOS High Sierra / WSL in Windows10
@kambing86
Copy link
Contributor Author

it seems like using rxjs/operators is fine, most likely because they are just pure functions without state

import { finalize, mergeMap, share } from "rxjs/operators";

but fromFetch is returning the Observable class which is stateful, and this causes a lot of weird issues

@cartant cartant added the bug Confirmed bug label Sep 3, 2019
@cartant
Copy link
Collaborator

cartant commented Sep 3, 2019

@benlesh It seems likely that the problem is related to fetch not being included here:

rxjs/.make-packages.js

Lines 135 to 140 in 3881723

fs.writeJsonSync(PKG_ROOT + 'package.json', rootPackageJson, {spaces: 2});
fs.copySync('src/operators/package.json', PKG_ROOT + '/operators/package.json');
fs.copySync('src/ajax/package.json', PKG_ROOT + '/ajax/package.json');
fs.copySync('src/webSocket/package.json', PKG_ROOT + '/webSocket/package.json');
fs.copySync('src/testing/package.json', PKG_ROOT + '/testing/package.json');
fs.copySync('src/internal-compatibility/package.json', PKG_ROOT + '/internal-compatibility/package.json');

@kambing86
Copy link
Contributor Author

thanks @cartant for pointing out the root cause, I tried to fix it in my local and it works

create a PR for this #5001

@lock lock bot locked as resolved and limited conversation to collaborators Oct 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Confirmed bug
Projects
None yet
Development

No branches or pull requests

2 participants