mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
7818c2d736
Use dynamic import instead of require to load the incremental cache handled, so when using ESM it will still work. Updated the tests and merged them into new test suite, include 3 cases of custom cache definition: - CJS with `module.exports` - CJS with `exports.default` with ESM mark - ESM with `export default` Closes NEXT-1924 Fixes #58509
28 lines
756 B
JavaScript
28 lines
756 B
JavaScript
Object.defineProperty(exports, '__esModule', { value: true })
|
|
|
|
const cache = new Map()
|
|
|
|
const CacheHandler = /** @class */ (function () {
|
|
function CacheHandler(options) {
|
|
this.options = options
|
|
this.cache = cache
|
|
console.log('initialized custom cache-handler')
|
|
console.log('cache handler - cjs default export')
|
|
}
|
|
CacheHandler.prototype.get = function (key) {
|
|
console.log('cache-handler get', key)
|
|
return Promise.resolve(this.cache.get(key))
|
|
}
|
|
CacheHandler.prototype.set = function (key, data) {
|
|
console.log('cache-handler set', key)
|
|
this.cache.set(key, {
|
|
value: data,
|
|
lastModified: Date.now(),
|
|
})
|
|
return Promise.resolve(undefined)
|
|
}
|
|
return CacheHandler
|
|
})()
|
|
|
|
exports.default = CacheHandler
|