Files
payloadcms/packages/payload/bundle.js
Alessio Gravili e6b664284f chore: fix payload bundle script (#13022)
This fixes the payload bundle script. While not run by default, it's
useful for checking the payload bundle size by manually running `cd
packages/payload && node bundle.js`.
2025-07-03 04:37:44 -07:00

66 lines
1.6 KiB
JavaScript

import * as esbuild from 'esbuild'
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
async function build() {
const resultIndex = await esbuild.build({
entryPoints: ['src/index.ts'],
bundle: true,
platform: 'node',
format: 'esm',
outfile: 'dist/index.js',
splitting: false,
external: [
'lodash',
'*.scss',
'*.css',
'@payloadcms/translations',
'memoizee',
'pino-pretty',
'pino',
//'ajv',
//'image-size',
],
minify: true,
metafile: true,
tsconfig: path.resolve(dirname, './tsconfig.json'),
// plugins: [commonjs()],
sourcemap: true,
})
console.log('payload server bundled successfully')
const resultShared = await esbuild.build({
entryPoints: ['src/exports/shared.ts'],
bundle: true,
platform: 'node',
format: 'esm',
outfile: 'dist/exports/shared.js',
splitting: false,
external: [
'lodash',
'*.scss',
'*.css',
'@payloadcms/translations',
'memoizee',
'pino-pretty',
'pino',
//'ajv',
//'image-size',
],
minify: true,
metafile: true,
tsconfig: path.resolve(dirname, './tsconfig.json'),
// plugins: [commonjs()],
sourcemap: true,
})
console.log('payload shared bundled successfully')
fs.writeFileSync('meta_index.json', JSON.stringify(resultIndex.metafile))
fs.writeFileSync('meta_shared.json', JSON.stringify(resultShared.metafile))
}
await build()