Skip to content

Commit 100c662

Browse files
authored
meta(utils): Don't use import assertion in rollup config (#14362)
1 parent 4357b44 commit 100c662

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

packages/utils/rollup.npm.config.mjs

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1+
// @ts-check
2+
3+
import { readFileSync } from 'fs';
4+
import { dirname, join } from 'path';
5+
import { fileURLToPath } from 'url';
16
import replace from '@rollup/plugin-replace';
27
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;
416

517
export default makeNPMConfigVariants(
618
makeBaseNPMConfig({
@@ -18,7 +30,7 @@ export default makeNPMConfigVariants(
1830
replace({
1931
preventAssignment: true,
2032
values: {
21-
__SENTRY_SDK_VERSION__: JSON.stringify(packageJson.version),
33+
__SENTRY_SDK_VERSION__: JSON.stringify(packageVersion),
2234
},
2335
}),
2436
],

0 commit comments

Comments
 (0)