build.mjs 1.3 KB

123456789101112131415161718192021222324
  1. import { build } from 'esbuild'
  2. import * as path from 'node:path'
  3. import { readFileSync } from 'node:fs'
  4. import { fileURLToPath } from 'node:url'
  5. import { writeNotices } from '../../../scripts/release/notices.mjs'
  6. const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
  7. const manifest = JSON.parse(readFileSync(path.join(root, 'package.json'), 'utf8'))
  8. const hostBuild = await build({
  9. entryPoints: [path.join(root, 'src/index.ts')], outfile: path.join(root, 'lib/index.js'),
  10. bundle: true, platform: 'node', format: 'esm', target: 'node22', legalComments: 'inline', metafile: true,
  11. external: ['@deepseek-ai/cordis', '@deepseek-ai/dsh-llm', 'node:*'],
  12. })
  13. const clientBuild = await build({
  14. entryPoints: [path.join(root, 'src/client.tsx')], outfile: path.join(root, 'lib/client.js'),
  15. bundle: true, platform: 'browser', format: 'cjs', target: 'chrome110', external: ['react'],
  16. loader: { '.css': 'text' },
  17. legalComments: 'inline', metafile: true, minify: true,
  18. banner: { js: `window.__ModuleLoader__.load({ id: ${JSON.stringify(manifest.name)}, factory: (require) => { const module = { exports: {} }; const exports = module.exports;` },
  19. footer: { js: 'return module.exports; } });' },
  20. })
  21. console.log('[embedding-provider] Host plugin and native settings client built')
  22. writeNotices(root, [hostBuild, clientBuild])