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/cli-import.mdx
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,16 +6,16 @@ description: "Learn how to use the node --import CLI flag."
6
6
7
7
## Understanding the `--import` CLI Flag
8
8
9
-
The [`--import` CLI flag](https://nodejs.org/api/cli.html#--importmodule) in Node is the default way in ESM to preload a module before the application starts.
10
-
Setting this flag is crucial for ensuring proper server-side initialization, as Sentry needs to be initialized before
11
-
Node.js resolves the entire import graph of your application. This is necessary for enabling proper instrumentation of ESM module
9
+
The [`--import` CLI flag](https://nodejs.org/api/cli.html#--importmodule) in Node is the default way in ESM to preload a specified module at startup.
10
+
Setting this CLI flag is crucial for ensuring proper server-side initialization, as Sentry needs to be initialized before the application runs.
11
+
This will register Sentry's [loader hook](https://nodejs.org/api/module.html#customization-hooks) and therefore enable proper instrumentation of ESM modules.
12
12
13
13
## Scenarios where `--import` does not work
14
14
15
-
- You're not able to add Node CLI flags or environment variables scoped to the function runtime, meaning these variables are not applied in other scopes, such as build time.
15
+
- You're unable to add Node CLI flags or environment variables scoped to the function runtime, meaning these variables aren't applied in other scopes, such as build time.
16
16
- You don't know the path to the Nuxt server folder in the build output
17
-
-On **Netlify**, it is as of now not possible to configure `--import`properly.
18
-
-On **Vercel**, it is as of now not possible to configure `--import`properly.
17
+
-At this time, it isn't possible to properly configure `--import`in **Netlify**.
18
+
-At this time, it isn't possible to properly configure `--import`in **Vercel**.
19
19
20
20
If any of those points apply to you, you cannot use the `--import` flag to initialize Sentry on the server-side.
21
21
Check out the guide for using <PlatformLinkto="/install/limited-server-tracing">limited server tracing</PlatformLink> instead.
Copy file name to clipboardExpand all lines: docs/platforms/javascript/guides/nuxt/install/dynamic-import.mdx
+8-7Lines changed: 8 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,16 +7,17 @@ description: "Learn about how the Nuxt SDK leverages dynamic input() in the buil
7
7
## Understanding the `import()` expression
8
8
9
9
<Alertlevel='warning'>
10
-
This installation method does not work with more recent versions of Nuxt/Nitro.
10
+
This installation method doesn't work with more recent versions of Nuxt/Nitro.
11
11
12
-
We recommend the guide for installing the SDK with the <PlatformLinkto="/install/cli-import">CLI flag `--import`</PlatformLink> or <PlatformLinkto="/install/limited-server-tracing">limited server tracing</PlatformLink>
12
+
We recommend reading the guide for installing the SDK with the <PlatformLinkto="/install/cli-import">CLI flag `--import`</PlatformLink> or <PlatformLinkto="/install/limited-server-tracing">limited server tracing</PlatformLink>
13
13
</Alert>
14
14
15
15
The `import()` expression, or dynamic import, enables flexible, conditional module loading in ESM.
16
-
For the Sentry Nuxt SDK, it provides an approach to initialize server-side Sentry configuration before application startup.
16
+
Node.js will generate a separate module graph for any code wrapped in a dynamic `import()`. This separate graph is evaluated **after** all modules, which are statically `import`ed.
17
17
18
-
The Sentry Nuxt SDK will be initialized before any other code runs and the Nitro server runtime code will be loaded later because of `import()`ing it.
19
-
This early initialization is required to set up the SDK's instrumentation of various libraries correctly.
18
+
By using the Sentry Nuxt SDK, the server-side application will be wrapped in a dynamic `import()`, while the Sentry configuration will be imported with a static `import`.
19
+
This makes it possible to initialize the Sentry Nuxt SDK at startup, while the Nitro server runtime loads later because it is `import()`ed.
20
+
This early initialization of Sentry is required to correctly set up the SDK's instrumentation of various libraries.
0 commit comments