Remove lib folder (LKG) and use node_modules for building (#52226)

This commit is contained in:
Jake Bailey
2023-03-07 15:34:47 -08:00
committed by GitHub
parent 2f229ab870
commit 3f4d16a25e
105 changed files with 51 additions and 763515 deletions

View File

@@ -35,7 +35,7 @@ const parsed = minimist(process.argv.slice(2), {
workers: +(process.env.workerCount ?? 0) || ((os.cpus().length - (ci ? 0 : 1)) || 1),
failed: false,
keepFailed: false,
lkg: true,
lkg: false,
dirty: false,
built: false,
ci,
@@ -48,8 +48,8 @@ const parsed = minimist(process.argv.slice(2), {
/** @type {CommandLineOptions} */
const options = /** @type {any} */ (parsed);
if (options.built) {
options.lkg = false;
if (options.built && options.lkg) {
throw new Error("--built and --lkg are mutually exclusive");
}
if (!options.bundle && !options.typecheck) {

View File

@@ -30,11 +30,14 @@ class ProjectQueue {
}
}
const execTsc = (/** @type {string[]} */ ...args) =>
exec(process.execPath,
[resolve(findUpRoot(), cmdLineOptions.lkg ? "./lib/tsc.js" : "./built/local/tsc.js"),
"-b", ...args],
{ hidePrompt: true });
const tscPath = resolve(
findUpRoot(),
cmdLineOptions.lkg ? "./lib/tsc.js" :
cmdLineOptions.built ? "./built/local/tsc.js" :
"./node_modules/typescript/lib/tsc.js",
);
const execTsc = (/** @type {string[]} */ ...args) => exec(process.execPath, [tscPath, "-b", ...args], { hidePrompt: true });
const projectBuilder = new ProjectQueue((projects) => execTsc(...(cmdLineOptions.bundle ? [] : ["--emitDeclarationOnly", "false"]), ...projects));
@@ -48,7 +51,7 @@ const projectCleaner = new ProjectQueue((projects) => execTsc("--clean", ...proj
/**
* @param {string} project
*/
export const cleanProject = (project) => projectCleaner.enqueue(project);
export const cleanProject = (project) => projectCleaner.enqueue(project);
const projectWatcher = new ProjectQueue((projects) => execTsc("--watch", "--preserveWatchOutput", ...projects));

View File

@@ -9,10 +9,9 @@ import assert, { fail } from "assert";
import fs from "fs";
import minimist from "minimist";
import path from "path";
import ts from "typescript";
import url from "url";
import ts from "../lib/typescript.js";
const __filename = url.fileURLToPath(new URL(import.meta.url));
const __dirname = path.dirname(__filename);
@@ -198,7 +197,7 @@ function containsPublicAPI(symbol) {
function nodeToLocation(node) {
const sourceFile = node.getSourceFile();
const lc = sourceFile.getLineAndCharacterOfPosition(node.pos);
return `${sourceFile.fileName}:${lc.line+1}:${lc.character+1}`;
return `${sourceFile.fileName}:${lc.line + 1}:${lc.character + 1}`;
}
/**
@@ -222,7 +221,7 @@ const scopeStack = [];
* @param {string} name
*/
function findInScope(name) {
for (let i = scopeStack.length-1; i >= 0; i--) {
for (let i = scopeStack.length - 1; i >= 0; i--) {
const scope = scopeStack[i];
const symbol = scope.get(name);
if (symbol) {
@@ -335,7 +334,7 @@ function emitAsNamespace(name, moduleSymbol) {
assert(moduleSymbol.flags & ts.SymbolFlags.ValueModule, "moduleSymbol is not a module");
scopeStack.push(new Map());
const currentScope = scopeStack[scopeStack.length-1];
const currentScope = scopeStack[scopeStack.length - 1];
const target = containsPublicAPI(moduleSymbol) ? WriteTarget.Both : WriteTarget.Internal;

View File

@@ -1,4 +1,3 @@
import del from "del";
import fs from "fs-extra";
import glob from "glob";
import path from "path";
@@ -15,7 +14,7 @@ const dest = path.join(root, "lib");
async function produceLKG() {
console.log(`Building LKG from ${source} to ${dest}`);
await del(`${dest.replace(/\\/g, "/")}/**`, { ignore: ["**/README.md"] });
await (fs.rm || fs.rmdir)(dest, { recursive: true, force: true });
await fs.mkdirp(dest);
await copyLibFiles();
await copyLocalizedDiagnostics();