Files
Jiwon ChoiandGitHub 6bd5c47b90 Add codemod for removing unstable_ prefix (#84974)
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
2025-10-17 00:55:30 +02:00

26 lines
1.1 KiB
TypeScript

// @ts-nocheck
import { unstable_cacheTag as cacheTagImport, unstable_cacheLife as cacheLifeImport } from 'next/cache'
const { unstable_cacheTag: cacheTagRequire, unstable_cacheLife: cacheLifeRequire } = require('next/cache')
// Alias with same API name, alias should be removed.
import { unstable_cacheTag as cacheTag, unstable_cacheLife as cacheLife } from 'next/cache'
const { unstable_cacheTag: cacheTag, unstable_cacheLife: 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>
)
}