-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(angular-ivy): Adjust package entry points to support Angular 17 w…
…ith 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.
- Loading branch information
Showing
2 changed files
with
29 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
|
||
type PackageJson = { | ||
main?: string; | ||
type?: string; | ||
nx?: string; | ||
volta?: any; | ||
}; | ||
|
||
const buildDir = path.join(process.cwd(), 'build'); | ||
const pkjJsonPath = path.join(buildDir, 'package.json'); | ||
const pkgJson: PackageJson = JSON.parse(fs.readFileSync(pkjJsonPath).toString()); | ||
|
||
// This is necessary for Angular 17+ compatibility when SSR is configured which switches dev mode to using Vite. | ||
// Deleting "main" and adding "type": "module" will direct Vite to | ||
// use the fesm2015 bundle instead of the UMD bundle. | ||
delete pkgJson.main; | ||
pkgJson.type = 'module'; | ||
|
||
// no need to keep around other properties that are only relevant for our reop: | ||
delete pkgJson.nx; | ||
delete pkgJson.volta; | ||
|
||
fs.writeFileSync(pkjJsonPath, JSON.stringify(pkgJson, null, 2)); | ||
|
||
console.log('Adjusted package.json for Angular 17+ compatibility.'); |