Skip to content

Commit aaebca9

Browse files
PapatMayuriMayuriPapat25samcx
authored
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: MayuriPapat25 <[email protected]> Co-authored-by: samcx <[email protected]>
1 parent 8dd0b56 commit aaebca9

File tree

8 files changed

+53
-29
lines changed

8 files changed

+53
-29
lines changed

examples/remove-console/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
npm-debug.log*
2929
yarn-debug.log*
3030
yarn-error.log*
31+
.pnpm-debug.log*
3132

3233
# local env files
3334
.env*.local

examples/remove-console/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Remove Console Example
22

3-
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.
3+
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.
44

55
## Deploy your own
66

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type { Metadata } from "next";
2+
3+
export const metadata: Metadata = {
4+
title: "Remove console",
5+
description: "Next.js example remove console",
6+
};
7+
8+
export default function RootLayout({
9+
children,
10+
}: Readonly<{
11+
children: React.ReactNode;
12+
}>) {
13+
return (
14+
<html lang="en">
15+
<body>{children}</body>
16+
</html>
17+
);
18+
}

examples/remove-console/app/page.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default function Page() {
2+
return (
3+
<div>
4+
<p>The console should be empty.</p>
5+
</div>
6+
);
7+
}
8+
9+
console.log("log from page.tsx");
10+
console.error("error log from page.tsx");
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
// @ts-check
1+
import type { NextConfig } from "next";
22

3-
/**
4-
* @type {import('next').NextConfig}
5-
**/
6-
const nextConfig = {
3+
const nextConfig: NextConfig = {
4+
/* config options here */
75
compiler: {
86
// Remove `console.*` output except `console.error`
97
removeConsole: {
@@ -14,4 +12,4 @@ const nextConfig = {
1412
},
1513
};
1614

17-
module.exports = nextConfig;
15+
export default nextConfig;

examples/remove-console/package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
},
88
"dependencies": {
99
"next": "latest",
10-
"react": "^18.2.0",
11-
"react-dom": "^18.2.0"
10+
"react": "^19.0.0",
11+
"react-dom": "^19.0.0"
1212
},
1313
"devDependencies": {
14-
"@types/node": "^18.11.5",
15-
"@types/react": "^18.0.23",
16-
"@types/react-dom": "^18.0.7",
17-
"typescript": "^4.8.4"
14+
"@types/node": "^22.13.5",
15+
"@types/react": "^19.0.10",
16+
"@types/react-dom": "^19.0.4",
17+
"typescript": "^5.7.3"
1818
}
1919
}

examples/remove-console/pages/index.tsx

-10
This file was deleted.

examples/remove-console/tsconfig.json

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
{
22
"compilerOptions": {
3-
"target": "es5",
3+
"target": "ES2017",
44
"lib": ["dom", "dom.iterable", "esnext"],
55
"allowJs": true,
66
"skipLibCheck": true,
77
"strict": true,
8-
"forceConsistentCasingInFileNames": true,
98
"noEmit": true,
109
"esModuleInterop": true,
1110
"module": "esnext",
12-
"moduleResolution": "node",
11+
"moduleResolution": "bundler",
1312
"resolveJsonModule": true,
1413
"isolatedModules": true,
1514
"jsx": "preserve",
16-
"incremental": true
15+
"incremental": true,
16+
"plugins": [
17+
{
18+
"name": "next"
19+
}
20+
],
21+
"paths": {
22+
"@/*": ["./*"]
23+
}
1724
},
18-
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
19-
"exclude": ["node_modules"]
25+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
26+
"exclude": ["node_modules", "**/*.test.ts", "**/*.test.tsx"]
2027
}

0 commit comments

Comments
 (0)