Skip to content

Commit dec3412

Browse files
committed
docs(README): update
1 parent d49e166 commit dec3412

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import { Context } from 'vm';
4242
import { TransformOptions } from 'esbuild';
4343

4444
interface Options {
45+
filename?: string
4546
dirname?: string
4647
globals?: Context
4748
useCurrentGlobal?: boolean
@@ -61,9 +62,27 @@ declare const importFromStringSync: (code: string, options?: ImportOptions) => a
6162
declare const createImportFromStringSync: (options?: ImportOptions) => typeof importFromStringSync
6263
```
6364
65+
### filename
66+
67+
Name, path or URL string of the virtual file for better exception stack trace.
68+
69+
```js
70+
requireFromString(
71+
"throw new Error('boom!')",
72+
{ filename: '/home/foo.js' }
73+
)
74+
// /home/foo.js:1
75+
// throw new Error('boom!')
76+
// ^
77+
//
78+
// Error: boom!
79+
// at /home/foo.js:1:7
80+
// at ...
81+
```
82+
6483
### dirname
6584

66-
An absolute path of the directory for resolving `require` or `import` from relative path.
85+
Path or URL string of the directory for resolving `require` or `import` from relative path.
6786

6887
```js
6988
requireFromString(

0 commit comments

Comments
 (0)