Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update nextjs and tailwindcss #284

Merged
merged 3 commits into from
Jan 23, 2025
Merged

chore: update nextjs and tailwindcss #284

merged 3 commits into from
Jan 23, 2025

Conversation

zce
Copy link
Owner

@zce zce commented Jan 23, 2025

upgrade nextjs to v15 and tailwindcss to v4

Summary by Sourcery

Upgrade Next.js to v15 and Tailwind CSS to v4.

Build:

  • Update Next.js configuration.

Chores:

  • Update dependencies and types.

Summary by CodeRabbit

Release Notes

  • Dependencies

    • Updated project dependencies to latest stable versions
    • Upgraded Next.js to version 15
    • Updated React to version 19
    • Migrated Tailwind CSS configuration
  • Configuration

    • Simplified TypeScript compiler settings
    • Updated PostCSS and Tailwind CSS integration
    • Removed ESLint configuration
  • Data Management

    • Transitioned content imports from #site/content to #velite

Copy link

sourcery-ai bot commented Jan 23, 2025

Reviewer's Guide by Sourcery

This pull request upgrades Next.js to v15 and Tailwind CSS to v4. It also includes necessary configuration and dependency updates to ensure compatibility with the new versions.

Class diagram showing configuration changes

classDiagram
    class PostCSSConfig {
        +plugins: Object
    }
    note for PostCSSConfig "Changed from multiple plugins to single @tailwindcss/postcss"

    class TSConfig {
        +compilerOptions: Object
        +include: String[]
        +exclude: String[]
    }
    note for TSConfig "Updated paths aliases and compiler options"

    class PackageJSON {
        +dependencies: Object
        +devDependencies: Object
        +scripts: Object
    }
    note for PackageJSON "Updated versions and removed eslint config"
Loading

File-Level Changes

Change Details Files
Updated Next.js and Tailwind CSS dependencies.
  • Upgraded next to v15.1.6.
  • Upgraded tailwindcss to v4.0.0.
  • Updated other related dependencies to their latest versions.
examples/nextjs/package.json
Updated the Next.js example README to reflect the new Next.js version.
  • Changed the Next.js version in the example description from 13 to 15.
examples/nextjs/readme.md
Updated the global CSS file to use the new Tailwind CSS v4 syntax and include compatibility styles.
  • Replaced @tailwind directives with @import 'tailwindcss'.
  • Added @plugin '@tailwindcss/typography'.
  • Added a custom variant for dark mode.
  • Added compatibility styles for border colors to match Tailwind CSS v3 defaults.
examples/nextjs/app/globals.css
Updated the tsconfig.json file to use the new '#velite' alias.
  • Changed the path alias from '#site/content' to '#velite'.
examples/nextjs/tsconfig.json
Updated the PostCSS configuration to use the new Tailwind CSS v4 plugin.
  • Replaced the tailwindcss and autoprefixer plugins with the @tailwindcss/postcss plugin.
examples/nextjs/postcss.config.js
Updated the import paths in the page components to use the new '#velite' alias.
  • Changed the import path from '#site/content' to '#velite' in the page components.
examples/nextjs/app/[slug]/page.tsx
examples/nextjs/app/page.tsx
examples/nextjs/app/posts/[slug]/page.tsx
Removed the tailwind.config.js file.
  • Removed the tailwind.config.js file.
examples/nextjs/tailwind.config.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

coderabbitai bot commented Jan 23, 2025

Walkthrough

The pull request introduces significant updates to a Next.js project, focusing on migrating from a custom content management approach to using Velite. The changes span multiple configuration files, updating import statements, dependency versions, and build configurations. The primary modifications involve transitioning data imports from #site/content to #velite, updating Tailwind CSS and PostCSS configurations, and upgrading various dependencies to more recent versions, including Next.js 15 and React 19.

Changes

File Change Summary
app/[slug]/page.tsx Updated import for pages from #site/content to #velite
app/page.tsx Updated import for posts from #site/content to #velite
app/posts/[slug]/page.tsx Updated import for posts from #site/content to #velite
app/globals.css Restructured Tailwind CSS directives, added typography plugin and dark mode variant
package.json Removed ESLint, updated multiple dependencies to specific versions
postcss.config.js Simplified plugin configuration
tsconfig.json Updated TypeScript compiler options, changed paths mapping
tailwind.config.js File removed entirely

Possibly related PRs

Poem

🐰 Velite hops, imports take flight,
Configuration dancing, oh so bright!
Dependencies update with glee,
Next.js 15 sets our project free
A rabbit's code, clean and light! 🚀

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @zce - I've reviewed your changes - here's some feedback:

Overall Comments:

  • This PR includes an upgrade to React 19 which hasn't been officially released yet. Please stick to stable releases for production dependencies.
  • Consider splitting this into separate PRs for Next.js and Tailwind CSS upgrades to make the changes more manageable and easier to review/rollback if needed.
  • Please document the migration steps and any breaking changes being addressed, particularly around the removed Velite webpack configuration and ESLint setup.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@@ -1,6 +1,6 @@
