Skip to content

Commit

Permalink
feat: added support for building with esbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
acaldas committed May 15, 2024
1 parent a1dbd76 commit 5c7e2cd
Show file tree
Hide file tree
Showing 25 changed files with 539 additions and 194 deletions.
4 changes: 4 additions & 0 deletions api/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tabWidth": 2,
"singleQuote": true
}
28 changes: 28 additions & 0 deletions api/esbuild.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* eslint-disable import/no-extraneous-dependencies */
import esbuild from 'esbuild';
import { builtinModules } from 'module';
import pkg from './package.json' with { type: 'json' };

// Configuration options
const config = {
entryPoints: ['src/index.ts'],
bundle: true,
platform: 'node',
format: 'esm',
outdir: 'dist',
sourcemap: true,
target: 'node20',
loader: {
'.node': 'copy',
},
external: [
...builtinModules, // Exclude Node.js built-in modules
// Exclude all node_modules except specific-module
...Object.keys(pkg.dependencies).filter((dep) => dep !== 'document-drive'),
...Object.keys(pkg.devDependencies),
],
logLevel: 'info',
};

// Build process
esbuild.build(config).catch(() => process.exit(1));
2 changes: 1 addition & 1 deletion api/logger.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LoggerConfig } from './src/types';
import type { LoggerConfig } from './src/types';

export const defaultLoggerConfig: LoggerConfig = {
// Filter by module name
Expand Down
11 changes: 7 additions & 4 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
"type": "module",
"license": "AGPL-3",
"scripts": {
"start": "node dist/index.js",
"dev": "vite-node -w src/index.ts",
"start": "NODE_ENV=production vite-node src/index.ts",
"debug": "DEBUG=1 npm run dev",
"lint": "eslint \"./**/*.{ts,tsx}\" --max-warnings=0",
"typecheck": "tsc --noEmit",
"test": "vitest run && vitest run --config ./vitest.modules.config.ts",
"watch": "vitest watch"
"watch": "vitest watch",
"build": "node --no-warnings=ExperimentalWarning ./esbuild.config.js"
},
"dependencies": {
"@apollo/server": "^4.10.3",
Expand Down Expand Up @@ -52,22 +53,24 @@
},
"devDependencies": {
"@types/bcrypt": "^5.0.2",
"@types/body-parser": "^1.19.5",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/jsonwebtoken": "^9.0.6",
"@types/ms": "^0.7.34",
"@types/node": "^18.19.31",
"@types/node": "^20.12.12",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"@vitest/coverage-istanbul": "^0.29.8",
"esbuild": "^0.21.2",
"eslint": "^8.57.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.1.0",
"gql-query-builder": "^3.8.0",
"graphql-request": "^5.2.0",
"node-fetch": "^3.3.2",
"prisma": "5.11.0",
"typescript": "^4.9.5",
"typescript": "^5.4.5",
"vitest-mock-extended": "^1.3.1"
}
}
Loading

0 comments on commit 5c7e2cd

Please sign in to comment.