Skip to content

Commit

Permalink
feat: support cjs
Browse files Browse the repository at this point in the history
  • Loading branch information
v8tenko committed Oct 1, 2024
1 parent a040201 commit 55c4065
Show file tree
Hide file tree
Showing 5 changed files with 417 additions and 13 deletions.
31 changes: 31 additions & 0 deletions esbuild/bundle.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {build} from 'esbuild';
import {TsconfigPathsPlugin} from '@esbuild-plugins/tsconfig-paths';
import {nodeExternalsPlugin} from 'esbuild-node-externals';

/** @type {import('esbuild').BuildOptions}*/
const commonConfig = {
tsconfig: './tsconfig.json',
entryPoints: ['src/lib/index.ts'],
packages: 'external',
platform: 'neutral',
bundle: true,
plugins: [
// eslint-disable-next-line new-cap
TsconfigPathsPlugin({tsconfig: './tsconfig.json'}),
nodeExternalsPlugin(),
],
};

const esmConfig = {
...commonConfig,
outdir: 'build/esm',
format: 'esm',
};

const cjsConfig = {
...commonConfig,
outdir: 'build/cjs',
format: 'cjs',
};

Promise.all([esmConfig, cjsConfig].map(build));
Loading

0 comments on commit 55c4065

Please sign in to comment.