Skip to content

Commit 8b44ce2

Browse files
committed
Emitting tsserverlibrary as an external module.
1 parent 88c6825 commit 8b44ce2

File tree

8 files changed

+35
-28
lines changed

8 files changed

+35
-28
lines changed

Gulpfile.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,9 @@ gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => {
472472
.pipe(sourcemaps.write("."))
473473
.pipe(gulp.dest(".")),
474474
dts.pipe(prependCopyright())
475+
.pipe(insert.transform((content) => {
476+
return content + "\r\nexport = ts;";
477+
}))
475478
.pipe(gulp.dest("."))
476479
]);
477480
});

Jakefile.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ var servicesSources = [
183183
return path.join(servicesDirectory, f);
184184
}));
185185

186-
var serverCoreSources = [
187-
"types.d.ts",
186+
var baseServerCoreSources = [
187+
"types.ts",
188188
"shared.ts",
189189
"utilities.ts",
190190
"scriptVersionCache.ts",
@@ -195,19 +195,24 @@ var serverCoreSources = [
195195
"editorServices.ts",
196196
"protocol.ts",
197197
"session.ts",
198-
"server.ts"
199198
].map(function (f) {
200199
return path.join(serverDirectory, f);
201200
});
202201

202+
var serverCoreSources = [
203+
"server.ts"
204+
].map(function (f) {
205+
return path.join(serverDirectory, f);
206+
}).concat(baseServerCoreSources);
207+
203208
var cancellationTokenSources = [
204209
"cancellationToken.ts"
205210
].map(function (f) {
206211
return path.join(cancellationTokenDirectory, f);
207212
});
208213

209214
var typingsInstallerSources = [
210-
"../types.d.ts",
215+
"../types.ts",
211216
"../shared.ts",
212217
"typingsInstaller.ts",
213218
"nodeTypingsInstaller.ts"
@@ -216,20 +221,7 @@ var typingsInstallerSources = [
216221
});
217222

218223
var serverSources = serverCoreSources.concat(servicesSources);
219-
220-
var languageServiceLibrarySources = [
221-
"protocol.ts",
222-
"utilities.ts",
223-
"scriptVersionCache.ts",
224-
"scriptInfo.ts",
225-
"lsHost.ts",
226-
"project.ts",
227-
"editorServices.ts",
228-
"session.ts",
229-
230-
].map(function (f) {
231-
return path.join(serverDirectory, f);
232-
}).concat(servicesSources);
224+
var languageServiceLibrarySources = baseServerCoreSources.concat(servicesSources);
233225

234226
var harnessCoreSources = [
235227
"harness.ts",
@@ -727,7 +719,15 @@ compileFile(
727719
[builtLocalDirectory, copyright, builtLocalCompiler].concat(languageServiceLibrarySources).concat(libraryTargets),
728720
/*prefixes*/[copyright],
729721
/*useBuiltCompiler*/ true,
730-
{ noOutFile: false, generateDeclarations: true });
722+
{ noOutFile: false, generateDeclarations: true },
723+
/*callback*/ function () {
724+
725+
prependFile(copyright, tsserverLibraryDefinitionFile);
726+
727+
// Appending 'export = ts;' at the end of the server library file to turn it into an external module
728+
var tsserverLibraryDefinitionFileContents = fs.readFileSync(tsserverLibraryDefinitionFile).toString() + "\r\nexport = ts;";
729+
fs.writeFileSync(tsserverLibraryDefinitionFile, tsserverLibraryDefinitionFileContents);
730+
});
731731

732732
// Local target to build the language service server library
733733
desc("Builds language service server library");

src/server/shared.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// <reference path="types.d.ts" />
1+
/// <reference path="types.ts" />
22

33
namespace ts.server {
44
export const ActionSet: ActionSet = "action::set";

src/server/tsconfig.library.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
{
22
"compilerOptions": {
33
"noImplicitAny": true,
4+
"noImplicitThis": true,
45
"removeComments": true,
56
"preserveConstEnums": true,
7+
"pretty": true,
68
"outFile": "../../built/local/tsserverlibrary.js",
79
"sourceMap": true,
810
"stripInternal": true,
9-
"declaration": true,
10-
"types": [],
11+
"types": [
12+
"node"
13+
],
1114
"target": "es5",
1215
"noUnusedLocals": true,
13-
"noUnusedParameters": true
16+
"noUnusedParameters": true,
17+
"declaration": true
1418
},
1519
"files": [
1620
"../services/shims.ts",
@@ -19,11 +23,11 @@
1923
"utilities.ts",
2024
"scriptVersionCache.ts",
2125
"scriptInfo.ts",
22-
"lshost.ts",
26+
"lsHost.ts",
2327
"typingsCache.ts",
2428
"project.ts",
2529
"editorServices.ts",
26-
"protocol.d.ts",
30+
"protocol.ts",
2731
"session.ts"
2832
]
2933
}
File renamed without changes.

src/server/typingsInstaller/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"noUnusedParameters": true
1717
},
1818
"files": [
19-
"../types.d.ts",
19+
"../types.ts",
2020
"../shared.ts",
2121
"typingsInstaller.ts",
2222
"nodeTypingsInstaller.ts"

src/server/typingsInstaller/typingsInstaller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// <reference path="../../compiler/core.ts" />
22
/// <reference path="../../compiler/moduleNameResolver.ts" />
33
/// <reference path="../../services/jsTyping.ts"/>
4-
/// <reference path="../types.d.ts"/>
4+
/// <reference path="../types.ts"/>
55
/// <reference path="../shared.ts"/>
66

77
namespace ts.server.typingsInstaller {

src/server/utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// <reference path="types.d.ts" />
1+
/// <reference path="types.ts" />
22
/// <reference path="shared.ts" />
33

44
namespace ts.server {

0 commit comments

Comments
 (0)