Skip to content

Commit e32026d

Browse files
committed
review suggestions
1 parent caa2c80 commit e32026d

File tree

3 files changed

+28
-26
lines changed

3 files changed

+28
-26
lines changed

docs/platforms/javascript/guides/nuxt/install/cli-import.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@ description: "Learn about using the node `--import` CLI flag."
77
## Understanding the `--import` CLI Flag
88

99
The [`--import` CLI flag](https://nodejs.org/api/cli.html#--importmodule) in Node allows you to preload modules before the application starts.
10-
This flag is crucial for ensuring proper server-side initialization, as Sentry needs to be initialized before the rest of the application runs.
10+
If you cannot use the SDK's <PlatformLink to="/install/dynamic-import/">default dynamic import behaviour</PlatformLink>, setting
11+
this flag is crucial for ensuring proper server-side initialization, as Sentry needs to be initialized before the rest of the application runs.
1112

1213
## Scenarios where `--import` does not work
1314

14-
- You are not able to add Node CLI flags or environment variables that are scoped to the function runtime
15+
- You're not able to add Node CLI flags or environment variables that are scoped to the function runtime
1516
- As of now, Netlify only supports adding scoped environment variables in the paid plan
1617
- As of now, Vercel does not provide an option for scoping environment variables
1718

1819
If any of those points apply to you, you cannot use the `--import` flag to initialize Sentry on the server-side.
19-
Check out the guide for using <PlatformLink to="/install/dynamic-import/">dynamic import</PlatformLink> as this might be a better choice for you.
20+
Check out the guide for using <PlatformLink to="/install/dynamic-import/">dynamic import</PlatformLink> instead.
2021

2122
## Initializing Sentry with `--import`
2223

2324
To successfully use the `--import` flag, follow these steps:
2425

2526
### 1. Disable Dynamic Import
2627

27-
First, you have to first disable the dynamic import.
28-
This can be done by setting `dynamicImportForServerEntry` to `false`:
28+
First, disable the dynamic import by setting `dynamicImportForServerEntry` to `false`:
2929

3030
```javascript {filename: nuxt.config.ts} {5}
3131
export default defineNuxtConfig({

docs/platforms/javascript/guides/nuxt/install/dynamic-import.mdx

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,25 @@ description: "Learn about how the Nuxt SDK leverages dynamic input() in the buil
88

99
The `import()` expression (also called "dynamic import") allows conditional and flexible module loading in ESM.
1010
For the Sentry Nuxt SDK, it provides an approach to initialize server-side configuration before application startup.
11+
This early initialization is required to set up the SDK's instrumentation of various libraries correctly.
1112

12-
## Scenarios where `import()` does not work
13+
## Initializing Sentry with Dynamic `import()`
14+
15+
By default, the Sentry Nuxt SDK includes a Rollup plugin which wraps the server entry file with a dynamic `import()`.
16+
With this, Sentry can be initialized before all other modules of the application.
17+
18+
The server entry file will look something like this:
19+
20+
```javascript {filename:.output/server/index.mjs}
21+
// Note: file may have some imports and code related to debug IDs
22+
Sentry.init({
23+
dsn: "..."
24+
});
25+
26+
import('./chunks/nitro/nitro.mjs').then(function (n) { return n.r; });
27+
```
28+
29+
## Scenarios where `import()` doesn't work
1330

1431
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).
1532
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:
@@ -38,22 +55,6 @@ We are working on figuring this out ([see issue here](https://github.com/getsent
3855
You can also check out the guide for using the <PlatformLink to="/install/cli-import//">CLI flag `--import`</PlatformLink> as this might be a better choice for you.
3956

4057

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
50-
Sentry.init({
51-
dsn: "..."
52-
});
53-
54-
import('./chunks/nitro/nitro.mjs').then(function (n) { return n.r; });
55-
```
56-
5758
## Re-exporting serverless handler functions
5859

5960
Sentry automatically detects serverless handler functions in the build output and re-exports them from the server entry file.
@@ -62,7 +63,7 @@ By default, Sentry re-exports functions named `handler`, `server`, and `default`
6263
In case your serverless function has another, custom name you can override this with `entrypointWrappedFunctions`:
6364

6465

65-
```javascript {filename: nuxt.config.ts} {6}
66+
```javascript {filename: nuxt.config.ts} {7}
6667
export default defineNuxtConfig({
6768
modules: ["@sentry/nuxt/module"],
6869

@@ -77,3 +78,5 @@ export default defineNuxtConfig({
7778

7879

7980

81+
82+

docs/platforms/javascript/guides/nuxt/install/index.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ sidebar_order: 1.5
44
description: "Review our alternate installation methods."
55
---
66

7-
<PageGrid />
7+
88

99
Nuxt uses ES Modules for server-side builds, which requires Sentry to register Node [customization hooks](https://nodejs.org/api/module.html#customization-hooks).
1010
Those customization hooks need to be registered before the rest of the application.
1111

1212
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:
1313

14-
- Dynamically import server code after initializing Sentry (default)
15-
- Preload Sentry configuration with the Node `--import` CLI flag
14+
<PageGrid />

0 commit comments

Comments
 (0)