You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/platforms/javascript/guides/nuxt/install/dynamic-import.mdx
+73-1Lines changed: 73 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,4 +4,76 @@ sidebar_order: 1
4
4
description: "Learn about how the Nuxt SDK leverages dynamic input() in the build output."
5
5
---
6
6
7
-
TODO
7
+
## Understanding the `import()` expression
8
+
9
+
The `import()` expression (also called "dynamic import") allows conditional and flexible module loading in ESM.
10
+
For the Sentry Nuxt SDK, it provides an approach to initialize server-side configuration before application startup.
11
+
12
+
## Scenarios where `import()` does not work
13
+
14
+
We are currently investigating an issue where the server-side is not correctly initialized with a recent update of Nitro (the server-side toolkit in Nuxt).
15
+
We are working on figuring this out ([see issue here](https://github.com/getsentry/sentry-javascript/issues/14514)). As a temporary workaround, you can add the following overrides to your application:
16
+
17
+
```json {tabTitle:npm} {filename:package.json}
18
+
"overrides": {
19
+
"nitropack": "2.9.7"
20
+
"@vercel/nft": "^0.27.4"
21
+
}
22
+
```
23
+
```json {tabTitle:yarn} {filename:package.json}
24
+
"resolutions": {
25
+
"nitropack": "2.9.7"
26
+
"@vercel/nft": "^0.27.4"
27
+
}
28
+
```
29
+
```json {tabTitle:pnpm} {filename:package.json}
30
+
"pnpm": {
31
+
"overrides": {
32
+
"nitropack": "2.9.7"
33
+
"@vercel/nft": "^0.27.4"
34
+
}
35
+
}
36
+
```
37
+
38
+
You can also check out the guide for using the <PlatformLinkto="/install/cli-import//">CLI flag `--import`</PlatformLink> as this might be a better choice for you.
39
+
40
+
41
+
## Initializing Sentry with Dynamic `import()`
42
+
43
+
By default, the Sentry Nuxt SDK includes a Rollup plugin which wraps the server entry file with a dynamic `import()`.
44
+
With this, Sentry can be initialized before all other modules of the application.
45
+
46
+
The server entry file will look something like this:
47
+
48
+
```javascript {filename:.output/server/index.mjs}
49
+
// Note: file may have some imports and code related to debug IDs
Sentry automatically detects serverless handler functions in the build output and re-exports them from the server entry file.
60
+
61
+
By default, Sentry re-exports functions named `handler`, `server`, and `default` exports. This will work in most cases and no other action is required.
62
+
In case your serverless function has another, custom name you can override this with `entrypointWrappedFunctions`:
Nuxt uses ES Modules for server-side builds, which requires Sentry to register Node [customization hooks](https://nodejs.org/api/module.html#customization-hooks).
10
+
Those customization hooks need to be registered before the rest of the application.
9
11
10
-
TODO: Nuxt is using ES Modules on the server-side so...
12
+
To be able to run Sentry before the rest of the application and fully monitor the server-side, Sentry can be initialized using one of those two approaches:
13
+
14
+
- Dynamically import server code after initializing Sentry (default)
15
+
- Preload Sentry configuration with the Node `--import` CLI flag
Copy file name to clipboardExpand all lines: docs/platforms/javascript/guides/nuxt/manual-setup.mdx
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -105,7 +105,8 @@ dotenv.config();
105
105
106
106
#### Troubleshoot Errors during Server Startup
107
107
108
-
In case you are experiencing problems after adding `sentry.server.config.ts` and building the project, you can check out <PlatformLinkto="/troubleshooting">Troubleshooting</PlatformLink>.
108
+
In case you are experiencing problems after adding `sentry.server.config.ts` and building the project, you can check out <PlatformLinkto="/troubleshooting">Troubleshooting</PlatformLink>
109
+
or read through the different <PlatformLinkto="/install">installation methods</PlatformLink>.
0 commit comments