next.js / test /e2e /filesystem-cache /my-timestamp-loader.js
AbdulElahGwaith's picture
Upload folder using huggingface_hub
b91e262 verified
module.exports = async function myLoader(source) {
console.log(`Run my-timestamp-loader on ${this.resourcePath}`)
if (this._compiler && this._compiler.__extra_delay) {
if (!this._compilation.__extra_delay) {
this._compilation.__extra_delay = true
// Make webpack consider the build as large change which makes it filesystem cache it sooner
await new Promise((resolve) => setTimeout(resolve, 2000))
}
}
return source.replace(/Timestamp/g, `Timestamp = ${Date.now()}`)
}