File tree 1 file changed +14
-2
lines changed
1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change
1
+ // @ts -check
2
+
3
+ import { readFileSync } from 'fs' ;
4
+ import { dirname , join } from 'path' ;
5
+ import { fileURLToPath } from 'url' ;
1
6
import replace from '@rollup/plugin-replace' ;
2
7
import { makeBaseNPMConfig , makeNPMConfigVariants } from '@sentry-internal/rollup-utils' ;
3
- import packageJson from './package.json' with { type : 'json' } ;
8
+
9
+ const packageJson = JSON . parse ( readFileSync ( join ( dirname ( fileURLToPath ( import . meta. url ) ) , 'package.json' ) , 'utf-8' ) ) ;
10
+
11
+ if ( ! packageJson . version ) {
12
+ throw new Error ( 'invariant: package version not found' ) ;
13
+ }
14
+
15
+ const packageVersion = packageJson . version ;
4
16
5
17
export default makeNPMConfigVariants (
6
18
makeBaseNPMConfig ( {
@@ -18,7 +30,7 @@ export default makeNPMConfigVariants(
18
30
replace ( {
19
31
preventAssignment : true ,
20
32
values : {
21
- __SENTRY_SDK_VERSION__ : JSON . stringify ( packageJson . version ) ,
33
+ __SENTRY_SDK_VERSION__ : JSON . stringify ( packageVersion ) ,
22
34
} ,
23
35
} ) ,
24
36
] ,
You can’t perform that action at this time.
0 commit comments