mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
Stacked on https://github.com/vercel/next.js/pull/84877, https://github.com/vercel/next.js/pull/84880 This PR adds a codemod for removing the `unstable_` prefix for stabilized APIs. It is considered to scale by adding more APIs to the `UNSTABLE_TO_STABLE_MAPPING` map in the future to this codemod. Closes NEXT-4739
26 lines
1.0 KiB
TypeScript
26 lines
1.0 KiB
TypeScript
// @ts-nocheck
|
|
import { cacheTag as cacheTagImport, cacheLife as cacheLifeImport } from 'next/cache'
|
|
const { cacheTag: cacheTagRequire, cacheLife: cacheLifeRequire } = require('next/cache')
|
|
// Alias with same API name, alias should be removed.
|
|
import { cacheTag, cacheLife } from 'next/cache'
|
|
const { cacheTag, cacheLife } = require('next/cache')
|
|
|
|
export function MyComponent() {
|
|
const cacheTagImportTag = cacheTagImport('foo')
|
|
const cacheLifeImportLife = cacheLifeImport('1 hour')
|
|
const cacheTagRequireTag = cacheTagRequire('bar')
|
|
const cacheLifeRequireLife = cacheLifeRequire('2 hours')
|
|
const cacheTagAlias = cacheTag('redundant')
|
|
const cacheLifeAlias = cacheLife('redundant-time')
|
|
|
|
return (
|
|
<div>
|
|
<p>Using cache tag: {cacheTagImportTag}</p>
|
|
<p>Using cache life: {cacheLifeImportLife}</p>
|
|
<p>Using another tag: {cacheTagRequireTag}</p>
|
|
<p>Using another life: {cacheLifeRequireLife}</p>
|
|
<p>Using same alias tag: {cacheTagAlias}</p>
|
|
<p>Using same alias life: {cacheLifeAlias}</p>
|
|
</div>
|
|
)
|
|
} |