Skip to content

Commit

Permalink
fix(nextjs): Fix requestAsyncStorageShim path resolution on windows (
Browse files Browse the repository at this point in the history
  • Loading branch information
lforst committed Aug 28, 2023
1 parent 891a44e commit 478b5e2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 10 additions & 0 deletions packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
"module": "build/esm/index.server.js",
"browser": "build/esm/index.client.js",
"types": "build/types/index.types.d.ts",
"exports": {
".": {
"import": "./build/esm/index.server.js",
"require": "./build/cjs/index.server.js",
"types": "./build/types/index.types.d.ts"
},
"./requestAsyncStorageShim": {
"import": "./build/esm/config/templates/requestAsyncStorageShim.js"
}
},
"typesVersions": {
"<4.9": {
"build/npm/types/index.d.ts": [
Expand Down
6 changes: 4 additions & 2 deletions packages/nextjs/src/config/loaders/wrappingLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const pageWrapperTemplateCode = fs.readFileSync(pageWrapperTemplatePath, { encod
const middlewareWrapperTemplatePath = path.resolve(__dirname, '..', 'templates', 'middlewareWrapperTemplate.js');
const middlewareWrapperTemplateCode = fs.readFileSync(middlewareWrapperTemplatePath, { encoding: 'utf8' });

const requestAsyncStorageShimPath = path.resolve(__dirname, '..', 'templates', 'requestAsyncStorageShim.js');
const requestAsyncStorageModuleExists = moduleExists(NEXTJS_REQUEST_ASYNC_STORAGE_MODULE_PATH);
let showedMissingAsyncStorageModuleWarning = false;

Expand Down Expand Up @@ -190,7 +189,10 @@ export default function wrappingLoader(
);
showedMissingAsyncStorageModuleWarning = true;
}
templateCode = templateCode.replace(/__SENTRY_NEXTJS_REQUEST_ASYNC_STORAGE_SHIM__/g, requestAsyncStorageShimPath);
templateCode = templateCode.replace(
/__SENTRY_NEXTJS_REQUEST_ASYNC_STORAGE_SHIM__/g,
'@sentry/nextjs/requestAsyncStorageShim',
);
}

templateCode = templateCode.replace(/__ROUTE__/g, parameterizedPagesRoute.replace(/\\/g, '\\\\'));
Expand Down

0 comments on commit 478b5e2

Please sign in to comment.