Files
JJ KasperandGitHub 6d05b8373b Experimental deferred entries handling (#88347)
This is just an exploration into a deferred entries hook in
`next.config` to allow waiting to build specific entries until all other
entries have processed allowing external discovery of assets from
compilation that can be used in building these deferred entries.

x-ref: [slack
thread](https://vercel.slack.com/archives/C09125LC4AX/p1767991281352189?thread_ts=1766951034.768869&cid=C09125LC4AX)
2026-02-03 18:27:17 +00:00

30 lines
896 B
JavaScript

const fs = require('fs')
const path = require('path')
// A simple webpack loader that logs when an entry is being processed
module.exports = function entryLoggerLoader(source) {
const callback = this.async()
const resourcePath = this.resourcePath
const logFile = path.join(__dirname, '.entry-log')
console.log('loader', resourcePath)
// Extract the page name from the resource path
let pageName = resourcePath
if (resourcePath.includes('/app/')) {
pageName = resourcePath.split('/app/')[1] || resourcePath
} else if (resourcePath.includes('/pages/')) {
pageName = resourcePath.split('/pages/')[1] || resourcePath
}
// Log the entry processing with timestamp
const logEntry = `${Date.now()}:${pageName}\n`
fs.appendFile(logFile, logEntry, (err) => {
if (err) {
console.error('Failed to write entry log:', err)
}
callback(null, source)
})
}