Skip to content

build: use a single top-level tsc -b for all packages #3090

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

Merged
merged 7 commits into from
Nov 24, 2022
Merged
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
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.nyc_output
dist/
docs/
packages/tsconfig.json
packages/*/*/dist
packages/*/*/doc
packages/*/*/index.d.ts
Expand Down
20 changes: 0 additions & 20 deletions .swcrc

This file was deleted.

11 changes: 3 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
},
"scripts": {
"clean": "rimraf dist && lerna exec -- rimraf dist tsconfig.tsbuildinfo",
"build": "lerna exec -- tsc --emitDeclarationOnly && yarn build:fast",
"build:fast": "lerna exec -- swc src --out-dir dist --quiet --extensions \".ts\" --config-file ../../../.swcrc",
"build:full": "lerna exec -- tsc -b",
"build": "tsc -b packages",
"build:watch": "yarn build --watch",
"postbuild": "ts-node tools/test-dist",
"docs": "yarn build:full && yarn docs:generate",
"docs": "yarn build && yarn docs:generate",
"docs:generate": "yarn docs:plugin && node --max-old-space-size=8192 -r ts-node/register ./tools/gen-docs.ts",
"docs:plugin": "cd ./tools/doc-plugin && yarn build",
"docs:deploy:build": "yarn docs",
"lerna:publish": "lerna publish --force-publish --conventional-commits --no-changelog",
"lint": "prettier --check . && eslint .",
"lint:fix": "prettier --write .",
Expand Down Expand Up @@ -81,9 +79,6 @@
"devDependencies": {
"@knodes/typedoc-plugin-monorepo-readmes": "0.22.5",
"@malept/eslint-config": "^2.0.0",
"@swc/cli": "^0.1.49",
"@swc/core": "^1.2.87",
"@swc/register": "^0.1.7",
"@types/chai": "^4.2.12",
"@types/chai-as-promised": "^7.1.2",
"@types/cross-spawn": "^6.0.1",
Expand Down
1 change: 0 additions & 1 deletion tools/gen-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ function generatedSidebarGroups(projReflection: typedoc.ProjectReflection) {
excludeProtected: true,
externalPattern: ['**/node_modules/@types/node/**', '**/node_modules/typescript/**'],
hideGenerator: true,
includeVersion: true,
name: 'Electron Forge',
plugin: ['typedoc-plugin-rename-defaults', 'typedoc-plugin-missing-exports', './tools/doc-plugin/dist/index.js', '@knodes/typedoc-plugin-monorepo-readmes'],
theme: 'forge-theme',
Expand Down
14 changes: 14 additions & 0 deletions tools/gen-tsconfigs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ function filterDupes<T>(arr: readonly T[]): T[] {
const BASE_TS_CONFIG = JSON.parse(await fs.readFile(path.resolve(__dirname, '../tsconfig.base.json'), 'utf-8'));
const packages = await getPackageInfo();

// Generate a root tsconfig.json for project references
const rootPackagesConfig = {
files: [],
references: packages.map((p) => {
const pathArr = p.path.split(path.sep);
const pathFromPackages = pathArr.slice(pathArr.indexOf('packages') + 1).join(path.sep);
return {
path: pathFromPackages,
};
}),
};

fs.writeFile(path.resolve(__dirname, '../packages/tsconfig.json'), JSON.stringify(rootPackagesConfig, null, 2));

// Do each package in parallel
await Promise.all(
packages.map((pkg) => {
Expand Down
14 changes: 11 additions & 3 deletions tools/test-dist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@ const BASE_DIR = path.resolve(__dirname, '..');
const PACKAGES_DIR = path.resolve(BASE_DIR, 'packages');

(async () => {
const dirsToCheck = [];
const dirsToCheck: string[] = [];

for (const subDir of await fs.readdir(PACKAGES_DIR)) {
for (const packageDir of await fs.readdir(path.resolve(PACKAGES_DIR, subDir))) {
dirsToCheck.push(path.resolve(PACKAGES_DIR, subDir, packageDir));
const subDirPath = path.resolve(PACKAGES_DIR, subDir);
const stat = await fs.lstat(subDirPath);
if (stat.isDirectory()) {
for (const packageDir of await fs.readdir(subDirPath)) {
const packageDirPath = path.resolve(PACKAGES_DIR, subDir, packageDir);
const stat = await fs.lstat(packageDirPath);
if (stat.isDirectory()) {
dirsToCheck.push(packageDirPath);
}
}
}
}

Expand Down
41 changes: 25 additions & 16 deletions tools/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@ export const getPackageInfo = async (): Promise<Package[]> => {
const packages: Package[] = [];

for (const subDir of await fs.readdir(PACKAGES_DIR)) {
for (const packageDir of await fs.readdir(path.resolve(PACKAGES_DIR, subDir))) {
const packagePath = path.resolve(PACKAGES_DIR, subDir, packageDir);
const pkg = await fs.readJson(path.resolve(packagePath, 'package.json'));
packages.push({
path: packagePath,
name: pkg.name,
manifest: pkg,
});
const subDirPath = path.resolve(PACKAGES_DIR, subDir);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used to assume that anything in the packages/ folder was a folder as well. Here, I add a little isDirectory() check to make sure that we don't assume package/foo is a folder.

const stat = await fs.lstat(subDirPath);

if (stat.isDirectory()) {
for (const packageDir of await fs.readdir(subDirPath)) {
const packagePath = path.resolve(subDirPath, packageDir);
const pkg = await fs.readJson(path.resolve(packagePath, 'package.json'));
packages.push({
path: packagePath,
name: pkg.name,
manifest: pkg,
});
}
}
}

Expand All @@ -33,14 +38,18 @@ export const getPackageInfoSync = (): Package[] => {
const packages: Package[] = [];

for (const subDir of fs.readdirSync(PACKAGES_DIR)) {
for (const packageDir of fs.readdirSync(path.resolve(PACKAGES_DIR, subDir))) {
const packagePath = path.resolve(PACKAGES_DIR, subDir, packageDir);
const pkg = fs.readJsonSync(path.resolve(packagePath, 'package.json'));
packages.push({
path: packagePath,
name: pkg.name,
manifest: pkg,
});
const subDirPath = path.resolve(PACKAGES_DIR, subDir);
const stat = fs.lstatSync(subDirPath);
if (stat.isDirectory()) {
for (const packageDir of fs.readdirSync(subDirPath)) {
const packagePath = path.resolve(subDirPath, packageDir);
const pkg = fs.readJsonSync(path.resolve(packagePath, 'package.json'));
packages.push({
path: packagePath,
name: pkg.name,
manifest: pkg,
});
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"target": "es2019",
"outDir": "dist",
"lib": ["dom", "es2019"],
"sourceMap": true,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches the behaviour from the .swcrc that we used in production.

"inlineSourceMap": true,
"rootDir": "src",
"experimentalDecorators": true,
"strict": true,
Expand Down
122 changes: 2 additions & 120 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2528,109 +2528,6 @@
resolved "https://registry.yarnpkg.com/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz#8da5c6530915653f3a1f38fd5f101d8c3f8079c5"
integrity sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==

"@swc/cli@^0.1.49":
version "0.1.55"
resolved "https://registry.yarnpkg.com/@swc/cli/-/cli-0.1.55.tgz#6c00b836ae56f35b4a5243f7fad5f9674470b016"
integrity sha512-akkLuRexFq8XTi6JNZ27mXD4wcKXLDSLj4g7YMU+/upFM8IeD1IEp1Mxtre7MzCZn+QOQgPF8N8IReJoHuSn3g==
dependencies:
commander "^7.1.0"
fast-glob "^3.2.5"
slash "3.0.0"
source-map "^0.7.3"

"@swc/core-android-arm-eabi@1.2.139":
version "1.2.139"
resolved "https://registry.yarnpkg.com/@swc/core-android-arm-eabi/-/core-android-arm-eabi-1.2.139.tgz#87a216fd40c0f8f482c92cf3eef85771140bcb1e"
integrity sha512-ceZNzueo6iazeO9b8txKFk/v1MOmHuCm53Cv0SMJdtEBLIs6GqpLnPzRBswnQEdL4Ge+EGD5YRtw3mAdSLcTzQ==

"@swc/core-android-arm64@1.2.139":
version "1.2.139"
resolved "https://registry.yarnpkg.com/@swc/core-android-arm64/-/core-android-arm64-1.2.139.tgz#41ce38212c38d7574aae8450e65b91fc66f45d8a"
integrity sha512-94kdkt+1zWJbxavSlTkTbTIklKjNByiCGYf920a/D5Nb0cuRXUHfxVPToHhzetFRMoNfnQPVhL3Wid/Gt02tBw==

"@swc/core-darwin-arm64@1.2.139":
version "1.2.139"
resolved "https://registry.yarnpkg.com/@swc/core-darwin-arm64/-/core-darwin-arm64-1.2.139.tgz#dc9085557d3f55650ec649221e0f6279ab8fa9df"
integrity sha512-l3C6ItB4OX1QEART1TnaUNzHeviDinbRQQZKJI8xo23HnhV0pvDjYl0D62R+1/7e8KiSweEG8BuKEtXPEYCBlw==

"@swc/core-darwin-x64@1.2.139":
version "1.2.139"
resolved "https://registry.yarnpkg.com/@swc/core-darwin-x64/-/core-darwin-x64-1.2.139.tgz#0e51a1be584e60deb7465b016db0797dd6aa2a7b"
integrity sha512-4KMTARit3LiJ+IZtxRAfiv7V7rrqryIxs+uZJmOfjenGIp3A+ygYzbm9PT/wfRiefL9Ds1nLBSAA1tQ6jiwObA==

"@swc/core-freebsd-x64@1.2.139":
version "1.2.139"
resolved "https://registry.yarnpkg.com/@swc/core-freebsd-x64/-/core-freebsd-x64-1.2.139.tgz#b43ab6a8f6d97c4e2c9a0fac2dc9b09d1625a818"
integrity sha512-qZFIV98J7IS692JSSsTWmhBB9jVv0zmqHm+65xAblitlZ06wyFpOF7cLBuJQPdEXxrmoD3z6skD879U5q89NGw==

"@swc/core-linux-arm-gnueabihf@1.2.139":
version "1.2.139"
resolved "https://registry.yarnpkg.com/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.2.139.tgz#53bc7ee2fa8d408dba1b1613756e92ebd39ba53f"
integrity sha512-DX/yRuOrDRoddvofDgbuXmJXFHtGL+M0TgQll+7M2bW293jTGT1D1dkQuTQ/oxiVyA5bXShm+/Rrh8ozNf/ieA==

"@swc/core-linux-arm64-gnu@1.2.139":
version "1.2.139"
resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.2.139.tgz#c7a29b2c5326a15425239b12c800894568e2fb98"
integrity sha512-ScLMFY121bzO4yOALxHlHut8Gj/cfJ74NL0JOzwtzL4lUJ1wkgmkHFJQNn5gXXrkTcfKR7o9D00R0WsbCfJGYA==

"@swc/core-linux-arm64-musl@1.2.139":
version "1.2.139"
resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.2.139.tgz#f788bb33039408374190d206378be72304404002"
integrity sha512-uSdVTMkBJtkfgKBAQxMz+lV/Kjx2IggWG1G57NIHJGNE2NMTBvpynjljLrL8jVBPAWxks4qANSsN4yixPmw7LA==

"@swc/core-linux-x64-gnu@1.2.139":
version "1.2.139"
resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.2.139.tgz#1161a5ce59b7c4a5adfe6c5aa0d673cc2bdb10c5"
integrity sha512-qpD9HQB50zZRIB/i21RjThUk7FRo7tLiHjcnSxZBnPcPYTM5sdzatrnO6b5/NnKngM1HW75OfJ1tvyccrU3Ufg==

"@swc/core-linux-x64-musl@1.2.139":
version "1.2.139"
resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.2.139.tgz#f713b33355f0e165a0b928d0b824c4d21564535e"
integrity sha512-ILm4Z+StN+spNrhA6P6m9lXkmU0Ban4GeWaI2ErslyTFNaybQiwKlXlCNmsylzKlpEQd4nCpYy3vIFoeOoyJlQ==

"@swc/core-win32-arm64-msvc@1.2.139":
version "1.2.139"
resolved "https://registry.yarnpkg.com/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.2.139.tgz#17a5a20be0bf8f3ebbd6a29a912faa67f4db56d9"
integrity sha512-hIckLZ08lqWlHdJyFQG4tZCMdnvqqBQTB/6FYUU0pWB5bTMIixFfMV8XytWZJinNgXVgi6PApU4IHbWksUrHdg==

"@swc/core-win32-ia32-msvc@1.2.139":
version "1.2.139"
resolved "https://registry.yarnpkg.com/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.2.139.tgz#47973072fe603c9a9e846f675f89909e9a7fac51"
integrity sha512-rN5XmVXW+Y/GZ/5FiV99R/0QejuN6YwDH/LoiEE85I8ytbLPBlpL2yhSe48BPhSeHgAwLpgeaK2NOKSeuhsHrA==

"@swc/core-win32-x64-msvc@1.2.139":
version "1.2.139"
resolved "https://registry.yarnpkg.com/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.2.139.tgz#d028873939e677c0ed86471e15aeff8d4288c39b"
integrity sha512-N1zvgp/xlSEgi6msYI2zkyY/B9RlIuLjuyUu5VmFY6dylCwwukCHu6Vi6kYYKEtNoZCGWvSCgKbg87TMydetxQ==

"@swc/core@^1.2.87":
version "1.2.139"
resolved "https://registry.yarnpkg.com/@swc/core/-/core-1.2.139.tgz#b7e042eaf102bebdfaf56a0c11196e2caa4ecf89"
integrity sha512-VlISQI7H6kIJT0Hhl6UVEOAb1HcuqWCnsoMHxVGdEQZlxt8g+ggyrY7F4AZoTvfgnSEayeIdpV8Xq52Zg+zjYw==
optionalDependencies:
"@swc/core-android-arm-eabi" "1.2.139"
"@swc/core-android-arm64" "1.2.139"
"@swc/core-darwin-arm64" "1.2.139"
"@swc/core-darwin-x64" "1.2.139"
"@swc/core-freebsd-x64" "1.2.139"
"@swc/core-linux-arm-gnueabihf" "1.2.139"
"@swc/core-linux-arm64-gnu" "1.2.139"
"@swc/core-linux-arm64-musl" "1.2.139"
"@swc/core-linux-x64-gnu" "1.2.139"
"@swc/core-linux-x64-musl" "1.2.139"
"@swc/core-win32-arm64-msvc" "1.2.139"
"@swc/core-win32-ia32-msvc" "1.2.139"
"@swc/core-win32-x64-msvc" "1.2.139"

"@swc/register@^0.1.7":
version "0.1.10"
resolved "https://registry.yarnpkg.com/@swc/register/-/register-0.1.10.tgz#74a20b7559669e03479b05e9e5c6d1524d4d92a2"
integrity sha512-6STwH/q4dc3pitXLVkV7sP0Hiy+zBsU2wOF1aXpXR95pnH3RYHKIsDC+gvesfyB7jxNT9OOZgcqOp9RPxVTx9A==
dependencies:
lodash.clonedeep "^4.5.0"
pirates "^4.0.1"
source-map-support "^0.5.13"

"@szmarczak/http-timer@^4.0.5":
version "4.0.6"
resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-4.0.6.tgz#b4a914bb62e7c272d4e5989fe4440f812ab1d807"
Expand Down Expand Up @@ -4365,11 +4262,6 @@ commander@^5.0.0:
resolved "https://registry.yarnpkg.com/commander/-/commander-5.1.0.tgz#46abbd1652f8e059bddaef99bbdcb2ad9cf179ae"
integrity sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==

commander@^7.1.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7"
integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==

commander@^8.3.0:
version "8.3.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-8.3.0.tgz#4837ea1b2da67b9c616a67afbb0fafee567bca66"
Expand Down Expand Up @@ -5896,7 +5788,7 @@ fast-glob@3.2.7:
merge2 "^1.3.0"
micromatch "^4.0.4"

fast-glob@^3.2.5, fast-glob@^3.2.7:
fast-glob@^3.2.7:
version "3.2.11"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9"
integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==
Expand Down Expand Up @@ -7824,11 +7716,6 @@ lodash._reinterpolate@^3.0.0:
resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d"
integrity sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=

lodash.clonedeep@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
integrity sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=

lodash.defaults@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c"
Expand Down Expand Up @@ -10234,7 +10121,7 @@ sinon@^13.0.1:
nise "^5.1.1"
supports-color "^7.2.0"

slash@3.0.0, slash@^3.0.0:
slash@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"
integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==
Expand Down Expand Up @@ -10323,11 +10210,6 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.0:
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==

source-map@^0.7.3:
version "0.7.3"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383"
integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==

spdx-correct@^3.0.0:
version "3.1.1"
resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9"
Expand Down