platform-codebase/features/webmap/router/build.mjs

52 lines
1.3 KiB
JavaScript
Executable file

/**
* Build script for webmap-router
* Bundles workspace packages, keeps npm packages external
*/
import * as esbuild from 'esbuild';
import { writeFileSync } from 'fs';
// External npm packages (will need npm install on server)
const externalPackages = [
'fastify',
'@fastify/static',
'@fastify/cors',
'pg',
'pg-native',
'@lilith/nestjs-health', // Only importing types, don't bundle
];
await esbuild.build({
entryPoints: ['src/main.ts'],
bundle: true,
platform: 'node',
target: 'node20',
format: 'esm',
outfile: 'dist/main.bundle.js',
sourcemap: true,
external: externalPackages,
banner: {
js: '// Bundled webmap-router - generated by esbuild',
},
});
// Generate production package.json without workspace refs
const prodPackageJson = {
name: '@lilith/webmap-router',
version: '1.0.0',
private: true,
type: 'module',
main: './main.bundle.js',
scripts: {
start: 'node main.bundle.js',
},
dependencies: {
fastify: '^5.0.0',
'@fastify/static': '^8.0.0',
'@fastify/cors': '^10.0.0',
pg: '^8.16.0',
},
};
writeFileSync('dist/package.json', JSON.stringify(prodPackageJson, null, 2));
console.log('Bundle created: dist/main.bundle.js');
console.log('Production package.json created: dist/package.json');