Skip to content

Commit

Permalink
meta(utils): Replace custom versionbump script with rollup replace pl…
Browse files Browse the repository at this point in the history
…ugin (#14340)
  • Loading branch information
lforst authored Nov 18, 2024
1 parent 9993d1e commit 4fbc3b2
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 38 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ env:
${{ github.workspace }}/packages/*/build
${{ github.workspace }}/packages/ember/*.d.ts
${{ github.workspace }}/packages/gatsby/*.d.ts
${{ github.workspace }}/packages/core/src/version.ts
${{ github.workspace }}/packages/utils/cjs
${{ github.workspace }}/packages/utils/esm
Expand Down
5 changes: 2 additions & 3 deletions packages/core/test/lib/carrier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,13 @@ describe('getSentryCarrier', () => {
describe('multiple (older) SDKs', () => {
it("returns the version of the sentry carrier object of the SDK's version rather than the one set in .version", () => {
const sentryCarrier = getSentryCarrier({
// @ts-expect-error - this is just a test object
__SENTRY__: {
version: '8.0.0' as const, // another SDK set this
version: '8.0.0', // another SDK set this
'8.0.0': {
// @ts-expect-error - this is just a test object, not passing a full stack
stack: {},
},
[SDK_VERSION]: {
// @ts-expect-error - this is just a test object, not passing a full ACS
acs: {},
},
hub: {},
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ module.exports = {
},
],
// symlinks to the folders inside of `build`, created to simulate what's in the npm package
ignorePatterns: ['cjs/**', 'esm/**'],
ignorePatterns: ['cjs/**', 'esm/**', 'rollup.npm.config.mjs'],
};
1 change: 0 additions & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
"lint": "eslint . --format stylish",
"test": "jest",
"test:watch": "jest --watch",
"version": "node ../../scripts/versionbump.js src/version.ts",
"yalc:publish": "yalc publish --push --sig"
},
"volta": {
Expand Down
10 changes: 10 additions & 0 deletions packages/utils/rollup.npm.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import replace from '@rollup/plugin-replace';
import { makeBaseNPMConfig, makeNPMConfigVariants } from '@sentry-internal/rollup-utils';
import packageJson from './package.json' with { type: 'json' };

export default makeNPMConfigVariants(
makeBaseNPMConfig({
Expand All @@ -12,6 +14,14 @@ export default makeNPMConfigVariants(
? true
: Boolean(process.env.SENTRY_BUILD_PRESERVE_MODULES),
},
plugins: [
replace({
preventAssignment: true,
values: {
__SENTRY_SDK_VERSION__: JSON.stringify(packageJson.version),
},
}),
],
},
}),
);
5 changes: 4 additions & 1 deletion packages/utils/src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
export const SDK_VERSION = '8.38.0';
// This is a magic string replaced by rollup
declare const __SENTRY_SDK_VERSION__: string;

export const SDK_VERSION = typeof __SENTRY_SDK_VERSION__ === 'string' ? __SENTRY_SDK_VERSION__ : '0.0.0-unknown.0';
31 changes: 0 additions & 31 deletions scripts/versionbump.js

This file was deleted.

0 comments on commit 4fbc3b2

Please sign in to comment.