@@ -4,7 +4,8 @@ import { dirname, resolve } from 'node:path';
44import { fileURLToPath } from 'node:url' ;
55import * as esbuild from 'esbuild' ;
66import { replace } from 'esbuild-plugin-replace' ;
7- import getPackageVersion from "./getPackageVersion.mjs" ;
7+ import getPackageVersion from './getPackageVersion.mjs' ;
8+ import packageJson from '../package.json' with { type : 'json' } ;
89
910// import.meta.dirname is not available before Node 20
1011const __dirname = dirname ( fileURLToPath ( import . meta. url ) ) ;
@@ -25,12 +26,9 @@ const bundledDeps = [
2526 'remark-gfm' ,
2627] ;
2728
28- const packageJson = await import ( resolve ( __dirname , '../package.json' ) , {
29- assert : { type : 'json' } ,
30- } ) ;
3129const deps = Object . keys ( {
32- ...packageJson . default . dependencies ,
33- ...packageJson . default . peerDependencies ,
30+ ...packageJson . dependencies ,
31+ ...packageJson . peerDependencies ,
3432} ) ;
3533const external = deps . filter ( ( dep ) => ! bundledDeps . includes ( dep ) ) ;
3634
@@ -46,7 +44,6 @@ const cjsBundleConfig = {
4644 sourcemap : 'linked' ,
4745} ;
4846
49-
5047// We build two CJS bundles: for browser and for node. The latter one can be
5148// used e.g. during SSR (although it makes little sence to SSR chat, but still
5249// nice for import not to break on server).
@@ -56,9 +53,9 @@ const bundles = ['browser', 'node'].map((platform) =>
5653 entryNames : `[dir]/[name].${ platform } ` ,
5754 platform,
5855 plugins : [
59- replace ( {
60- ' __STREAM_CHAT_REACT_VERSION__' : getPackageVersion ( ) ,
61- } ) ,
56+ replace ( {
57+ __STREAM_CHAT_REACT_VERSION__ : getPackageVersion ( ) ,
58+ } ) ,
6259 ] ,
6360 } ) ,
6461) ;
0 commit comments