Unverified Commit ed242dc7 authored by Tim Fish's avatar Tim Fish Committed by GitHub

fix: Add `import-in-the-middle` to server-external-packages (#68937)

OpenTelemetry and many other APM libraries rely on
`import-in-the-middle` to hook ES module loading and
`import-in-the-middle` does not work if it's bundled since the ESM
loader hook picks up a different copy of the library to the bundled
code.

Nextjs uses dynamic import in some places to load modules and these can
be hooked via `import-in-the-middle` but it's currently not possible to
hook these modules when `import-in-the-middle` gets bundled.

I'm currently working on auto instrumentation of cache handlers which
are dynamically imported. You can add `import-in-the-middle` to
`serverExternalPackages` but this only works if it's a direct
dependency. It doesn't appear to stop bundling if `import-in-the-middle`
is a sub-dependency.

---------
Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
parent 56dc3ed5
...@@ -45,6 +45,7 @@ Next.js includes a [short list of popular packages](https://github.com/vercel/ne ...@@ -45,6 +45,7 @@ Next.js includes a [short list of popular packages](https://github.com/vercel/ne
- `eslint` - `eslint`
- `express` - `express`
- `firebase-admin` - `firebase-admin`
- `import-in-the-middle`
- `isolated-vm` - `isolated-vm`
- `jest` - `jest`
- `jsdom` - `jsdom`
......
...@@ -45,6 +45,7 @@ Next.js includes a [short list of popular packages](https://github.com/vercel/ne ...@@ -45,6 +45,7 @@ Next.js includes a [short list of popular packages](https://github.com/vercel/ne
- `eslint` - `eslint`
- `express` - `express`
- `firebase-admin` - `firebase-admin`
- `import-in-the-middle`
- `isolated-vm` - `isolated-vm`
- `jest` - `jest`
- `jsdom` - `jsdom`
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
"eslint", "eslint",
"express", "express",
"firebase-admin", "firebase-admin",
"import-in-the-middle",
"isolated-vm", "isolated-vm",
"jest", "jest",
"jsdom", "jsdom",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment