Skip to content

meta(utils): Replace custom versionbump script with rollup replace plugin #14340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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' };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work in our GH action (currently node 18)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am pretty sure this was added in node 18.20.0 and we are on 18.20.3 😎


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.

Loading