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:
JJ Kasper <jj@jjsweb.site>
Showing
Please
register
or
sign in
to comment