Unverified Commit aaebca93 authored by PapatMayuri's avatar PapatMayuri Committed by GitHub

Updated remove-console example to utilize the app router. (#76543)

This PR updates the remove-console example for using the App Router.
Here are the changes that have been made:

- I renamed the pages folder and moved it to the app folder.
- Added the layout.tsx file as part of the App Router.
- Updated the package.json file.

CC: @samcx

---------
Co-authored-by: 's avatarMayuriPapat25 <mayuri.papat@qed42.com>
Co-authored-by: 's avatarsamcx <sam@vercel.com>
parent 8dd0b56f
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
npm-debug.log* npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
.pnpm-debug.log*
# local env files # local env files
.env*.local .env*.local
......
# Remove Console Example # Remove Console Example
This example shows how to use the Next.js [removeConsole](https://nextjs.org/docs/advanced-features/compiler#remove-console) config option to remove all `console.*` calls except `console.error`, or suppress all logs. This example shows how to use the Next.js [removeConsole](https://nextjs.org/docs/architecture/nextjs-compiler#remove-console) config option to remove all `console.*` calls except `console.error`, or suppress all logs.
## Deploy your own ## Deploy your own
......
import type { Metadata } from "next";
export const metadata: Metadata = {
title: "Remove console",
description: "Next.js example remove console",
};
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en">
<body>{children}</body>
</html>
);
}
export default function Index() { export default function Page() {
return ( return (
<div> <div>
<p>The console should be empty.</p> <p>The console should be empty.</p>
...@@ -6,5 +6,5 @@ export default function Index() { ...@@ -6,5 +6,5 @@ export default function Index() {
); );
} }
console.log("log from index.js"); console.log("log from page.tsx");
console.error("error log from index.js"); console.error("error log from page.tsx");
// @ts-check import type { NextConfig } from "next";
/** const nextConfig: NextConfig = {
* @type {import('next').NextConfig} /* config options here */
**/
const nextConfig = {
compiler: { compiler: {
// Remove `console.*` output except `console.error` // Remove `console.*` output except `console.error`
removeConsole: { removeConsole: {
...@@ -14,4 +12,4 @@ const nextConfig = { ...@@ -14,4 +12,4 @@ const nextConfig = {
}, },
}; };
module.exports = nextConfig; export default nextConfig;
...@@ -7,13 +7,13 @@ ...@@ -7,13 +7,13 @@
}, },
"dependencies": { "dependencies": {
"next": "latest", "next": "latest",
"react": "^18.2.0", "react": "^19.0.0",
"react-dom": "^18.2.0" "react-dom": "^19.0.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^18.11.5", "@types/node": "^22.13.5",
"@types/react": "^18.0.23", "@types/react": "^19.0.10",
"@types/react-dom": "^18.0.7", "@types/react-dom": "^19.0.4",
"typescript": "^4.8.4" "typescript": "^5.7.3"
} }
} }
{ {
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "ES2017",
"lib": ["dom", "dom.iterable", "esnext"], "lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true, "allowJs": true,
"skipLibCheck": true, "skipLibCheck": true,
"strict": true, "strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true, "noEmit": true,
"esModuleInterop": true, "esModuleInterop": true,
"module": "esnext", "module": "esnext",
"moduleResolution": "node", "moduleResolution": "bundler",
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,
"jsx": "preserve", "jsx": "preserve",
"incremental": true "incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./*"]
}
}, },
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"] "exclude": ["node_modules", "**/*.test.ts", "**/*.test.tsx"]
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment