Skip to content

Commit 2aae69c

Browse files
committed
perf(astro): reduce unnecessary path resolutions (#10021)
- No need to call `process.cwd()` on every iteration. - No need to create paths on memory
1 parent e23050b commit 2aae69c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

packages/astro/src/integration/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,14 @@ export const sentryAstro = (options: SentryOptions = {}): AstroIntegration => {
101101
};
102102
};
103103

104+
const possibleFileExtensions = ['ts', 'js', 'tsx', 'jsx', 'mjs', 'cjs', 'mts'];
105+
104106
function findDefaultSdkInitFile(type: 'server' | 'client'): string | undefined {
105-
const fileExtensions = ['ts', 'js', 'tsx', 'jsx', 'mjs', 'cjs', 'mts'];
106-
return fileExtensions
107-
.map(ext => path.resolve(path.join(process.cwd(), `sentry.${type}.config.${ext}`)))
108-
.find(filename => fs.existsSync(filename));
107+
const cwd = process.cwd();
108+
return possibleFileExtensions.find(extension => {
109+
const filename = path.resolve(path.join(cwd, `sentry.${type}.config.${extension}`));
110+
return fs.existsSync(filename);
111+
});
109112
}
110113

111114
function getSourcemapsAssetsGlob(config: AstroConfig): string {

0 commit comments

Comments
 (0)