Read only
    function transform(file, { j }) {
      const root = j(file.source);
    
      // If the file does not use @vercel/analytics/react exit early
      if (!root.find(j.ImportDeclaration, { source: { value: '@vercel/analytics/react' } }).size()) {
        return;
      }
      
      // Find all import declarations
      root.find(j.ImportDeclaration)
        .filter(path => path.node.source.value === '@vercel/analytics/react') // Find the specific import
        .forEach(path => {
          // Replace with new module path
          path.node.source.value = '@vercel/analytics/next';
        });
    
      return root.toSource();
    }
    
    export default transform;
    
    
    Input
    import { Analytics } from '@vercel/analytics/react';
     
    export default function RootLayout({
      children,
    }: {
      children: React.ReactNode;
    }) {
      return (
        <html lang="en">
          <head>
            <title>Next.js</title>
          </head>
          <body>
            {children}
            <Analytics />
          </body>
        </html>
      );
    }
    Output
    loading
    Read-only
    Open on CodeSandboxOpen Sandbox