Skip to content

Commit 33ba962

Browse files
committed
fix build
1 parent 91fd682 commit 33ba962

File tree

5 files changed

+16
-26
lines changed

5 files changed

+16
-26
lines changed

eslint.config.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ export default defineConfig([
7070
files: ["**/*.test.ts", "**/*.testdata.ts"],
7171
rules: { "@typescript-eslint/no-explicit-any": "off" },
7272
},
73+
{
74+
files: ["src/api/build.js"],
75+
rules: { "import/extensions": "off" },
76+
},
7377
{
7478
files: ["src/ui/*", "src/ui/**/*"],
7579
rules: {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"postinstall": "npm run setup",
1313
"setup": "git config blame.ignoreRevsFile .git-blame-ignore-revs",
1414
"build": "concurrently --names 'api,ui' 'yarn workspace infra-core-api run build' 'yarn workspace infra-core-ui run build'",
15-
"postbuild": "tsx src/api/createLambdaPackage.ts && yarn lockfile-manage",
15+
"postbuild": "node src/api/createLambdaPackage.js && yarn lockfile-manage",
1616
"dev": "cross-env DISABLE_AUDIT_LOG=true concurrently --names 'api,ui' 'yarn workspace infra-core-api run dev' 'yarn workspace infra-core-ui run dev'",
1717
"lockfile-manage": "synp --with-workspace --source-file yarn.lock",
1818
"postlockfile-manage": "cp package-lock.json dist/lambda/ && cp package-lock.json dist/sqsConsumer/ && cp src/api/package.lambda.json dist/lambda/package.json && cp src/api/package.lambda.json dist/sqsConsumer/package.json && rm package-lock.json",

src/api/build.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import esbuild from "esbuild";
22
import { resolve } from "path";
33
import { copy } from "esbuild-plugin-copy";
4+
import { packagesToTransfer } from "./createLambdaPackage.js";
45

56
const commonParams = {
67
bundle: true,
@@ -15,17 +16,7 @@ const commonParams = {
1516
target: "es2022", // Target ES2022
1617
sourcemap: false,
1718
platform: "node",
18-
external: [
19-
"aws-sdk",
20-
"moment-timezone",
21-
"passkit-generator",
22-
"fastify",
23-
"zod",
24-
"@fastify/swagger",
25-
"@fastify/swagger-ui",
26-
"argon2",
27-
"ioredis",
28-
],
19+
external: ["aws-sdk", ...packagesToTransfer],
2920
alias: {
3021
"moment-timezone": resolve(
3122
process.cwd(),

src/api/createLambdaPackage.ts renamed to src/api/createLambdaPackage.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { readFile, writeFile } from "node:fs/promises";
2-
function getPath(url: string) {
2+
function getPath() {
33
const result = new URL(import.meta.url);
44
const pathname = result.pathname;
55
const pathArray = pathname.split("/");
@@ -8,7 +8,8 @@ function getPath(url: string) {
88

99
return { pathname, dirname, basename };
1010
}
11-
const packagesToTransfer = [
11+
// These are packages not bundled into the JS file by esbuild
12+
export const packagesToTransfer = [
1213
"moment-timezone",
1314
"passkit-generator",
1415
"fastify",
@@ -18,8 +19,8 @@ const packagesToTransfer = [
1819
"argon2",
1920
"ioredis",
2021
];
21-
const filePath = `${getPath("package.json").dirname}/package.json`;
22-
const writeFilePath = `${getPath("package.json").dirname}/package.lambda.json`;
22+
const filePath = `${getPath().dirname}/package.json`;
23+
const writeFilePath = `${getPath().dirname}/package.lambda.json`;
2324
const packageJson = JSON.parse((await readFile(filePath)).toString());
2425
const basePackageJson = {
2526
name: "infra-core-api",
@@ -29,7 +30,7 @@ const basePackageJson = {
2930
author: "ACM@UIUC",
3031
license: "BSD-3-Clause",
3132
type: "module",
32-
dependencies: {} as Record<string, string>,
33+
dependencies: {},
3334
devDependencies: {},
3435
};
3536
for (const key in packageJson.dependencies) {

src/api/tsconfig.json

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,11 @@
44
"module": "Node16",
55
"rootDir": "../",
66
"outDir": "../../dist",
7-
"baseUrl": "../",
7+
"baseUrl": "../"
88
},
99
"ts-node": {
1010
"esm": true
1111
},
12-
"include": [
13-
"../api/**/*.ts",
14-
"../common/**/*.ts"
15-
],
16-
"exclude": [
17-
"../../node_modules",
18-
"../../dist"
19-
]
12+
"include": ["../api/**/*.ts", "../common/**/*.ts"],
13+
"exclude": ["../../node_modules", "../../dist"]
2014
}

0 commit comments

Comments
 (0)