MCPcopy
hub / github.com/TypeStrong/ts-node / attemptRequireWithV8CompileCache

Function attemptRequireWithV8CompileCache

src/util.ts:100–116  ·  view source on GitHub ↗
(
  requireFn: typeof require,
  specifier: string
)

Source from the content-addressed store, hash-verified

98 * Do lots of error-handling so that, worst case, we require without the cache, and users are not blocked.
99 */
100export function attemptRequireWithV8CompileCache(
101 requireFn: typeof require,
102 specifier: string
103) {
104 try {
105 const v8CC = (
106 require('v8-compile-cache-lib') as typeof import('v8-compile-cache-lib')
107 ).install();
108 try {
109 return requireFn(specifier);
110 } finally {
111 v8CC?.uninstall();
112 }
113 } catch (e) {
114 return requireFn(specifier);
115 }
116}
117
118/**
119 * Helper to discover dependencies relative to a user's project, optionally

Callers 1

loadCompilerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…