@@ -3,13 +3,24 @@ import packageJson from './package.json';
33import { Configuration } from '@rspack/cli' ;
44import rspack from '@rspack/core' ;
55import { ModuleFederationPlugin } from '@module-federation/enhanced/rspack' ;
6- import { execSync } from 'node:child_process ' ;
6+ import fs from 'fs ' ;
77
88const deps = packageJson . dependencies ;
99
1010const isProduction = process . env . NODE_ENV === 'production' ;
1111
12- const revision = execSync ( 'git rev-parse HEAD' ) . toString ( ) . trim ( ) ;
12+ let version = process . env . VERSION ;
13+ if ( ! version ) {
14+ const versionFileContents = fs . readFileSync (
15+ path . join ( __dirname , '../VERSION' ) ,
16+ { encoding : 'utf-8' } ,
17+ ) ;
18+ const versionRegex =
19+ / .* V E R S I O N _ M A J O R = (?< versionMajor > \d + ) ( \n ) { 0 , 1 } .* V E R S I O N _ M I N O R = (?< versionMinor > \d + ) ( \n ) { 0 , 1 } .* V E R S I O N _ P A T C H = (?< versionPatch > \d + ) ( \n ) { 0 , 1 } .* V E R S I O N _ S U F F I X = (?< versionSuffix > .* ) / m;
20+ const { versionMajor, versionMinor, versionPatch, versionSuffix } =
21+ versionRegex . exec ( versionFileContents ) . groups ;
22+ version = `${ versionMajor } .${ versionMinor } .${ versionPatch } ${ versionSuffix } ` ;
23+ }
1324
1425const config : Configuration = {
1526 entry : {
@@ -100,7 +111,7 @@ const config: Configuration = {
100111 plugins : [
101112 new ModuleFederationPlugin ( {
102113 name : 'metalk8s' ,
103- filename : `static/js/remoteEntry.${ revision } .js` ,
114+ filename : `static/js/remoteEntry.${ version } .js` ,
104115 exposes : {
105116 './FederableApp' : './src/FederableApp.tsx' ,
106117 './platformLibrary' : './src/services/platformlibrary/k8s.ts' ,
0 commit comments