* Refactor `Extensions`, fix lookup priorities
* Update baselines
* Clean up
* Temporarily apply same fix to `node` for testing
* Revert ancestor node_modules lookups back to two passes
* Revert "Temporarily apply same fix to `node` for testing"
This reverts commit 4014f3005a2a01a5c71a88e6418cc635498a83bc.
* Update baselines
* Add new test for node_modules searching behavior
* Update new baseline
* Add tests where typeRef resolution is not in the cache
* Ensure that type ref reuse is actually handled since type ref resolution only sends containingSourceFileMode and not containingSourceFile
* Remove unnecessary redirection now that we are not in namespaces
* Move the tsc helpers in one place
* Move virtual file system with watch in unittests folder instead of harness since harness doesnt use it anyways
* Replace protocol and commandNames
* Revert incorrect pick
* Add known keys of the mapped type constraint to its members
* Avoid second pass of adding known members by instead passing `noReductions` to `mapType`
It turns out that the import expression won't actally be rewritten by
esbuild, so we can just write it directly.
While this won't help CJS emit, that already didn't work anyway, and
it's likely that this code is going to be moved outside of the codebase
into VS Code or a shared package elsewhere anyway.
The troubleshooting wizard for the debugger actually says that this
option is no longer recommended; removing it enables us to use source
maps if we happen to be debugging while in --bundle=false mode.
Looking at github, sourcegraph, and internally, nobody appears to use
this factory at all.
It's still used within our testing framework, so I won't remove it, but
we shouldn't be polyfilling globalThis and sticking things onto it these
days.
This debug code was added quite a while ago, constructed such that we
wouldn't have to ship this code to our users.
However, this is the sole place in the compiler project where the ts
namespace "escapes" the bundle. By moving this debug code into the
compiler itself, we no longer have any references to the ts namespace
itself for our bundles that don't export anything (tsc,
typingsInstaller). This lets bundlers tree shake the compiler, reducing
the size of our output by _5.7 MB_ (a ridiculous improvement for
_adding_ code).
We pass the entire "ts" object into plugins. However, we need to make
sure that that object contains the debug compat helpers.
In the old codebase, the deprecated compat code would tack things onto
the actual ts object, after the server code was executed, and later that
same object would be given to plugins.
But in modules, each TS project only sees the view of the "ts" namespace
that their references implied, not the ts object as some sort of
singleton. To ensure that plugins get the debug compat code, we have to
bring that into each project's view of the ts namespace, and not add it
on later in the executable projects.
Unlike our other exectuables, tsserver is used in web, which means that
there actually would have been a "ts" variable declared for those users
(e.g. in a web worker). It looks like VS Code needs this variable to be
declared, so change this bundle to look the same as other libraries.
Note that in Node, the IIFE will never actually return, so this can have
no effect. On web, it will return in order to yield control back to the
event loop (as on web, postMessage is used to communicate).
needsUpdate may be wrong when the branch changes; these ones are now so
fast thanks to being pure JS that we can just always run their contents
and be sure that the outputs are right.
This file is pretty much the same as it was when it was committed in
2017; these days, we can write clearer code with async/await and new FS
APIs.
Additionally, we can improve the performance of this script by using a
newer/faster/maintained XML library. This will enable us to run the
script unconditionally in a later commit.
Profiling the build roughly half of the time spent loading the
build is spent importing typescript.js, for this one function.
Since this stack is already adding required devDependencies, switch
readJson to use jsonc-parser (published by the VS Code team), rather
than importing the entire LKG typescript.js library.
The old gulpfile produced lib.d.ts files with mixed newlines, thanks to
the files containing CRLF, but the gulp streams adding in LF.
Now they're all LF, which matches every other file in built / lib, but
our baselines are sensitive to this. Rerun the tests and accept them.
This eliminates a significant number of dependencies, eliminating all
npm audit issues, speeding up `npm ci` by 20%, and overall making the
build faster (faster startup, direct code is faster than streams, etc)
and clearer to understand.
I'm finding it much easier to make build changes for the module
transform with this; I can more clearly indicate task dependencies and
prevent running tasks that don't need to be run.
Given we're changing our build process entirely (new deps, new steps),
it seems like this is a good time to change things up.
In namespaces, we'd have access to a variable named "ts" when debugging,
because that was just the ts namespace in the current file. But when
modules, that variable doesn't exist, either because we are pure modules
(so no ts variable), or named something else (when bundled, for export).
Tack a "ts" object onto the globals, which should make this easier. Of
course, someone may eventually declare a variable in the top level scope
named "ts" and break this, but we can cross that bridge when we come to
it.