Skip to content
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

Fix @opentelemetry/api aliasing for webpack #64085

Merged
merged 2 commits into from
Apr 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 3 additions & 19 deletions packages/next/src/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,29 +269,13 @@ export async function loadProjectInfo({
}
}

function getOpenTelemetryVersion(): string | null {
export function hasExternalOtelApiPackage(): boolean {
try {
return require('@opentelemetry/api/package.json')?.version ?? null
require('@opentelemetry/api')
return true
} catch {
return null
}
}

export function hasExternalOtelApiPackage(): boolean {
const opentelemetryVersion = getOpenTelemetryVersion()
if (!opentelemetryVersion) {
return false
}

// 0.19.0 is the first version of the package that has the `tracer.getSpan` API that we need:
// https://github.com/vercel/next.js/issues/48118
if (semver.gte(opentelemetryVersion, '0.19.0')) {
return true
} else {
throw new Error(
`Installed "@opentelemetry/api" with version ${opentelemetryVersion} is not supported by Next.js. Please upgrade to 0.19.0 or newer version.`
)
}
}

const UNSAFE_CACHE_REGEX = /[\\/]pages[\\/][^\\/]+(?:$|\?|#)/
Expand Down
Loading