MCPcopy
hub / github.com/vercel/next.js / evaluateInContext

Function evaluateInContext

packages/next/src/server/web/sandbox/context.ts:534–549  ·  view source on GitHub ↗
(filepath: string)

Source from the content-addressed store, hash-verified

532 const moduleContext = lazyModuleContext
533
534 const evaluateInContext = (filepath: string) => {
535 if (!moduleContext.paths.has(filepath)) {
536 const content = readFileSync(filepath, 'utf-8')
537 try {
538 runInContext(content, moduleContext.runtime.context, {
539 filename: filepath,
540 })
541 moduleContext.paths.set(filepath, content)
542 } catch (error) {
543 if (options.useCache) {
544 moduleContext?.paths.delete(filepath)
545 }
546 throw error
547 }
548 }
549 }
550
551 return { ...moduleContext, evaluateInContext }
552}

Callers 1

getRuntimeContextFunction · 0.85

Calls 4

readFileSyncFunction · 0.85
setMethod · 0.65
hasMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected