File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ import { Context } from 'vm';
4242import { TransformOptions } from ' esbuild' ;
4343
4444interface 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
6162declare 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
6988requireFromString (
You can’t perform that action at this time.
0 commit comments