Skip to content

Commit 65f4159

Browse files
committed
PR feedback
1 parent a5d2063 commit 65f4159

File tree

5 files changed

+29
-33
lines changed

5 files changed

+29
-33
lines changed

docs/platforms/javascript/guides/nestjs/install/commonjs.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ supported:
1111
[installation methods](../).
1212
</Alert>
1313

14-
Most node applications today are either written in CommonJS (CJS), or compiled to CJS before running them.
15-
CommonJS uses `require()` to load modules.
14+
Most node applications today are either written in or compiled to CommonJS (CJS), which uses `require()` to load modules.
15+
Nest.js, by default, transpiles your TypeScript code into CommonJS.
1616

17-
You can find installation instructions for CommonJS in the SDK's <PlatformLink to="/">Quick Start guide</PlatformLink>.
17+
You can follow the installation instructions in the SDK's <PlatformLink to="/">Quick Start guide</PlatformLink>.

docs/platforms/javascript/guides/nestjs/install/esm-without-import.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: ESM without CLI Flag
2+
title: ESM Without CLI Flag
33
sidebar_order: 11
44
description: "Learn about running Sentry in an ESM application, without the --import flag."
55
supported:
@@ -17,13 +17,13 @@ When running your application in ESM mode, you will most likely want to <Platfor
1717

1818
This installation method has the fundamental restriction that only native Node.js APIs can be instrumented (such as `fetch` and the `http` module).
1919

20-
As a result, the Sentry SDK will not capture data from database calls, queues, ORMs, third-party libraries, or other framework-specific data.
20+
As a result, the Sentry SDK will **not** capture data from database calls, queues, ORMs, third-party libraries, or other framework-specific data.
2121

2222
We recommend using this only if the `--import` flag is not an option for you.
2323

2424
</Alert>
2525

26-
You need to create a file named `instrument.mjs` that imports and initializes Sentry:
26+
**Step 1:** Create a file named `instrument.mjs` that imports and initializes Sentry:
2727

2828
```javascript {tabTitle:ESM} {filename: instrument.mjs}
2929
import * as Sentry from "@sentry/nestjs";
@@ -38,14 +38,14 @@ Sentry.init({
3838
});
3939
```
4040

41-
You need to import the `instrument.mjs` file before importing any other modules in your application. This is necessary to ensure that Sentry can automatically instrument all modules in your application:
41+
**Step 2:** Import the `instrument.mjs` file before importing any other modules in your in the `main.ts` file of your application. This ensures that Sentry can automatically instrument all modules in your application:
4242

43-
```javascript {filename: main.js}
43+
```javascript {filename: main.ts}
4444
// Import this first!
4545
import "./instrument";
4646

