Skip to content

Commit 3f4d16a

Browse files
authored
Remove lib folder (LKG) and use node_modules for building (microsoft#52226)
1 parent 2f229ab commit 3f4d16a

File tree

105 files changed

+51
-763515
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+51
-763515
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,26 @@ jobs:
9696
with:
9797
node-version: "*"
9898
check-latest: true
99+
100+
# Pre-build the base branch so we can check lib folder size changes.
101+
# Note that github.sha points to a merge commit, meaning we're testing
102+
# the base branch versus the base branch with the PR applied.
103+
- if: github.event_name == 'pull_request'
104+
run: |
105+
if [ ! -d lib ]; then
106+
git fetch origin ${{ github.base_ref }}
107+
git checkout ${{ github.base_ref }}
108+
npm ci
109+
npx hereby lkg
110+
mkdir /tmp/lkg
111+
mv lib /tmp/lkg/
112+
git restore lib
113+
git clean -fdx lib
114+
git checkout ${{ github.sha }}
115+
rm -rf lib
116+
mv /tmp/lkg/lib .
117+
fi
118+
99119
- run: npm ci
100120

101121
- run: npx hereby lkg

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,4 @@ TEST-results.xml
6262
package-lock.json
6363
.eslintcache
6464
*v8.log
65+
lib/

.vscode/settings.template.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// Rename this file 'settings.json' or merge its
22
// contents into your existing settings.
33
{
4-
// To use the last-known-good (LKG) compiler version:
5-
// "typescript.tsdk": "lib"
6-
74
// To use the locally built compiler, after 'npm run build':
85
// "typescript.tsdk": "built/local"
96

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"label": "tsc: watch ./src",
2626
"type": "shell",
2727
"command": "node",
28-
"args": ["${workspaceFolder}/lib/tsc.js", "--build", "${workspaceFolder}/src", "--watch"],
28+
"args": ["${workspaceFolder}/node_modules/tsc.js", "--build", "${workspaceFolder}/src", "--watch"],
2929
"group": "build",
3030
"isBackground": true,
3131
"problemMatcher": [

Herebyfile.mjs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import del from "del";
66
import esbuild from "esbuild";
77
import { EventEmitter } from "events";
88
import fs from "fs";
9-
import fsExtra from "fs-extra";
109
import _glob from "glob";
1110
import { task } from "hereby";
1211
import path from "path";
@@ -833,11 +832,19 @@ export const produceLKG = task({
833832
if (missingFiles.length > 0) {
834833
throw new Error("Cannot replace the LKG unless all built targets are present in directory 'built/local/'. The following files are missing:\n" + missingFiles.join("\n"));
835834
}
836-
const sizeBefore = getDirSize("lib");
835+
836+
/** @type {number | undefined} */
837+
let sizeBefore;
838+
if (fs.existsSync("lib")) {
839+
sizeBefore = getDirSize("lib");
840+
}
837841
await exec(process.execPath, ["scripts/produceLKG.mjs"]);
838-
const sizeAfter = getDirSize("lib");
839-
if (sizeAfter > (sizeBefore * 1.10)) {
840-
throw new Error("The lib folder increased by 10% or more. This likely indicates a bug.");
842+
843+
if (sizeBefore !== undefined) {
844+
const sizeAfter = getDirSize("lib");
845+
if (sizeAfter > (sizeBefore * 1.10)) {
846+
throw new Error("The lib folder increased by 10% or more. This likely indicates a bug.");
847+
}
841848
}
842849
}
843850
});
@@ -884,14 +891,3 @@ export const help = task({
884891
hiddenFromTaskList: true,
885892
run: () => exec("hereby", ["--tasks"], { hidePrompt: true }),
886893
});
887-
888-
export const bumpLkgToNightly = task({
889-
name: "bump-lkg-to-nightly",
890-
description: "Bumps typescript in package.json to the latest nightly and copies it to LKG.",
891-
run: async () => {
892-
await exec("npm", ["install", "--save-dev", "--save-exact", "typescript@next"]);
893-
await fs.promises.rm("lib", { recursive: true, force: true });
894-
await fsExtra.copy("node_modules/typescript/lib", "lib");
895-
await fs.promises.writeFile("lib/.gitattributes", "* text eol=lf");
896-
}
897-
});

lib/.gitattributes

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/README.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

lib/cancellationToken.js

Lines changed: 0 additions & 91 deletions
This file was deleted.

0 commit comments

Comments
 (0)