26 lines
728 B
JavaScript
26 lines
728 B
JavaScript
import { build } from 'esbuild';
|
|
import path from 'node:path';
|
|
|
|
// Bundle workspace packages (they ship TypeScript sources), keep npm dependencies external.
|
|
const externalNpmPackages = {
|
|
name: 'external-npm-packages',
|
|
setup(b) {
|
|
b.onResolve({ filter: /.*/ }, (args) => {
|
|
if (args.kind === 'entry-point' || args.path.startsWith('.') || path.isAbsolute(args.path)) return undefined;
|
|
if (args.path.startsWith('@cardy/')) return undefined;
|
|
return { path: args.path, external: true };
|
|
});
|
|
},
|
|
};
|
|
|
|
await build({
|
|
entryPoints: ['src/index.ts'],
|
|
outfile: 'dist/index.js',
|
|
bundle: true,
|
|
platform: 'node',
|
|
format: 'esm',
|
|
target: 'node22',
|
|
sourcemap: true,
|
|
plugins: [externalNpmPackages],
|
|
});
|