4747
// Now import other modules
48-
import http from "http";
49-
48+
import { NestFactory } from "@nestjs/core";
49+
// ...
5050
// Your application code goes here
5151
```

docs/platforms/javascript/guides/nestjs/install/esm.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ supported:
1111
[installation methods](../).
1212
</Alert>
1313

14-
When running your application in ESM mode, you can't use `require()` to load modules. Instead, you have to use the `--import` command line options to load a module before the application starts.
14+
When running your application in [ECMAScript Modules](https://nodejs.org/api/esm.html#introduction) (ESM) mode, you can't use `require()` to load modules. Instead, you have to use the `--import` command line options to load a module before the application starts.
1515

16-
You need to create a file named `instrument.mjs` that imports and initializes Sentry:
16+
**Step 1:** Create a file named `instrument.mjs` that imports and initializes Sentry:
1717

1818
```javascript {tabTitle:ESM} {filename: instrument.mjs}
1919
import * as Sentry from "@sentry/nestjs";
@@ -28,24 +28,24 @@ Sentry.init({
2828
});
2929
```
3030

31-
Adjust the Node.js call for your application to use the [--import](https://nodejs.org/api/cli.html#--importmodule) parameter and point it at `instrument.mjs`, which contains your `Sentry.init()` code:
31+
**Step 2:** Adjust your application's start command to use the [--import](https://nodejs.org/api/cli.html#--importmodule) parameter:
3232

3333
```bash
3434
# Note: This is only available for Node v18.19.0 onwards.
35-
node --import ./instrument.mjs dist/main.js
35+
"start": "--import ./instrument.mjs nest start"
3636
```
3737

38-
If it is not possible for you to pass the `--import` flag to the Node.js binary, you can alternatively use the `NODE_OPTIONS` environment variable as follows:
38+
If you can't pass the `--import` flag to the Node.js binary, you can alternatively use the `NODE_OPTIONS` environment variable as follows:
3939

4040
```bash
4141
NODE_OPTIONS="--import ./instrument.mjs" npm run start
4242
```
4343

44-
We do not support ESM in Node versions before 18.19.0.
44+
<Alert>We do not support ESM in Node versions before 18.19.0.</Alert>
4545

46-
## Troubleshooting instrumentation
46+
## Troubleshooting ESM Instrumentation
4747

48-
By default, all packages are wrapped under the hood by
48+
By default, all packages are automatically wrapped by
4949
[import-in-the-middle](https://www.npmjs.com/package/import-in-the-middle) to
5050
aid instrumenting them.
5151

docs/platforms/javascript/guides/nestjs/install/esm__v8.x.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ noindex: true
1212
[installation methods](../).
1313
</Alert>
1414

15-
When running your application in ESM mode, you can't use `require()` to load modules. Instead, you have to use the `--import` command line options to load a module before the application starts.
15+
When running your application in [ECMAScript Modules](https://nodejs.org/api/esm.html#introduction) (ESM) mode, you can't use `require()` to load modules. Instead, you have to use the `--import` command line options to load a module before the application starts.
1616

17-
You need to create a file named `instrument.mjs` that imports and initializes Sentry:
17+
**Step 1:** Create a file named `instrument.mjs` that imports and initializes Sentry:
1818

1919
```javascript {tabTitle:ESM} {filename: instrument.mjs}
2020
import * as Sentry from "@sentry/nestjs";
@@ -29,24 +29,24 @@ Sentry.init({
2929
});
3030
```
3131

32-
Adjust the Node.js call for your application to use the [--import](https://nodejs.org/api/cli.html#--importmodule) parameter and point it at `instrument.js`, which contains your `Sentry.init()` code:
32+
**Step 2:** Adjust your application's start command to use the [--import](https://nodejs.org/api/cli.html#--importmodule) parameter:
3333

3434
```bash
3535
# Note: This is only available for Node v18.19.0 onwards.
36-
node --import ./instrument.mjs dist/main.js
36+
"start": "--import ./instrument.mjs nest start"
3737
```
3838

39-
If it is not possible for you to pass the `--import` flag to the Node.js binary, you can alternatively use the `NODE_OPTIONS` environment variable as follows:
39+
If you can't pass the `--import` flag to the Node.js binary, you can alternatively use the `NODE_OPTIONS` environment variable as follows:
4040

4141
```bash
4242
NODE_OPTIONS="--import ./instrument.mjs" npm run start
4343
```
4444

45-
We do not support ESM in Node versions before 18.19.0.
45+
<Alert>We do not support ESM in Node versions before 18.19.0.</Alert>
4646

4747
## Troubleshooting instrumentation
4848

49-
By default, all packages are wrapped under the hood by
49+
By default, all packages are automatically wrapped by
5050
[import-in-the-middle](https://www.npmjs.com/package/import-in-the-middle) to
5151
aid instrumenting them.
5252

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Installation Methods
33
sidebar_order: 1
4-
description: "Review our alternate installation methods."
4+
description: "Review our alternate installation methods for Sentry using Nest.js."
55
supported:
66
- javascript.nestjs
77
---
@@ -11,24 +11,20 @@ supported:
1111
## How To Decide Which Installation Method To Use
1212

1313
Most node applications today are either written in CommonJS (CJS), or compiled to CJS before running them.
14-
CommonJS uses `require()` to load modules. Our recommended installation method when using CommonJS is to require the `instrument.js` file at the top of your application. However, if your application is run in ESM mode, this will not work. In this case, you can follow the [ESM docs](./esm).
14+
CommonJS uses `require()` to load modules. Our recommended installation method when using CommonJS is to require the `instrument.js` file at the top of your application. However, if your application is run in ESM mode, this will not work, in which case, you can follow the [ESM docs](./esm).
1515

1616
Note that even if your application is written in ESM (using `import`), it may still be _run_ in CJS. In this case, you should follow the [CommonJS instructions](./commonjs).
1717

1818
### My application uses the default Nest.js setup
1919

2020
Nest.js transpiles to CJS by default, so you should follow the [CommonJS installation instructions](./commonjs). Keep reading if you have a more customized application or build setup.
2121

22-
### My application is in TypeScript
23-
24-
If you're using TypeScript, your application is likely compiled to CommonJS before running it. In this case, you should follow the [CommonJS instructions](./commonjs).
25-
2622
### My application uses `require`
2723

28-
If you are using `require()` in your application, you should follow the [CommonJS instructions](./commonjs).
24+
If you're using `require()` in your application, you should follow the [CommonJS instructions](./commonjs).
2925

3026
### My application uses `import`
3127

32-
If you are using `import` in your application, your installation method depends on how your application is _run_. If you compile your application (e.g. into a `/dist` folder or similar) before running this, you need to check how the compiled code looks like. Is the compiled code using `require`? Then you should follow the [CommonJS instructions](./commonjs). If the compiled code is using `import`, you should follow the [ESM instructions](./esm).
28+
If you're using `import` in your application, your installation method depends on how your application is _run_. If you compile your application (for example, into a `/dist` folder or similar) before running it, you need to check how the compiled code looks like. Is the compiled code using `require`? Then you should follow the [CommonJS instructions](./commonjs). If the compiled code is using `import`, you should follow the [ESM instructions](./esm).
3329

3430
If you do not compile your code, you'll need to follow the [ESM instructions](./esm).

0 commit comments

Comments
 (0)