MCPcopy Create free account
hub / github.com/babel/babel / _eval

Function _eval

packages/babel-node/src/_babel-node.ts:96–118  ·  view source on GitHub ↗
(code: string, filename: string)

Source from the content-addressed store, hash-verified

94});
95
96const _eval = function (code: string, filename: string) {
97 code = code.trim();
98 if (!code) return undefined;
99
100 hasTopLevelAwait = false;
101
102 code = babel.transformSync(code, {
103 filename: filename,
104 ...babelOptions,
105 parserOpts: {
106 allowAwaitOutsideFunction: true,
107 },
108 plugins: (opts.plugins || []).concat([replPlugin]),
109 }).code;
110
111 if (hasTopLevelAwait) {
112 code = `(async () => { ${code} })()`;
113 }
114
115 return vm.runInThisContext(code, {
116 filename: filename,
117 });
118};
119
120if (opts.eval || opts.print) {
121 let code = opts.eval;

Callers 5

_babel-node.tsFile · 0.85
replEvalFunction · 0.85
output.jsFile · 0.85
output.jsFile · 0.85
output.jsFile · 0.85

Calls 1

concatMethod · 0.45

Tested by

no test coverage detected