next
Version:
The React Framework
50 lines (49 loc) • 1.69 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "cacheTag", {
enumerable: true,
get: function() {
return cacheTag;
}
});
const _workunitasyncstorageexternal = require("../app-render/work-unit-async-storage.external");
const _patchfetch = require("../lib/patch-fetch");
function cacheTag(...tags) {
if (!process.env.__NEXT_USE_CACHE) {
throw Object.defineProperty(new Error('`cacheTag()` is only available with the `cacheComponents` config.'), "__NEXT_ERROR_CODE", {
value: "E886",
enumerable: false,
configurable: true
});
}
const workUnitStore = _workunitasyncstorageexternal.workUnitAsyncStorage.getStore();
switch(workUnitStore == null ? void 0 : workUnitStore.type){
case 'prerender':
case 'prerender-client':
case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy':
case 'request':
case 'unstable-cache':
case undefined:
throw Object.defineProperty(new Error('`cacheTag()` can only be called inside a "use cache" function.'), "__NEXT_ERROR_CODE", {
value: "E819",
enumerable: false,
configurable: true
});
case 'cache':
case 'private-cache':
break;
default:
workUnitStore;
}
const validTags = (0, _patchfetch.validateTags)(tags, '`cacheTag()`');
if (!workUnitStore.tags) {
workUnitStore.tags = validTags;
} else {
workUnitStore.tags.push(...validTags);
}
}
//# sourceMappingURL=cache-tag.js.map