# Next.js + MDX + Velite

A template with Next.js 13 app dir, [Velite](https://github.com/zce/velite), Tailwind CSS and dark mode.
A template with Next.js 15 app dir, [Velite](https://github.com/zce/velite), Tailwind CSS and dark mode.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick (typo): Possible typo: 'A' should be 'a'.

The first word of the sentence 'A template...' might be better as 'a template...'.

Suggested change
A template with Next.js 15 app dir, [Velite](https://github.com/zce/velite), Tailwind CSS and dark mode.
a template with Next.js 15 app dir, [Velite](https://github.com/zce/velite), Tailwind CSS and dark mode.

@zce zce merged commit 0349d8b into main Jan 23, 2025
1 of 2 checks passed
@zce zce deleted the upgrade-deps branch January 23, 2025 08:06
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🔭 Outside diff range comments (1)
examples/nextjs/app/posts/[slug]/page.tsx (1)

Add HTML sanitization to prevent XSS vulnerabilities

The content processing pipeline in Velite currently allows raw HTML without sanitization. This, combined with dangerouslySetInnerHTML, could expose the application to XSS attacks. Consider:

  • Adding rehype-sanitize to the rehype plugins in velite.config.ts
  • Configuring appropriate sanitization rules to allow only safe HTML elements and attributes

Example locations:

  • examples/nextjs/velite.config.ts: Add sanitization to the markdown config
  • examples/nextjs/app/posts/[slug]/page.tsx: Content rendering with dangerouslySetInnerHTML
🔗 Analysis chain

Line range hint 28-28: Verify content sanitization for XSS prevention.

The use of dangerouslySetInnerHTML could expose the application to XSS attacks if the content isn't properly sanitized.

Let's check if Velite handles content sanitization:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for sanitization configuration in Velite setup
rg -A 5 "sanitize|xss|html" .velite.ts

Length of output: 91


Script:

#!/bin/bash
# Find Velite configuration files and content processing
fd -e ts -e js velite
rg -l "velite" .
rg -A 5 "markdown|content|html|sanitize|xss" --type ts --type js

Length of output: 20680

🧹 Nitpick comments (2)
examples/nextjs/readme.md (1)

Line range hint 11-26: Consider optimizing npm scripts for better DX.

The current script setup requires running multiple commands in parallel. Consider using Next.js's built-in support for watch mode plugins to simplify the development workflow.

Here's a suggested optimization:

 {
   "scripts": {
-    "dev:content": "velite --watch",
-    "build:content": "velite --clean",
-    "dev:next": "next dev",
-    "build:next": "next build",
-    "dev": "run-p dev:*",
-    "build": "run-s build:*",
+    "dev": "next dev",
+    "build": "velite --clean && next build",
     "start": "next start"
   }
 }
examples/nextjs/tsconfig.json (1)

3-3: Consider using a more recent JavaScript target.

Next.js 15 supports modern browsers by default. Using ES2017 as the target might unnecessarily transpile modern JavaScript features.

-    "target": "ES2017",
+    "target": "ES2020",
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bfdb8a2 and 4045320.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • examples/nextjs/app/[slug]/page.tsx (1 hunks)
  • examples/nextjs/app/globals.css (2 hunks)
  • examples/nextjs/app/page.tsx (1 hunks)
  • examples/nextjs/app/posts/[slug]/page.tsx (1 hunks)
  • examples/nextjs/package.json (1 hunks)
  • examples/nextjs/postcss.config.js (1 hunks)
  • examples/nextjs/readme.md (1 hunks)
  • examples/nextjs/tailwind.config.js (0 hunks)
  • examples/nextjs/tsconfig.json (1 hunks)
  • package.json (3 hunks)
💤 Files with no reviewable changes (1)
  • examples/nextjs/tailwind.config.js
✅ Files skipped from review due to trivial changes (2)
  • examples/nextjs/app/page.tsx
  • examples/nextjs/app/[slug]/page.tsx
🔇 Additional comments (4)
examples/nextjs/postcss.config.js (1)

2-2: ⚠️ Potential issue

Fix PostCSS configuration issues.

The current configuration has several issues that need to be addressed:

  1. The package name @tailwindcss/postcss appears incorrect. The standard package is tailwindcss.
  2. autoprefixer is missing, which is required for cross-browser compatibility and is a peer dependency of Tailwind CSS.

Apply this diff to fix the configuration:

- plugins: ['@tailwindcss/postcss']
+ plugins: {
+   'tailwindcss': {},
+   'autoprefixer': {}
+ }

Let's verify the package name and its dependencies:

examples/nextjs/app/posts/[slug]/page.tsx (1)

4-4: LGTM: Import path updated for Velite migration.

The import path change from '#site/content' to '#velite' aligns with the migration to Velite for content management.

examples/nextjs/readme.md (1)

3-3: LGTM: Next.js version updated in documentation.

Documentation correctly reflects the upgrade to Next.js 15.

examples/nextjs/tsconfig.json (1)

19-19: LGTM: Path alias updated for Velite integration.

The path alias change from '#site/content' to '#velite' correctly reflects the migration to Velite.

"shiki": "latest",
"tailwindcss": "latest",
"typescript": "latest",
"@tailwindcss/postcss": "^4.0.0",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove non-existent dependency @tailwindcss/postcss

The package @tailwindcss/postcss doesn't exist in the npm registry. Tailwind CSS already includes PostCSS integration by default.

-    "@tailwindcss/postcss": "^4.0.0",

Comment on lines +14 to +25
"@types/node": "^22.10.9",
"@types/react": "^19.0.7",
"@types/react-dom": "^19.0.3",
"next": "^15.1.6",
"next-themes": "^0.4.4",
"postcss": "^8.5.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"rehype-pretty-code": "^0.14.0",
"shiki": "^1.29.1",
"tailwindcss": "^4.0.0",
"typescript": "^5.7.3",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Critical: Multiple non-existent package versions specified

Several dependencies are specified with versions that don't exist yet:

  • next: ^15.1.6 (latest stable is 14.x)
  • react & react-dom: ^19.0.0 (latest stable is 18.x)
  • tailwindcss: ^4.0.0 (latest stable is 3.x)
  • @types/node: ^22.10.9 (latest LTS is 20.x)

Please update to the latest stable versions:

-    "@types/node": "^22.10.9",
-    "@types/react": "^19.0.7",
-    "@types/react-dom": "^19.0.3",
-    "next": "^15.1.6",
-    "react": "^19.0.0",
-    "react-dom": "^19.0.0",
-    "tailwindcss": "^4.0.0",
+    "@types/node": "^20.11.5",
+    "@types/react": "^18.2.48",
+    "@types/react-dom": "^18.2.18",
+    "next": "^14.1.0",
+    "react": "^18.2.0",
+    "react-dom": "^18.2.0",
+    "tailwindcss": "^3.4.1",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"@types/node": "^22.10.9",
"@types/react": "^19.0.7",
"@types/react-dom": "^19.0.3",
"next": "^15.1.6",
"next-themes": "^0.4.4",
"postcss": "^8.5.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"rehype-pretty-code": "^0.14.0",
"shiki": "^1.29.1",
"tailwindcss": "^4.0.0",
"typescript": "^5.7.3",
"@types/node": "^20.11.5",
"@types/react": "^18.2.48",
"@types/react-dom": "^18.2.18",
"next": "^14.1.0",
"next-themes": "^0.4.4",
"postcss": "^8.5.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rehype-pretty-code": "^0.14.0",
"shiki": "^1.29.1",
"tailwindcss": "^3.4.1",
"typescript": "^5.7.3",

Comment on lines +1 to +5
@import 'tailwindcss';

@plugin '@tailwindcss/typography';

@custom-variant dark (&:is(.dark *));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Invalid Tailwind CSS syntax

The new syntax is incorrect and incompatible with Tailwind CSS:

  1. Tailwind CSS uses @tailwind directives, not @import
  2. Plugins are configured in tailwind.config.js, not via @plugin
  3. Custom variants are defined in tailwind.config.js, not via @custom-variant

Replace with standard Tailwind CSS syntax:

-@import 'tailwindcss';
-
-@plugin '@tailwindcss/typography';
-
-@custom-variant dark (&:is(.dark *));
+@tailwind base;
+@tailwind components;
+@tailwind utilities;

And move plugin & variant configuration to tailwind.config.js:

// tailwind.config.js
module.exports = {
  darkMode: 'class',
  plugins: [
    require('@tailwindcss/typography')
  ]
}


@layer base {
[data-rehype-pretty-code-figure] pre {
@apply px-0;
}

[data-rehype-pretty-code-figure] code {
@apply text-sm !leading-loose md:text-base;
@apply text-sm leading-loose! md:text-base;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix important modifier syntax

The ! modifier should be placed before the utility class, not after it.

-    @apply text-sm leading-loose! md:text-base;
+    @apply text-sm !leading-loose md:text-base;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@apply text-sm leading-loose! md:text-base;
@apply text-sm !leading-loose md:text-base;

@@ -48,14 +48,14 @@
"@rollup/plugin-node-resolve": "^16.0.0",
"@types/hast": "^3.0.4",
"@types/mdast": "^4.0.4",
"@types/node": "^22.10.2",
"@types/picomatch": "^3.0.1",
"@types/node": "^22.10.8",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix invalid @types/node version

The specified version ^22.10.8 is invalid as Node.js 22 hasn't been released yet. The latest LTS version of Node.js is 20.x.

-    "@types/node": "^22.10.8",
+    "@types/node": "^20.11.5",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"@types/node": "^22.10.8",
"@types/node": "^20.11.5",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant