Skip to content

Commit 1346443

Browse files
authored
docs(configuration): update node options (#7116)
1 parent f6e05a0 commit 1346443

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/content/configuration/node.mdx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ contributors:
1010
- EugeneHlushko
1111
- anikethsaha
1212
- chenxsan
13+
- snitin315
1314
---
1415

1516
The following Node.js options configure whether to polyfill or mock certain [Node.js globals](https://nodejs.org/docs/latest/api/globals.html).
@@ -53,24 +54,26 @@ Options:
5354

5455
## node.\_\_filename
5556

56-
`boolean` `'mock' | 'warn-mock' | 'eval-only'`
57+
`boolean` `'mock' | 'warn-mock' | 'node_module' | 'eval-only'`
5758

5859
Options:
5960

6061
- `true`: The filename of the **input** file relative to the [`context` option](/configuration/entry-context/#context).
6162
- `false`: Webpack won't touch your `__filename` code, which means you have the regular Node.js `__filename` behavior. The filename of the **output** file when run in a Node.js environment.
6263
- `'mock'`: The fixed value `'/index.js'`.
6364
- `'warn-mock'`: Use the fixed value of `'/index.js'` but show a warning.
65+
- `node_module`: Replace `__filename` in CommonJS modules to `fileURLToPath(import.meta.url)` when `output.module` is enabled.
6466
- `'eval-only'`
6567

6668
## node.\_\_dirname
6769

68-
`boolean` `'mock' | 'warn-mock' | 'eval-only'`
70+
`boolean` `'mock' | 'warn-mock' | 'node_module' | 'eval-only'`
6971

7072
Options:
7173

7274
- `true`: The dirname of the **input** file relative to the [`context` option](/configuration/entry-context/#context).
7375
- `false`: Webpack won't touch your `__dirname` code, which means you have the regular Node.js `__dirname` behavior. The dirname of the **output** file when run in a Node.js environment.
7476
- `'mock'`: The fixed value `'/'`.
7577
- `'warn-mock'`: Use the fixed value of `'/'` but show a warning.
78+
- `node_module`: Replace `__dirname` in CommonJS modules to `fileURLToPath(import.meta.url + "/..")` when `output.module` is enabled.
7679
- `'eval-only'`

0 commit comments

Comments
 (0)