@@ -18,15 +18,24 @@ const version = packageJson.version;
1818
1919console . log ( `Replacing __LIB_VERSION__ with ${ version } ` ) ;
2020
21- // Replace in the compiled version.js file
22- const versionFilePath = join ( __dirname , '..' , 'dist' , 'version.js' ) ;
23- try {
24- let content = readFileSync ( versionFilePath , 'utf-8' ) ;
25- content = content . replace ( / _ _ L I B _ V E R S I O N _ _ / g, version ) ;
26- writeFileSync ( versionFilePath , content , 'utf-8' ) ;
27- console . log ( `✓ Updated ${ versionFilePath } ` ) ;
28- } catch ( error ) {
29- console . error ( `Error updating version file:` , error . message ) ;
21+ // Replace in both ESM and CJS bundles
22+ const filesToUpdate = [ 'index.js' , 'index.cjs' ] ;
23+ let hasError = false ;
24+
25+ for ( const file of filesToUpdate ) {
26+ const filePath = join ( __dirname , '..' , 'dist' , file ) ;
27+ try {
28+ let content = readFileSync ( filePath , 'utf-8' ) ;
29+ content = content . replace ( / _ _ L I B _ V E R S I O N _ _ / g, version ) ;
30+ writeFileSync ( filePath , content , 'utf-8' ) ;
31+ console . log ( `✓ Updated ${ filePath } ` ) ;
32+ } catch ( error ) {
33+ console . error ( `Error updating ${ file } :` , error . message ) ;
34+ hasError = true ;
35+ }
36+ }
37+
38+ if ( hasError ) {
3039 process . exit ( 1 ) ;
3140}
3241
0 commit comments