Skip to content

Commit

Permalink
chore: simplify esbuild script
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Valeriano committed Oct 1, 2024
1 parent af2d2fa commit 4835695
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 89 deletions.
17 changes: 8 additions & 9 deletions esbuild.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import child_process from "node:child_process";
import { globSync } from "node:fs";
import fs from "node:fs/promises";
import { promisify } from "node:util";
import { build } from "esbuild";
import { esbuildPluginFilePathExtensions } from "esbuild-plugin-file-path-extensions";
import fastGlob from "fast-glob";
import { replaceTscAliasPaths } from "tsc-alias";
import { compilerOptions } from "./tsconfig.json";

const execAsync = promisify(child_process.exec);
const entryPoints = await fastGlob("src/**/*.ts");
const entryPoints = globSync("src/**/*.ts");
const { outDir } = compilerOptions;

// clean up old dist
Expand All @@ -19,24 +18,24 @@ await build({
entryPoints,
outdir: outDir,
treeShaking: true,
bundle: true, // only to make the extension plugin work
external: ["*"],
packages: "external",
platform: "node",
target: "ESNext",
sourcemap: false,
format: "esm",
minify: false,
tsconfig: "./tsconfig.json",
plugins: [esbuildPluginFilePathExtensions({ esm: true, esmExtension: "js" })],
});

// create full temp config because tsc-alias doesn't like extended configs
// https://github.com/justkey007/tsc-alias/issues/230
await execAsync("tsc --showConfig > tsconfig.temp.json");

// replace aliases with actual, relative paths
await replaceTscAliasPaths({ outDir, configFile: "tsconfig.temp.json" });
// replace aliases with actual paths and add .js extensions
await replaceTscAliasPaths({
outDir,
resolveFullPaths: true,
configFile: "tsconfig.temp.json",
});

