Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .dprint.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
// Needs to be LF to have a working shebang.
"packages/typescript/bin/tsc",
"tsc/internal/bundled/source/**",
"tsc/internal/locale/lcl/**",
"tsc/internal/diagnostics/diagnosticMessages.generated.json",
"tsc/internal/diagnostics/loc/*.generated.json",
"packages/typescript/dist/**",
"packages/typescript/tsconfig.tsbuildinfo",
"packages/vscode-typescript/dist/**",
Expand Down
39 changes: 37 additions & 2 deletions Herebyfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ const builtLocal = "./built/local";
const libsDir = "./tsc/internal/bundled/libs";
const libsRegexp = /(?:^|[\\/])internal[\\/]bundled[\\/]libs[\\/]/;

const locDir = "./tsc/internal/diagnostics/loc";
const locRegexp = /(?:^|[\\/])internal[\\/]diagnostics[\\/]loc[\\/]/;

/**
* @param {string} out
*/
Expand All @@ -171,12 +174,33 @@ async function generateLibs(out) {
}));
}

/**
* @param {string} out
*/
async function generateLocs(out) {
const locOut = path.join(out, "loc");
await rimraf(locOut);
await fs.promises.mkdir(locOut, { recursive: true });

const locs = (await fs.promises.readdir(locDir)).filter(loc => loc.endsWith(".generated.json"));

await Promise.all(locs.map(async loc => {
await fs.promises.copyFile(path.join(locDir, loc), path.join(locOut, loc));
}));
}

export const lib = task({
name: "lib",
description: "Copies the libs to built/local.",
run: () => generateLibs(builtLocal),
});

export const loc = task({
name: "loc",
description: "Copies the locale files to built/local.",
run: () => generateLocs(builtLocal),
});

/**
* Gets the release build flags for stripping debug info.
* @param {string} [versionOverride] Optional version to embed in the binary.
Expand Down Expand Up @@ -214,7 +238,7 @@ export const tscBuild = task({

export const tsgo = task({
name: "tsgo",
dependencies: [lib, tscBuild],
dependencies: [lib, loc, tscBuild],
});

export const local = task({
Expand All @@ -233,23 +257,28 @@ export const buildWatch = task({
run: async () => {
await watchDebounced("build:watch", async (paths, abortSignal) => {
let libsChanged = false;
let locsChanged = false;
let goChanged = false;

if (paths) {
for (const p of paths) {
if (libsRegexp.test(p)) {
libsChanged = true;
}
else if (locRegexp.test(p)) {
locsChanged = true;
}
else if (p.endsWith(".go")) {
goChanged = true;
}
if (libsChanged && goChanged) {
if (libsChanged && locsChanged && goChanged) {
break;
}
}
}
else {
libsChanged = true;
locsChanged = true;
goChanged = true;
}

Expand All @@ -258,6 +287,11 @@ export const buildWatch = task({
await generateLibs(builtLocal);
}

if (locsChanged) {
console.log("Copying locale files...");
await generateLocs(builtLocal);
}

if (goChanged) {
console.log("Building tsgo...");
await buildTsc({ abortSignal });
Expand Down Expand Up @@ -1981,6 +2015,7 @@ async function runBuildNativePreviewPackages() {
await fs.promises.writeFile(path.join(npmDir, "README.md"), readme.join("\n") + "\n");

await generateLibs(out);
await generateLocs(out);

const exeName = nativePreviewExeName(nodeOs);
await buildTsc({
Expand Down
14 changes: 14 additions & 0 deletions tools/LocProject.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"Projects": [
{
"LocItems": [
{
"SourceFile": "tsc\\internal\\diagnostics\\diagnosticMessages.generated.json",
"Languages": "cs-CZ;de-DE;es-ES;fr-FR;it-IT;ja-JP;ko-KR;pl-PL;pt-BR;ru-RU;tr-TR;zh-CN;zh-TW",
"CopyOption": "UsePlaceholders",
"OutputPath": "tsc\\internal\\diagnostics\\loc\\{Lang}.generated.json"
}
]
}
]
}
1 change: 0 additions & 1 deletion tsc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require (
github.com/Microsoft/go-winio v0.6.2
github.com/go-json-experiment/json v0.0.0-20260623181947-01eb4420fa68
github.com/google/go-cmp v0.7.0
github.com/klauspost/compress v1.19.0
github.com/mackerelio/go-osstat v0.2.7
github.com/peter-evans/patience v0.3.0
github.com/zeebo/xxh3 v1.1.0
Expand Down
2 changes: 0 additions & 2 deletions tsc/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ github.com/go-json-experiment/json v0.0.0-20260623181947-01eb4420fa68 h1:KZaTBSy
github.com/go-json-experiment/json v0.0.0-20260623181947-01eb4420fa68/go.mod h1:tphK2c80bpPhMOI4v6bIc2xWywPfbqi1Z06+RcrMkDg=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/klauspost/compress v1.19.0 h1:sXLILfc9jV2QYWkzFOPWStmcUVH2RHEB1JCdY2oVvCQ=
github.com/klauspost/compress v1.19.0/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
github.com/mackerelio/go-osstat v0.2.7 h1:TCavZi10wF49bT6iQZ9eT2keGZQpC69MTDfdJej5e94=
Expand Down
Loading