-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Move tsserverlibrary.js to typescript.js, make tsserverlibrary.js a shim #55273
Changes from all commits
f344f9b
ae24827
b40497c
7d0cd83
d3fc401
1f6d337
e9c8a61
0027c61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -404,27 +404,50 @@ export const watchMin = task({ | |
|
||
|
||
|
||
const { main: lssl, build: buildLssl, watch: watchLssl } = entrypointBuildTask({ | ||
// This is technically not enough to make tsserverlibrary loadable in the | ||
// browser, but it's unlikely that anyone has actually been doing that. | ||
const lsslJs = ` | ||
if (typeof module !== "undefined" && module.exports) { | ||
module.exports = require("./typescript.js"); | ||
} | ||
else { | ||
throw new Error("tsserverlibrary requires CommonJS; use typescript.js instead"); | ||
} | ||
`; | ||
|
||
const lsslDts = ` | ||
import ts = require("./typescript.js"); | ||
export = ts; | ||
`; | ||
|
||
const lsslDtsInternal = ` | ||
import ts = require("./typescript.internal.js"); | ||
export = ts; | ||
`; | ||
|
||
/** | ||
* @param {string} contents | ||
*/ | ||
async function fileContentsWithCopyright(contents) { | ||
return await copyright() + contents.trim().replace(/\r\n/g, "\n") + "\n"; | ||
} | ||
|
||
const lssl = task({ | ||
name: "lssl", | ||
description: "Builds language service server library", | ||
buildDeps: [generateDiagnostics], | ||
project: "src/tsserverlibrary", | ||
srcEntrypoint: "./src/tsserverlibrary/tsserverlibrary.ts", | ||
builtEntrypoint: "./built/local/tsserverlibrary/tsserverlibrary.js", | ||
output: "./built/local/tsserverlibrary.js", | ||
mainDeps: [generateLibs], | ||
bundlerOptions: { exportIsTsObject: true }, | ||
dependencies: [services], | ||
run: async () => { | ||
await fs.promises.writeFile("./built/local/tsserverlibrary.js", await fileContentsWithCopyright(lsslJs)); | ||
} | ||
}); | ||
export { lssl, watchLssl }; | ||
|
||
export const dtsLssl = task({ | ||
name: "dts-lssl", | ||
description: "Bundles tsserverlibrary.d.ts", | ||
dependencies: [buildLssl], | ||
dependencies: [dtsServices], | ||
run: async () => { | ||
if (needsUpdate("./built/local/tsserverlibrary/tsconfig.tsbuildinfo", ["./built/local/tsserverlibrary.d.ts", "./built/local/tsserverlibrary.internal.d.ts"])) { | ||
await runDtsBundler("./built/local/tsserverlibrary/tsserverlibrary.d.ts", "./built/local/tsserverlibrary.d.ts"); | ||
} | ||
await fs.promises.writeFile("./built/local/tsserverlibrary.d.ts", await fileContentsWithCopyright(lsslDts)); | ||
await fs.promises.writeFile("./built/local/tsserverlibrary.internal.d.ts", await fileContentsWithCopyright(lsslDtsInternal)); | ||
} | ||
}); | ||
|
||
|
@@ -563,7 +586,7 @@ export const watchLocal = task({ | |
name: "watch-local", | ||
description: "Watches the full compiler and services", | ||
hiddenFromTaskList: true, | ||
dependencies: [localize, watchTsc, watchTsserver, watchServices, watchLssl, watchOtherOutputs, dts, watchSrc], | ||
dependencies: [localize, watchTsc, watchTsserver, watchServices, lssl, watchOtherOutputs, dts, watchSrc], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Last minute change; we still have to run |
||
}); | ||
|
||
const runtestsDeps = [tests, generateLibs].concat(cmdLineOptions.typecheck ? [dts] : []); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import * as compiler from "../_namespaces/compiler"; | ||
import * as documents from "../_namespaces/documents"; | ||
import * as fakes from "../_namespaces/fakes"; | ||
import * as Harness from "../_namespaces/Harness"; | ||
|
@@ -19,21 +18,6 @@ describe("unittests:: Public APIs", () => { | |
it("should be acknowledged when they change", () => { | ||
Harness.Baseline.runBaseline(api, fileContent, { PrintDiff: true }); | ||
}); | ||
|
||
it("should compile", () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We actually already test this by nature of the new public API compiler tests I added, which disable skipLibCheck to test the actual public API. This change could be pulled out into another PR but it's needed for this PR because this test assumes that our d.ts files are self-contained, which is no longer true. Alternatively, I can just make There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is is possible to create symlinks for tsserverlibrary.js and tsserverLibrary,d,ts to point to typescript.js and typescript.d.ts instead There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right now In terms of the package itself, we can't really use symlinks as those are not universally supported on Windows or by package managers themselves. There are ways that people store packages which can't contain symlinks at all (e.g., zips, used in yarn, for example), and it'd be a bit dicey to commit back to a release branch. |
||
const fs = vfs.createFromFileSystem(Harness.IO, /*ignoreCase*/ false); | ||
fs.linkSync(`${vfs.builtFolder}/${fileName}`, `${vfs.srcFolder}/${fileName}`); | ||
const sys = new fakes.System(fs); | ||
const options: ts.CompilerOptions = { | ||
...ts.getDefaultCompilerOptions(), | ||
strict: true, | ||
exactOptionalPropertyTypes: true, | ||
lib: ["lib.es2018.d.ts"], | ||
}; | ||
const host = new fakes.CompilerHost(sys, options); | ||
const result = compiler.compileFiles(host, [`${vfs.srcFolder}/${fileName}`], options); | ||
assert(!result.diagnostics || !result.diagnostics.length, Harness.Compiler.minimalDiagnosticsToString(result.diagnostics, /*pretty*/ true)); | ||
}); | ||
} | ||
|
||
describe("for the language service and compiler", () => { | ||
|
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
{ "path": "../compiler" }, | ||
{ "path": "../jsTyping" }, | ||
{ "path": "../services" }, | ||
{ "path": "../deprecatedCompat" } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this intentional to drop drepcated compat from typescript.js ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's already in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it should still be here since references are not transitive. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They aren't? But, tsserverlibrary's been set up this way since I merged modules and has been fine; what breaks if this isn't done? If it's about the code itself, it's imported in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Build as in typecheck or as in write out files? I guess dts emit may matter for this... I'm surprised in that I think a lot of monorepo projects aren't just bulk including all transitive dependencies in their tsconfigs as that would get unweildy. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aha! Thanks! I'll go figure out which transitive things we're missing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I pulled this out into #55339, which I'd like to merge first. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given this isn't a regression (all I did was move |
||
{ "path": "../server" } | ||
], | ||
"include": ["**/*"] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little unfortunate for anyone who is attempting to pull these internal types, e.g. byots/ts-expose-internals but the fix would be quite simple for them; just use
typescript.internal.d.ts
for both.