Skip to content

Commit

Permalink
fix edge warning
Browse files Browse the repository at this point in the history
  • Loading branch information
feedthejim committed Feb 22, 2023
1 parent dc428b9 commit f53df6e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/next/src/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,11 @@ export default async function getBaseWebpackConfig(

const reactDir = path.dirname(require.resolve('react/package.json'))
const reactDomDir = path.dirname(require.resolve('react-dom/package.json'))
let hasOptionalOTELAPIPackage = false
try {
require('@opentelemetry/api')
hasOptionalOTELAPIPackage = true
} catch {}

const resolveConfig: webpack.Configuration['resolve'] = {
// Disable .mjs for node_modules bundling
Expand Down Expand Up @@ -955,6 +960,9 @@ export default async function getBaseWebpackConfig(
'next/dist/client/components/navigation',
[require.resolve('next/dist/client/components/headers')]:
'next/dist/client/components/headers',
'@opentelemetry/api': hasOptionalOTELAPIPackage
? '@opentelemetry/api'
: 'next/dist/compiled/@opentelemetry/api',
}
: undefined),

Expand Down Expand Up @@ -1101,7 +1109,6 @@ export default async function getBaseWebpackConfig(
// Returning from the function in case the directory has already been added and traversed
if (topLevelFrameworkPaths.includes(directory)) return
topLevelFrameworkPaths.push(directory)

const dependencies = require(packageJsonPath).dependencies || {}
for (const name of Object.keys(dependencies)) {
addPackagePath(name, directory)
Expand Down

0 comments on commit f53df6e

Please sign in to comment.