Skip to content

Commit

Permalink
Add esbuild bundler
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul1 committed Apr 28, 2023
1 parent 5b5633a commit 4897bdb
Show file tree
Hide file tree
Showing 4 changed files with 1,097 additions and 94 deletions.
34 changes: 34 additions & 0 deletions esbuild-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import esbuild from 'esbuild';
import { glob } from 'glob';

// Find all TypeScript files in your source directory
const entryPoints = glob.sync('./src/**/*.ts').filter((file) => !file.endsWith('test.ts'));

const external = ['form-data', 'node-fetch', 'pdfmake', 'ssh2', 'ssh2-sftp-client', 'dotenv', '@medplum/core'];

// Define the esbuild options
const esbuildOptions = {
entryPoints: entryPoints,
bundle: true, // Bundle imported functions
outdir: './dist', // Output directory for compiled files
platform: 'node', // or 'node', depending on your target platform
loader: {
'.ts': 'ts', // Load TypeScript files
},
resolveExtensions: ['.ts'],
external,
format: 'cjs', // Set output format as ECMAScript modules
target: 'es2020', // Set the target ECMAScript version
tsconfig: 'tsconfig.build.json',
};

// Build using esbuild
esbuild
.build(esbuildOptions)
.then(() => {
console.log('Build completed successfully!');
})
.catch((error) => {
console.error('Build failed:', JSON.stringify(error, null, 2));
process.exit(1);
});
Loading

0 comments on commit 4897bdb

Please sign in to comment.