Skip to content

Commit 389cfd3

Browse files
committed
fix(nextjs): Import path issue on Windows
1 parent 60a60ad commit 389cfd3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/nextjs/src/config/loaders/wrappingLoader.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,15 @@ export default function wrappingLoader(
203203
}
204204

205205
if (sentryConfigFilePath) {
206-
templateCode = `import "${sentryConfigFilePath}";`.concat(templateCode);
206+
let importPath = sentryConfigFilePath;
207+
208+
// absolute paths do not work with Windows
209+
// https://github.com/getsentry/sentry-javascript/issues/8133
210+
if (path.isAbsolute(importPath)) {
211+
importPath = path.relative(path.dirname(this.resourcePath), importPath);
212+
}
213+
214+
templateCode = `import "${importPath.replace(/\\/g, '/')}";\n`.concat(templateCode);
207215
}
208216
} else if (wrappingTargetKind === 'middleware') {
209217
templateCode = middlewareWrapperTemplateCode;

0 commit comments

Comments
 (0)