// clean up temp config
await fs.rm("tsconfig.temp.json");
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,16 @@
"devDependencies": {
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@mkvlrn/configurations": "^1.0.4",
"@mkvlrn/configurations": "^1.0.5",
"@nestjs/cli": "^10.4.5",
"@nestjs/schematics": "^10.1.4",
"@nestjs/testing": "^10.4.4",
"@types/express": "^5.0.0",
"@types/node": "^22.7.2",
"@types/node": "^22.7.4",
"@types/supertest": "^6.0.2",
"@vitest/coverage-v8": "^2.1.1",
"esbuild": "^0.24.0",
"esbuild-plugin-file-path-extensions": "^2.1.3",
"eslint": "^9.11.1",
"fast-glob": "^3.3.2",
"husky": "^9.1.6",
"lint-staged": "^15.2.10",
"prettier": "^3.3.3",
Expand Down
147 changes: 71 additions & 76 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -827,23 +827,23 @@
resolved "https://registry.yarnpkg.com/@lukeed/csprng/-/csprng-1.1.0.tgz#1e3e4bd05c1cc7a0b2ddbd8a03f39f6e4b5e6cfe"
integrity sha512-Z7C/xXCiGWsg0KuKsHTKJxbWhpI3Vs5GwLfOean7MGyVFGqdRgBbAjOCh6u4bbjPc/8MJ2pZmK/0DLdCbivLDA==

"@mkvlrn/configurations@^1.0.4":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@mkvlrn/configurations/-/configurations-1.0.4.tgz#f73408154788e1048ab61516fe12c2451c6236ca"
integrity sha512-1CVeyTCjmNdCDb6qOzCpfW65XItFwuA0JBFV09Do3s3SOTjzay2W8EHiCutGhvmo4BpblaeLTjfDyjlM7EAfcw==
"@mkvlrn/configurations@^1.0.5":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@mkvlrn/configurations/-/configurations-1.0.5.tgz#34ca667e01822823577cb3249fff58e4df74eee7"
integrity sha512-l0Ufp+6k41AL0lqHDTKTJbTEBDOqlM/3cR6/iJKi/YXU9g/XJ43idf2lJLc8xiDMwUycC7GUI8laYtM723CJ0g==
dependencies:
"@eslint/js" "^9.11.1"
"@next/eslint-plugin-next" "^14.2.13"
"@trivago/prettier-plugin-sort-imports" "^4.3.0"
eslint-config-prettier "^9.1.0"
eslint-import-resolver-typescript "^3.6.3"
eslint-plugin-import "^2.30.0"
eslint-plugin-react "^7.36.1"
eslint-plugin-react "^7.37.0"
eslint-plugin-react-hooks "^4.6.2"
eslint-plugin-unicorn "^55.0.0"
eslint-plugin-vitest "^0.5.4"
prettier-plugin-tailwindcss "^0.6.8"
typescript-eslint "^8.7.0"
typescript-eslint "^8.8.0"

"@nestjs/cli@^10.4.5":
version "10.4.5"
Expand Down Expand Up @@ -1153,10 +1153,10 @@
dependencies:
undici-types "~6.19.2"

"@types/node@^22.7.2":
version "22.7.2"
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.7.2.tgz#80ed66c0a5025ffa037587fd69a816f29b54e4c7"
integrity sha512-866lXSrpGpgyHBZUa2m9YNWqHDjjM0aBTJlNtYaGEw4rqY/dcD7deRVTbBBAJelfA7oaGDbNftXF/TL/A6RgoA==
"@types/node@^22.7.4":
version "22.7.4"
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.7.4.tgz#e35d6f48dca3255ce44256ddc05dee1c23353fcc"
integrity sha512-y+NPi1rFzDs1NdQHHToqeiX2TIS79SWEAw9GYhkkx8bD0ChpfqC+n2j5OXOCpzfojBEBt6DnEnnG9MY0zk1XLg==
dependencies:
undici-types "~6.19.2"

Expand Down Expand Up @@ -1210,30 +1210,30 @@
"@types/methods" "^1.1.4"
"@types/superagent" "^8.1.0"

"@typescript-eslint/eslint-plugin@8.7.0":
version "8.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.7.0.tgz#d0070f206daad26253bf00ca5b80f9b54f9e2dd0"
integrity sha512-RIHOoznhA3CCfSTFiB6kBGLQtB/sox+pJ6jeFu6FxJvqL8qRxq/FfGO/UhsGgQM9oGdXkV4xUgli+dt26biB6A==
"@typescript-eslint/eslint-plugin@8.8.0":
version "8.8.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.8.0.tgz#b2b02a5447cdc885950eb256b3b8a97b92031bd3"
integrity sha512-wORFWjU30B2WJ/aXBfOm1LX9v9nyt9D3jsSOxC3cCaTQGCW5k4jNpmjFv3U7p/7s4yvdjHzwtv2Sd2dOyhjS0A==
dependencies:
"@eslint-community/regexpp" "^4.10.0"
"@typescript-eslint/scope-manager" "8.7.0"
"@typescript-eslint/type-utils" "8.7.0"
"@typescript-eslint/utils" "8.7.0"
"@typescript-eslint/visitor-keys" "8.7.0"
"@typescript-eslint/scope-manager" "8.8.0"
"@typescript-eslint/type-utils" "8.8.0"
"@typescript-eslint/utils" "8.8.0"
"@typescript-eslint/visitor-keys" "8.8.0"
graphemer "^1.4.0"
ignore "^5.3.1"
natural-compare "^1.4.0"
ts-api-utils "^1.3.0"

"@typescript-eslint/parser@8.7.0":
version "8.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-8.7.0.tgz#a567b0890d13db72c7348e1d88442ea8ab4e9173"
integrity sha512-lN0btVpj2unxHlNYLI//BQ7nzbMJYBVQX5+pbNXvGYazdlgYonMn4AhhHifQ+J4fGRYA/m1DjaQjx+fDetqBOQ==
"@typescript-eslint/parser@8.8.0":
version "8.8.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-8.8.0.tgz#ee4397c70230c4eee030456924c0fba480072f5e"
integrity sha512-uEFUsgR+tl8GmzmLjRqz+VrDv4eoaMqMXW7ruXfgThaAShO9JTciKpEsB+TvnfFfbg5IpujgMXVV36gOJRLtZg==
dependencies:
"@typescript-eslint/scope-manager" "8.7.0"
"@typescript-eslint/types" "8.7.0"
"@typescript-eslint/typescript-estree" "8.7.0"
"@typescript-eslint/visitor-keys" "8.7.0"
"@typescript-eslint/scope-manager" "8.8.0"
"@typescript-eslint/types" "8.8.0"
"@typescript-eslint/typescript-estree" "8.8.0"
"@typescript-eslint/visitor-keys" "8.8.0"
debug "^4.3.4"

"@typescript-eslint/scope-manager@7.18.0":
Expand All @@ -1244,21 +1244,21 @@
"@typescript-eslint/types" "7.18.0"
"@typescript-eslint/visitor-keys" "7.18.0"

"@typescript-eslint/scope-manager@8.7.0":
version "8.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-8.7.0.tgz#90ee7bf9bc982b9260b93347c01a8bc2b595e0b8"
integrity sha512-87rC0k3ZlDOuz82zzXRtQ7Akv3GKhHs0ti4YcbAJtaomllXoSO8hi7Ix3ccEvCd824dy9aIX+j3d2UMAfCtVpg==
"@typescript-eslint/scope-manager@8.8.0":
version "8.8.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-8.8.0.tgz#30b23a6ae5708bd7882e40675ef2f1b2beac741f"
integrity sha512-EL8eaGC6gx3jDd8GwEFEV091210U97J0jeEHrAYvIYosmEGet4wJ+g0SYmLu+oRiAwbSA5AVrt6DxLHfdd+bUg==
dependencies:
"@typescript-eslint/types" "8.7.0"
"@typescript-eslint/visitor-keys" "8.7.0"
"@typescript-eslint/types" "8.8.0"
"@typescript-eslint/visitor-keys" "8.8.0"

"@typescript-eslint/type-utils@8.7.0":
version "8.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-8.7.0.tgz#d56b104183bdcffcc434a23d1ce26cde5e42df93"
integrity sha512-tl0N0Mj3hMSkEYhLkjREp54OSb/FI6qyCzfiiclvJvOqre6hsZTGSnHtmFLDU8TIM62G7ygEa1bI08lcuRwEnQ==
"@typescript-eslint/type-utils@8.8.0":
version "8.8.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-8.8.0.tgz#a0ca1c8a90d94b101176a169d7a0958187408d33"
integrity sha512-IKwJSS7bCqyCeG4NVGxnOP6lLT9Okc3Zj8hLO96bpMkJab+10HIfJbMouLrlpyOr3yrQ1cA413YPFiGd1mW9/Q==
dependencies:
"@typescript-eslint/typescript-estree" "8.7.0"
"@typescript-eslint/utils" "8.7.0"
"@typescript-eslint/typescript-estree" "8.8.0"
"@typescript-eslint/utils" "8.8.0"
debug "^4.3.4"
ts-api-utils "^1.3.0"

Expand All @@ -1267,10 +1267,10 @@
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-7.18.0.tgz#b90a57ccdea71797ffffa0321e744f379ec838c9"
integrity sha512-iZqi+Ds1y4EDYUtlOOC+aUmxnE9xS/yCigkjA7XpTKV6nCBd3Hp/PRGGmdwnfkV2ThMyYldP1wRpm/id99spTQ==

"@typescript-eslint/types@8.7.0":
version "8.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-8.7.0.tgz#21d987201c07b69ce7ddc03451d7196e5445ad19"
integrity sha512-LLt4BLHFwSfASHSF2K29SZ+ZCsbQOM+LuarPjRUuHm+Qd09hSe3GCeaQbcCr+Mik+0QFRmep/FyZBO6fJ64U3w==
"@typescript-eslint/types@8.8.0":
version "8.8.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-8.8.0.tgz#08ea5df6c01984d456056434641491fbf7a1bf43"
integrity sha512-QJwc50hRCgBd/k12sTykOJbESe1RrzmX6COk8Y525C9l7oweZ+1lw9JiU56im7Amm8swlz00DRIlxMYLizr2Vw==

"@typescript-eslint/typescript-estree@7.18.0":
version "7.18.0"
Expand All @@ -1286,29 +1286,29 @@
semver "^7.6.0"
ts-api-utils "^1.3.0"

"@typescript-eslint/typescript-estree@8.7.0":
version "8.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-8.7.0.tgz#6c7db6baa4380b937fa81466c546d052f362d0e8"
integrity sha512-MC8nmcGHsmfAKxwnluTQpNqceniT8SteVwd2voYlmiSWGOtjvGXdPl17dYu2797GVscK30Z04WRM28CrKS9WOg==
"@typescript-eslint/typescript-estree@8.8.0":
version "8.8.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-8.8.0.tgz#072eaab97fdb63513fabfe1cf271812affe779e3"
integrity sha512-ZaMJwc/0ckLz5DaAZ+pNLmHv8AMVGtfWxZe/x2JVEkD5LnmhWiQMMcYT7IY7gkdJuzJ9P14fRy28lUrlDSWYdw==
dependencies:
"@typescript-eslint/types" "8.7.0"
"@typescript-eslint/visitor-keys" "8.7.0"
"@typescript-eslint/types" "8.8.0"
"@typescript-eslint/visitor-keys" "8.8.0"
debug "^4.3.4"
fast-glob "^3.3.2"
is-glob "^4.0.3"
minimatch "^9.0.4"
semver "^7.6.0"
ts-api-utils "^1.3.0"

"@typescript-eslint/utils@8.7.0":
version "8.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-8.7.0.tgz#cef3f70708b5b5fd7ed8672fc14714472bd8a011"
integrity sha512-ZbdUdwsl2X/s3CiyAu3gOlfQzpbuG3nTWKPoIvAu1pu5r8viiJvv2NPN2AqArL35NCYtw/lrPPfM4gxrMLNLPw==
"@typescript-eslint/utils@8.8.0":
version "8.8.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-8.8.0.tgz#bd8607e3a68c461b69169c7a5824637dc9e8b3f1"
integrity sha512-QE2MgfOTem00qrlPgyByaCHay9yb1+9BjnMFnSFkUKQfu7adBXDTnCAivURnuPPAG/qiB+kzKkZKmKfaMT0zVg==
dependencies:
"@eslint-community/eslint-utils" "^4.4.0"
"@typescript-eslint/scope-manager" "8.7.0"
"@typescript-eslint/types" "8.7.0"
"@typescript-eslint/typescript-estree" "8.7.0"
"@typescript-eslint/scope-manager" "8.8.0"
"@typescript-eslint/types" "8.8.0"
"@typescript-eslint/typescript-estree" "8.8.0"

"@typescript-eslint/utils@^7.7.1":
version "7.18.0"
Expand All @@ -1328,12 +1328,12 @@
"@typescript-eslint/types" "7.18.0"
eslint-visitor-keys "^3.4.3"

"@typescript-eslint/visitor-keys@8.7.0":
version "8.7.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-8.7.0.tgz#5e46f1777f9d69360a883c1a56ac3c511c9659a8"
integrity sha512-b1tx0orFCCh/THWPQa2ZwWzvOeyzzp36vkJYOpVg0u8UVOIsfVrnuC9FqAw9gRKn+rG2VmWQ/zDJZzkxUnj/XQ==
"@typescript-eslint/visitor-keys@8.8.0":
version "8.8.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-8.8.0.tgz#f93965abd38c82a1a1f5574290a50d02daf1cd2e"
integrity sha512-8mq51Lx6Hpmd7HnA2fcHQo3YgfX1qbccxQOgZcb4tvasu//zXRaA1j5ZRFeCw/VRAdFi4mRM9DnZw0Nu0Q2d1g==
dependencies:
"@typescript-eslint/types" "8.7.0"
"@typescript-eslint/types" "8.8.0"
eslint-visitor-keys "^3.4.3"

"@vitest/coverage-v8@^2.1.1":
Expand Down Expand Up @@ -2609,11 +2609,6 @@ es-to-primitive@^1.2.1:
is-date-object "^1.0.1"
is-symbol "^1.0.2"

esbuild-plugin-file-path-extensions@^2.1.3:
version "2.1.3"
resolved "https://registry.yarnpkg.com/esbuild-plugin-file-path-extensions/-/esbuild-plugin-file-path-extensions-2.1.3.tgz#a4205367d31f2d0896889d2dc3c9dc6f77a7c3b4"
integrity sha512-yLriKqLz32F0zGDqrfuTx8aENTVnf0l0HZ6qAgPhQpxFIcrZRNc4DfXjZs8pq0VPeBazzpb3WJ05B0S6s3ucSQ==

esbuild@^0.21.3:
version "0.21.5"
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.21.5.tgz#9ca301b120922959b766360d8ac830da0d02997d"
Expand Down Expand Up @@ -2787,10 +2782,10 @@ eslint-plugin-react-hooks@^4.6.2:
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.2.tgz#c829eb06c0e6f484b3fbb85a97e57784f328c596"
integrity sha512-QzliNJq4GinDBcD8gPB5v0wh6g8q3SUi6EFF0x8N/BL9PoVs0atuGc47ozMRyOWAKdwaZ5OnbOEa3WR+dSGKuQ==

eslint-plugin-react@^7.36.1:
version "7.36.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.36.1.tgz#f1dabbb11f3d4ebe8b0cf4e54aff4aee81144ee5"
integrity sha512-/qwbqNXZoq+VP30s1d4Nc1C5GTxjJQjk4Jzs4Wq2qzxFM7dSmuG2UkIjg2USMLh3A/aVcUNrK7v0J5U1XEGGwA==
eslint-plugin-react@^7.37.0:
version "7.37.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.37.0.tgz#c21f64a32fc34df1eaeca571ec8f70bdc40dd20a"
integrity sha512-IHBePmfWH5lKhJnJ7WB1V+v/GolbB0rjS8XYVCSQCZKaQCAUhMoVoOEn1Ef8Z8Wf0a7l8KTJvuZg5/e4qrZ6nA==
dependencies:
array-includes "^3.1.8"
array.prototype.findlast "^1.2.5"
Expand Down Expand Up @@ -5794,14 +5789,14 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==

typescript-eslint@^8.7.0:
version "8.7.0"
resolved "https://registry.yarnpkg.com/typescript-eslint/-/typescript-eslint-8.7.0.tgz#6c84f94013a0cc0074da7d639c2644eae20c3171"
integrity sha512-nEHbEYJyHwsuf7c3V3RS7Saq+1+la3i0ieR3qP0yjqWSzVmh8Drp47uOl9LjbPANac4S7EFSqvcYIKXUUwIfIQ==
typescript-eslint@^8.8.0:
version "8.8.0"
resolved "https://registry.yarnpkg.com/typescript-eslint/-/typescript-eslint-8.8.0.tgz#93762a4cbd9d586dec0d9ab18e07dea13f497a27"
integrity sha512-BjIT/VwJ8+0rVO01ZQ2ZVnjE1svFBiRczcpr1t1Yxt7sT25VSbPfrJtDsQ8uQTy2pilX5nI9gwxhUyLULNentw==
dependencies:
"@typescript-eslint/eslint-plugin" "8.7.0"
"@typescript-eslint/parser" "8.7.0"
"@typescript-eslint/utils" "8.7.0"
"@typescript-eslint/eslint-plugin" "8.8.0"
"@typescript-eslint/parser" "8.8.0"
"@typescript-eslint/utils" "8.8.0"

typescript@5.3.3:
version "5.3.3"
Expand Down

0 comments on commit 4835695

Please sign in to comment.