fix(language-service): Simplify resolution logic in banner (#34262)
Due to a bug in the existing banner, `typescript` module was require-d instead of reusing the module passed in from tsserver. This bug is caused by some source files in language-service that imports `typescript` instead of `typescript/lib/tsserverlibrary`. This is not an unsupported use case, it's just that when typescript is resolved in the banner we have to be very careful about which modules to "require". The convoluted logic in the banner makes it very hard to detect anomalies. This commit cleans it up and removes a lot of unneeded code. This commit also removes `ts` import in typescript_host.ts and use `tss` instead to make it less confusing. PR Close #34262
This commit is contained in:

committed by
Andrew Kushnir

parent
6c70ba7376
commit
7dfd327099
28
packages/language-service/bundles/banner.js
Normal file
28
packages/language-service/bundles/banner.js
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* @license Angular v0.0.0-PLACEHOLDER
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
* License: MIT
|
||||
*/
|
||||
|
||||
let $deferred;
|
||||
function define(modules, callback) {
|
||||
$deferred = {modules, callback};
|
||||
}
|
||||
module.exports = function(provided) {
|
||||
const ts = provided['typescript'];
|
||||
if (!ts) {
|
||||
throw new Error('Caller does not provide typescript module');
|
||||
}
|
||||
const results = {};
|
||||
const resolvedModules = $deferred.modules.map(m => {
|
||||
if (m === 'exports') {
|
||||
return results;
|
||||
}
|
||||
if (m === 'typescript' || m === 'typescript/lib/tsserverlibrary') {
|
||||
return ts;
|
||||
}
|
||||
return require(m);
|
||||
});
|
||||
$deferred.callback(...resolvedModules);
|
||||
return results;
|
||||
};
|
Reference in New Issue
Block a user