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

Function ncc_edge_runtime

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

Source from the content-addressed store, hash-verified

436
437externals['edge-runtime'] = 'next/dist/compiled/edge-runtime'
438export async function ncc_edge_runtime(task, opts) {
439 const vmPath = resolveFrom(
440 dirname(require.resolve('edge-runtime')),
441 '@edge-runtime/vm/dist/edge-vm'
442 )
443
444 const content = await fs.readFile(vmPath, 'utf8')
445
446 // ensure ncc doesn't attempt to bundle dynamic requires
447 // so that they work at runtime correctly
448 await fs.writeFile(
449 vmPath,
450 content.replace(
451 /require\.resolve\('@edge-runtime\/primitives/g,
452 `__non_webpack_require__.resolve('next/dist/compiled/@edge-runtime/primitives`
453 )
454 )
455
456 await task
457 .source(relative(__dirname, require.resolve('edge-runtime')))
458 .ncc({ packageName: 'edge-runtime', externals })
459 .target('src/compiled/edge-runtime')
460
461 const outputFile = join(__dirname, 'src/compiled/edge-runtime/index.js')
462
463 await fs.writeFile(
464 outputFile,
465 (await fs.readFile(outputFile, 'utf8')).replace(
466 /eval\("require"\)/g,
467 'require'
468 )
469 )
470}
471
472export async function ncc_next_font(task, opts) {
473 // `@next/font` can be copied as is, its only dependency is already NCCed

Callers

nothing calls this directly

Calls 10

targetMethod · 0.80
resolveMethod · 0.65
writeFileMethod · 0.65
replaceMethod · 0.65
resolveFromFunction · 0.50
dirnameFunction · 0.50
relativeFunction · 0.50
joinFunction · 0.50
readFileMethod · 0.45
sourceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…