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

fix: VS code will now properly import operators, et al #6276

Merged
merged 1 commit into from
Apr 29, 2021

Conversation

benlesh
Copy link
Member

@benlesh benlesh commented Apr 28, 2021

  • Adds typesVersions, enforcing TypeScript >= 4.2.
  • Adds some superfluous imports required for TS and VS Code to find proper import locations for our strange deep import sites.
  • Independantly tested by building the package and installing it locally in another project, then testing in VS code.

Fixes #6067
Related microsoft/TypeScript#43034

NOTE: I'm worried about the check-side-effects run here, because it can't seem to figure out what to make of it. However, tested against an Angular build locally, this branch didn't have any problems tree-shaking or removing dead code. Given the importance of people getting their imports right, and the DX around this, we might want to disable check-side-effects if it causes us issues.

@benlesh
Copy link
Member Author

benlesh commented Apr 28, 2021

attn @filipesilva ... we're getting errors from check-side-effects, however, there's no real change to the tree-shakability of what rxjs is outputting here from any of my tests (with angular-cli).

image

@benlesh
Copy link
Member Author

benlesh commented Apr 28, 2021

It does have me a little concerned that rollup will have issues with this. Good grief, I had modules. @Rich-Harris, should rollup not like what we're doing here? It's admittedly bananas, but it seems to be working otherwise.

@benlesh
Copy link
Member Author

benlesh commented Apr 28, 2021

Yeah, I don't think we can get this fix into version 7 unless we're totally sure it's in the clear with everyone's bundlers. This is only to fix auto imports in VS Code... as crazy as that is. So just waiting to have some experts weigh in.

Hopefully we don't need to restructure our entire build to get things working in VS Code. :\

@cartant
Copy link
Collaborator

cartant commented Apr 28, 2021

FWIW, I did a small test with Rollup and the inclusion of the imports seems to make no difference to its output and tree shaking seems to work just fine.

@Rich-Harris
Copy link

Unfortunately I got different results. I added a tmp/index.js file with a single line:

import '../dist/esm5_for_rollup/index.js';

Running the following on master after npm run compile...

npx rollup@latest -i tmp/index.js -o tmp/master.js -f esm

...yielded a 48kb (unminified) file.

I switched to this branch and it failed at first, because dist/esm5_for_rollup/index.js contained the new directory imports...

import './ajax';
import './fetch';
import './operators';
import './testing';
import './webSocket';

...which Rollup chafes at (since native loaders don't handle directory imports). Appending /index.js to each of the imports allowed the command to run, but it yielded a 91kb file.

@benlesh
Copy link
Member Author

benlesh commented Apr 28, 2021

Thank you so much, @Rich-Harris, for taking the time to look at this.


So given this feedback, I think this PR is a no-go, and I'm going to close it. We're going to have to come up with another solution.

- Adds typesVersions, enforcing TypeScript >= 4.2.
- Adds some superfluous references required for TS and VS Code to find proper import locations for our strange deep import sites.
- Independantly tested by building the package and installing it locally in another project, then testing in VS code.

Fixes ReactiveX#6067
Related microsoft/TypeScript#43034
@benlesh
Copy link
Member Author

benlesh commented Apr 28, 2021

All right, I've reopened this because there was another approach proposed by the TypeScript team, and it seems to be working! cc @cartant

@benlesh
Copy link
Member Author

benlesh commented Apr 28, 2021

I've tested this with the methodology recommended by @Rich-Harris, and the output is identical between this branch and the master branch. So I think this is good to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[v7] TS automatic imports in VSCode default to wrong path
4 participants