@@ -404,27 +404,50 @@ export const watchMin = task({
404
404
405
405
406
406
407
- const { main : lssl , build : buildLssl , watch : watchLssl } = entrypointBuildTask ( {
407
+ // This is technically not enough to make tsserverlibrary loadable in the
408
+ // browser, but it's unlikely that anyone has actually been doing that.
409
+ const lsslJs = `
410
+ if (typeof module !== "undefined" && module.exports) {
411
+ module.exports = require("./typescript.js");
412
+ }
413
+ else {
414
+ throw new Error("tsserverlibrary requires CommonJS; use typescript.js instead");
415
+ }
416
+ ` ;
417
+
418
+ const lsslDts = `
419
+ import ts = require("./typescript.js");
420
+ export = ts;
421
+ ` ;
422
+
423
+ const lsslDtsInternal = `
424
+ import ts = require("./typescript.internal.js");
425
+ export = ts;
426
+ ` ;
427
+
428
+ /**
429
+ * @param {string } contents
430
+ */
431
+ async function fileContentsWithCopyright ( contents ) {
432
+ return await copyright ( ) + contents . trim ( ) . replace ( / \r \n / g, "\n" ) + "\n" ;
433
+ }
434
+
435
+ const lssl = task ( {
408
436
name : "lssl" ,
409
437
description : "Builds language service server library" ,
410
- buildDeps : [ generateDiagnostics ] ,
411
- project : "src/tsserverlibrary" ,
412
- srcEntrypoint : "./src/tsserverlibrary/tsserverlibrary.ts" ,
413
- builtEntrypoint : "./built/local/tsserverlibrary/tsserverlibrary.js" ,
414
- output : "./built/local/tsserverlibrary.js" ,
415
- mainDeps : [ generateLibs ] ,
416
- bundlerOptions : { exportIsTsObject : true } ,
438
+ dependencies : [ services ] ,
439
+ run : async ( ) => {
440
+ await fs . promises . writeFile ( "./built/local/tsserverlibrary.js" , await fileContentsWithCopyright ( lsslJs ) ) ;
441
+ }
417
442
} ) ;
418
- export { lssl , watchLssl } ;
419
443
420
444
export const dtsLssl = task ( {
421
445
name : "dts-lssl" ,
422
446
description : "Bundles tsserverlibrary.d.ts" ,
423
- dependencies : [ buildLssl ] ,
447
+ dependencies : [ dtsServices ] ,
424
448
run : async ( ) => {
425
- if ( needsUpdate ( "./built/local/tsserverlibrary/tsconfig.tsbuildinfo" , [ "./built/local/tsserverlibrary.d.ts" , "./built/local/tsserverlibrary.internal.d.ts" ] ) ) {
426
- await runDtsBundler ( "./built/local/tsserverlibrary/tsserverlibrary.d.ts" , "./built/local/tsserverlibrary.d.ts" ) ;
427
- }
449
+ await fs . promises . writeFile ( "./built/local/tsserverlibrary.d.ts" , await fileContentsWithCopyright ( lsslDts ) ) ;
450
+ await fs . promises . writeFile ( "./built/local/tsserverlibrary.internal.d.ts" , await fileContentsWithCopyright ( lsslDtsInternal ) ) ;
428
451
}
429
452
} ) ;
430
453
@@ -563,7 +586,7 @@ export const watchLocal = task({
563
586
name : "watch-local" ,
564
587
description : "Watches the full compiler and services" ,
565
588
hiddenFromTaskList : true ,
566
- dependencies : [ localize , watchTsc , watchTsserver , watchServices , watchLssl , watchOtherOutputs , dts , watchSrc ] ,
589
+ dependencies : [ localize , watchTsc , watchTsserver , watchServices , lssl , watchOtherOutputs , dts , watchSrc ] ,
567
590
} ) ;
568
591
569
592
const runtestsDeps = [ tests , generateLibs ] . concat ( cmdLineOptions . typecheck ? [ dts ] : [ ] ) ;
0 commit comments