mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
https://github.com/vercel/next.js/pull/94197 had a bug in the Turbopack case, where it didn't properly trace all necessary files referenced from `cacheHandler` and `cacheHandlers`. If you imported `lodash` in the cache handler, then - `node_modules/.pnpm/[email protected].1/node_modules/lodash/lodash.js` was correctly traced but missing were - `node_modules/.pnpm/[email protected].1/node_modules/lodash/package.json` and - `node_modules/lodash` (the symlink) The problem was that it wasn't including affecting sources of these entrypoints, because it was treating those entrypoints as bundled: ``` SingleModuleGraph::new_inner( entries: Vec<ChunkGroupEntry>, visited_modules: &FxIndexMap<ResolvedVc<Box<dyn Module>>, GraphNodeIndex>, include_traced: bool, include_binding_usage: bool, entries_are_traced: bool, // <------ problematic ) -> Result<Vc<Self>> ``` should really have been ``` SingleModuleGraph::new_inner( entries: &GraphEntries, // contains Vec<ChunkGroupEntry> and traced_modules: Vec<Modules visited_modules: &FxIndexMap<ResolvedVc<Box<dyn Module>>, GraphNodeIndex>, include_traced: bool, include_binding_usage: bool, ) -> Result<Vc<Self>> { ``` because the single `entries_are_traced: bool` can be different per entry.
26 lines
586 B
JavaScript
26 lines
586 B
JavaScript
const cache = new Map()
|
|
const isEven = require('is-even')
|
|
|
|
module.exports = class CacheHandler {
|
|
constructor() {
|
|
console.log('initialized custom cache-handler: ', isEven(3))
|
|
}
|
|
|
|
async get(key, ctx) {
|
|
console.log('cache-handler get', key, ctx)
|
|
|
|
if (ctx.softTags?.some((tag) => tag.includes('?'))) {
|
|
throw new Error(`invalid soft tag found should only be pathname`)
|
|
}
|
|
return cache.get(key)
|
|
}
|
|
|
|
async set(key, data, ctx) {
|
|
console.log('cache-handler set', key, ctx)
|
|
cache.set(key, {
|
|
value: data,
|
|
lastModified: Date.now(),
|
|
})
|
|
}
|
|
}
|