[Nuxt] Investigate issue with server-side not building correctly (import
and import()
are added)
#14514
Labels
Package: nuxt
Issues related to the Sentry Nuxt SDK
--> scroll down to see the workaround for this issue
What is happening?
With the Nuxt rollup plugin (which is automatically added by the SDK), the content of
sentry.server.config.ts
is added to the server entry file (.output/server/index.mjs
) and the rest of the server application (eithernitro/nitro.mjs
orruntime.mjs
) is added via a dynamicimport()
.If it is correct, it should look something like this:
However, the build output sometimes looks like this:
This is a problem, because Sentry needs to be initialized before any other server-side code is loaded. With ES Modules, this can only happen by dynamically importing (with
import()
) the application to load it afterwards or using the--import
flag. Sentry is not initialized correctly when there is another, regularimport
of the server-side code.Debugging Process
The following things have been found out already:
.git
folder (more on this below)server/middleware
nitropack
in thenode_modules
(still needs some investigation if this happens continously)Deleting
.git
This is very strange, as there is no obvious connection to git. The files and folders listed below are the ones that affect the build output. If any of those are missing, the build output is correct again.
Workaround
The current workaround is overriding the version of
nitropack
. As the older version ofnitropack
is still including an old version of@vercel/nft
, this override has to be added as well:npm
yarn
pnpm
The text was updated successfully, but these errors were encountered: