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

Function copy_babel_runtime

packages/next/taskfile.js:163–199  ·  view source on GitHub ↗
(task, opts)

Source from the content-addressed store, hash-verified

161
162externals['@babel/runtime'] = 'next/dist/compiled/@babel/runtime'
163export async function copy_babel_runtime(task, opts) {
164 const runtimeDir = dirname(require.resolve('@babel/runtime/package.json'))
165 const outputDir = join(__dirname, 'src/compiled/@babel/runtime')
166 const runtimeFiles = glob.sync('**/*', {
167 cwd: runtimeDir,
168 ignore: ['node_modules/**/*'],
169 })
170
171 for (const file of runtimeFiles) {
172 const inputPath = join(runtimeDir, file)
173 const outputPath = join(outputDir, file)
174
175 if (!(await fs.stat(inputPath)).isFile()) {
176 continue
177 }
178 let contents = await fs.readFile(inputPath, 'utf8')
179
180 if (inputPath.endsWith('.js')) {
181 contents = contents
182 .replace(
183 'regenerator-runtime',
184 'next/dist/compiled/regenerator-runtime'
185 )
186 .replace('@babel/runtime', 'next/dist/compiled/@babel/runtime')
187 }
188
189 if (inputPath.endsWith('package.json')) {
190 contents = JSON.stringify({
191 ...JSON.parse(contents),
192 dependencies: {},
193 })
194 }
195
196 await fs.mkdir(dirname(outputPath), { recursive: true })
197 await fs.writeFile(outputPath, contents)
198 }
199}
200
201externals['@vercel/og'] = 'next/dist/compiled/@vercel/og'
202export async function copy_vercel_og(task, opts) {

Callers

nothing calls this directly

Calls 12

isFileMethod · 0.80
mkdirMethod · 0.80
resolveMethod · 0.65
statMethod · 0.65
replaceMethod · 0.65
writeFileMethod · 0.65
dirnameFunction · 0.50
joinFunction · 0.50
readFileMethod · 0.45
endsWithMethod · 0.45
stringifyMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected