-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(nextjs): Add edge polyfills for nextjs-13 in dev mode #17488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ae5fa5d
330f172
46aaac9
5bb46ea
5202ba6
5250cba
4b8db28
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { NextResponse } from 'next/server'; | ||
|
||
export function middleware() { | ||
// Basic middleware to ensure that the build works with edge runtime | ||
return NextResponse.next(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Polyfill for Node.js perf_hooks module in edge runtime | ||
// This mirrors the polyfill from packages/vercel-edge/rollup.npm.config.mjs | ||
const __sentry__timeOrigin = Date.now(); | ||
|
||
// Ensure performance global is available | ||
if (typeof globalThis !== 'undefined' && globalThis.performance === undefined) { | ||
globalThis.performance = { | ||
timeOrigin: __sentry__timeOrigin, | ||
now: function () { | ||
return Date.now() - __sentry__timeOrigin; | ||
}, | ||
}; | ||
} | ||
|
||
// Export the performance object for perf_hooks compatibility | ||
export const performance = globalThis.performance || { | ||
timeOrigin: __sentry__timeOrigin, | ||
now: function () { | ||
return Date.now() - __sentry__timeOrigin; | ||
}, | ||
}; | ||
|
||
// Default export for CommonJS compatibility | ||
export default { | ||
performance, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,7 +99,13 @@ export function getBuildContext( | |
distDir: '.next', | ||
...materializedNextConfig, | ||
} as NextConfigObject, | ||
webpack: { version: webpackVersion, DefinePlugin: class {} as any }, | ||
webpack: { | ||
version: webpackVersion, | ||
DefinePlugin: class {} as any, | ||
ProvidePlugin: class { | ||
constructor(public definitions: Record<string, any>) {} | ||
} as any, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Can we use a more precise type? or type this with unknown instead of any please? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are just test fixtures, I don't think it's necessary to be more precise here. |
||
}, | ||
defaultLoaders: true, | ||
totalPages: 2, | ||
isServer: buildTarget === 'server' || buildTarget === 'edge', | ||
|
Uh oh!
There was an error while loading. Please reload this page.