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

Method runTrace

turbopack/packages/webpack-nmt/src/index.ts:73–139  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

71 }
72
73 private async runTrace() {
74 process.stdout.write('\n')
75 const cwd = this.options?.cwd ?? process.cwd()
76 const args = [
77 'annotate',
78 '--context-directory',
79 // `npm_config_local_prefix` set by `npm` to the root of the project, include workspaces
80 // `PROJECT_CWD` set by `yarn` to the root of the project, include workspaces
81 this.options?.contextDirectory ??
82 process.env.npm_config_local_prefix ??
83 process.env.PROJECT_CWD ??
84 cwd,
85 '--exact',
86 ]
87 if (this.options?.log?.detail) {
88 args.push('--log-detail')
89 }
90 if (this.options?.log?.all) {
91 args.push('--show-all')
92 }
93 const logLevel = this.options?.log?.level
94 if (logLevel) {
95 args.push(`--log-level`)
96 args.push(logLevel)
97 }
98 let turboTracingPackagePath = ''
99 let turboTracingBinPath = ''
100 try {
101 turboTracingPackagePath = require.resolve(
102 '@vercel/experimental-nft/package.json'
103 )
104 } catch (e) {
105 console.warn(
106 `Could not resolve the @vercel/experimental-nft directory, turbo tracing may fail.`
107 )
108 }
109 if (turboTracingPackagePath) {
110 try {
111 const turboTracingBinPackageJsonPath = require.resolve(
112 `@vercel/experimental-nft-${process.platform}-${process.arch}/package.json`,
113 {
114 paths: [join(turboTracingPackagePath, '..')],
115 }
116 )
117 turboTracingBinPath = join(turboTracingBinPackageJsonPath, '..')
118 } catch (e) {
119 console.warn(
120 `Could not resolve the @vercel/experimental-nft-${process.platform}-${process.arch} directory, turbo tracing may fail.`
121 )
122 }
123 }
124 const pathSep = process.platform === 'win32' ? ';' : ':'
125 let paths = `${this.options?.path ?? ''}${pathSep}${process.env.PATH}`
126 if (turboTracingBinPath) {
127 paths = `${turboTracingBinPath}${pathSep}${paths}`
128 }
129 const maxFiles = this.options?.maxFiles ?? 128
130 let chunks = [...this.chunksToTrace]

Callers 1

applyMethod · 0.95

Calls 7

traceChunksFunction · 0.85
pushMethod · 0.65
resolveMethod · 0.65
joinFunction · 0.50
writeMethod · 0.45
warnMethod · 0.45
spliceMethod · 0.45

Tested by

no test coverage detected