Skip to content

Make tsserver.js a library #39291

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

Closed
wants to merge 5 commits into from
Closed

Conversation

amcasey
Copy link
Member

@amcasey amcasey commented Jun 27, 2020

VS Code (and probably others) currently consumes both tsserver.js and
typescript.js, even though they have essentially the same content. This
change makes it possible to use tsserver.js for both purposes, by
suppressing the server startup code (including requires) and adding a
declaration file (stripped of internals).

@amcasey
Copy link
Member Author

amcasey commented Jun 27, 2020

I bet there's a cleverer way to skip the body of server.ts and I'd be happy to hear it.

@amcasey
Copy link
Member Author

amcasey commented Jun 27, 2020

FYI @mjbvz, hopefully, this will save VS Code 8MB or so.

@amcasey
Copy link
Member Author

amcasey commented Jun 27, 2020

Do I need to hook the new .d.ts file up to some sort of baseline/validation system?

@weswigham
Copy link
Member

If we're considering this, the tsserverlibrary build is already this minus the startup code - perhaps we should just merge them?

@amcasey
Copy link
Member Author

amcasey commented Jun 27, 2020

@weswigham What does "merge them" mean in this context? Drop tsserverlibrary?

@weswigham
Copy link
Member

weswigham commented Jun 27, 2020

tsserverlibrary's build tasks already have the declaration files and API baselining set up - so copying the conditional startup code into the tsserverlibrary entrypoint, then renaming it to tsserver (after deleting the old tsserver tasks/folder), I imagine (so, sort-of dropping it, yes, since name-wise, it'd be gone).

@amcasey
Copy link
Member Author

amcasey commented Jun 29, 2020

I've done my best to port the functionality of tsserverlibrary to tsserver, but they had slightly different watch functionality, so it might not be exact.

amcasey added 5 commits June 29, 2020 16:09
VS Code (and probably others) currently consumes both tsserver.js and
typescript.js, even though they have essentially the same content.  This
change makes it possible to use tsserver.js for both purposes, by
suppressing the server startup code (including requires) and adding a
declaration file (stripped of internals).
@amcasey
Copy link
Member Author

amcasey commented Jun 29, 2020

Force update was just a rebase. No manual merging required.

Copy link
Member

@weswigham weswigham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks OK to me; but we should also have @rbuckton take a look over the build changes and @RyanCavanaugh validate when we wanna take the API break (since we'll no longer be shipping a file named tsserverlibrary - though we could symlink it to preserve compatibility, admittedly).

@amcasey
Copy link
Member Author

amcasey commented Jun 30, 2020

There's a weird quirk there actually - unless we manually delete it next time we update the LKG, we'll continue to ship the old one. (See also #39330)

@weswigham
Copy link
Member

AFAIK when we rewrote the LKG script, the only reason it doesn't automatically delete dead files was because there was some .json document or something which seemed dead but was also potentially consumed by VS (and may even be gone by now - or I could be thinking of typesMap.json, don't know), IIRC from a conversation from years ago.

@amcasey amcasey closed this Jul 10, 2020
@amcasey
Copy link
Member Author

amcasey commented Jul 10, 2020

This would be a hack, so we're not going to pursue it.

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.

2 participants