Skip to content

Commit 1005925

Browse files
authored
fix(angular-ivy): Adjust package entry points to support Angular 17 with SSR config (#9412)
Adjust the entry points of `@sentry/angular-ivy`'s `package.json` to point directly to FESM2015 bundles (= bundled ESM2015 code) instead of the UMD bundles. This fixes an error when the old (no longer supported) UMD bundles were picked up by Vite in Angular apps with SSR config (#9376). A proper long term fix to this is to bump to Angular 15 in this package which we can only do in a new major.
1 parent a8cf899 commit 1005925

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

packages/angular-ivy/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"build:watch": "yarn build:syncSymlinks && yarn build:transpile:watch",
4747
"build:dev:watch": "yarn build:watch",
4848
"build:transpile:watch": "ng build --watch",
49-
"build:tarball": "npm pack ./build",
49+
"build:tarball": "ts-node ./scripts/prepack.ts && npm pack ./build",
5050
"build:syncSymlinks": "ts-node ./scripts/syncSourceFiles.ts",
5151
"circularDepCheck": "madge --circular src/index.ts",
5252
"clean": "rimraf build coverage sentry-angular-ivy-*.tgz",
@@ -56,7 +56,7 @@
5656
"lint": "run-s lint:prettier lint:eslint",
5757
"lint:eslint": "eslint . --format stylish",
5858
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
59-
"yalc:publish": "yalc publish build --push --sig"
59+
"yalc:publish": "ts-node ./scripts/prepack.ts && yalc publish build --push --sig"
6060
},
6161
"volta": {
6262
"extends": "../../package.json"
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import * as fs from 'fs';
2+
import * as path from 'path';
3+
4+
type PackageJson = {
5+
main?: string;
6+
type?: string;
7+
nx?: string;
8+
volta?: any;
9+
};
10+
11+
const buildDir = path.join(process.cwd(), 'build');
12+
const pkjJsonPath = path.join(buildDir, 'package.json');
13+
const pkgJson: PackageJson = JSON.parse(fs.readFileSync(pkjJsonPath).toString());
14+
15+
// This is necessary for Angular 17+ compatibility when SSR is configured which switches dev mode to using Vite.
16+
// Deleting "main" and adding "type": "module" will direct Vite to
17+
// use the fesm2015 bundle instead of the UMD bundle.
18+
delete pkgJson.main;
19+
pkgJson.type = 'module';
20+
21+
// no need to keep around other properties that are only relevant for our reop:
22+
delete pkgJson.nx;
23+
delete pkgJson.volta;
24+
25+
fs.writeFileSync(pkjJsonPath, JSON.stringify(pkgJson, null, 2));
26+
27+
console.log('Adjusted package.json for Angular 17+ compatibility.');

0 commit comments

Comments
 (0)