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

Turbo #170

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Turbo #170

wants to merge 5 commits into from

Conversation

haydenbleasel
Copy link
Owner

@haydenbleasel haydenbleasel commented Nov 3, 2024

This pull request includes updates to the dev scripts in various package.json files to enable Turbopack for faster development builds.

Changes to dev scripts:

Summary by CodeRabbit

  • New Features

    • Introduced a new RootLayout component for improved layout management.
    • Enhanced module resolution with new path mappings in TypeScript configuration.
  • Improvements

    • Updated development scripts across applications to include the --turbopack flag for better performance.
    • Added several new dependencies across applications to expand functionality, including image processing and module handling capabilities.
  • Bug Fixes

    • No specific bug fixes were noted in this release.

@haydenbleasel haydenbleasel added the patch Increment the patch version when merged label Nov 3, 2024
@haydenbleasel haydenbleasel self-assigned this Nov 3, 2024
Copy link

vercel bot commented Nov 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-forge ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 13, 2024 8:39am

@haydenbleasel
Copy link
Owner Author

api - looks like root layouts are mandatory with turbopack even if there's no pages.

CleanShot 2024-11-05 at 17 20 05@2x

@haydenbleasel
Copy link
Owner Author

haydenbleasel commented Nov 5, 2024

app is throwing a bunch of external-related errors

app:dev:  ✓ Compiled / in 7.3s
app:dev:  ⚠ ./node_modules/.pnpm/@[email protected][email protected]/node_modules/.prisma/client
app:dev: Package @prisma/client can't be external
app:dev: The request @prisma/client/runtime/library.js matches serverExternalPackages (or the default list).
app:dev: The request could not be resolved by Node.js from the project directory.
app:dev: Packages that should be external need to be installed in the project directory, so they can be resolved from the output files.
app:dev: Try to install it into the project directory by running npm install @prisma/client from the project directory.
app:dev:
app:dev:
app:dev:  ⚠ ./packages/database
app:dev: Package @prisma/client can't be external
app:dev: The request @prisma/client matches serverExternalPackages (or the default list).
app:dev: The request could not be resolved by Node.js from the project directory.
app:dev: Packages that should be external need to be installed in the project directory, so they can be resolved from the output files.
app:dev: Try to install it into the project directory by running npm install @prisma/client from the project directory.
app:dev:
app:dev:
app:dev:  ⚠ ./node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@opentelemetry/instrumentation/build/esm/platform/node
app:dev: Package import-in-the-middle can't be external
app:dev: The request import-in-the-middle matches serverExternalPackages (or the default list).
app:dev: The request could not be resolved by Node.js from the project directory.
app:dev: Packages that should be external need to be installed in the project directory, so they can be resolved from the output files.
app:dev: Try to install it into the project directory by running npm install import-in-the-middle from the project directory.
app:dev:
app:dev:
app:dev:  ⚠ ./node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@opentelemetry/instrumentation/build/esm/platform/node
app:dev: Package import-in-the-middle can't be external
app:dev: The request import-in-the-middle matches serverExternalPackages (or the default list).
app:dev: The request could not be resolved by Node.js from the project directory.
app:dev: Packages that should be external need to be installed in the project directory, so they can be resolved from the output files.
app:dev: Try to install it into the project directory by running npm install import-in-the-middle from the project directory.
app:dev:
app:dev:
app:dev:  ⚠ ./node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@opentelemetry/instrumentation/build/esm/platform/node
app:dev: Package import-in-the-middle can't be external
app:dev: The request import-in-the-middle matches serverExternalPackages (or the default list).
app:dev: The request could not be resolved by Node.js from the project directory.
app:dev: Packages that should be external need to be installed in the project directory, so they can be resolved from the output files.
app:dev: Try to install it into the project directory by running npm install import-in-the-middle from the project directory.
app:dev:

@haydenbleasel
Copy link
Owner Author

web is doing the same, but also complaining about content-collections:

web:dev:  ✓ Compiled / in 9.5s
web:dev:  ⨯ ./node_modules/.pnpm/@[email protected]/node_modules/@esbuild/darwin-arm64/README.md
web:dev: Unknown module type
web:dev: This module doesn't have an associated type. Use a known file extension, or register a loader for it.
web:dev:
web:dev: Read more: https://nextjs.org/docs/app/api-reference/next-config-js/turbo#webpack-loaders
web:dev:
web:dev:
web:dev:
web:dev: ./node_modules/.pnpm/@[email protected]/node_modules/@esbuild/darwin-arm64/bin/esbuild
web:dev: Reading source code for parsing failed
web:dev: An unexpected error happened while trying to read the source code to parse: failed to convert rope into string
web:dev:
web:dev: Caused by:
web:dev: - invalid utf-8 sequence of 1 bytes from index 0
web:dev:
web:dev:
web:dev:
web:dev: ./apps/web/app/(home)/components/hero.tsx:3:1
web:dev: Export allPosts doesn't exist in target module
web:dev:   1 | import { Button } from '@repo/design-system/components/ui/button';
web:dev:   2 | import { env } from '@repo/env';
web:dev: > 3 | import { allPosts } from 'content-collections';
web:dev:     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
web:dev:   4 | import { MoveRight, PhoneCall } from 'lucide-react';
web:dev:   5 | import Link from 'next/link';
web:dev:   6 |
web:dev:
web:dev: The export allPosts was not found in module [project]/apps/web/content-collections.ts [app-rsc] (ecmascript).
web:dev: Did you mean to import default?
web:dev: All exports of the module are statically known (It doesn't have dynamic exports). So it's known statically that the requested export doesn't exist.
web:dev:
web:dev:
web:dev:  ⚠ ./node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@opentelemetry/instrumentation/build/esm/platform/node
web:dev: Package import-in-the-middle can't be external
web:dev: The request import-in-the-middle matches serverExternalPackages (or the default list).
web:dev: The request could not be resolved by Node.js from the project directory.
web:dev: Packages that should be external need to be installed in the project directory, so they can be resolved from the output files.
web:dev: Try to install it into the project directory by running npm install import-in-the-middle from the project directory.

@timneutkens
Copy link

api - looks like root layouts are mandatory with turbopack even if there's no pages.

Root layout was always required, e.g. for the 404 page which you were requesting there. With Turbopack we can't auto-generate a root layout like it does when running webpack as mentioned in the documentation: https://nextjs.org/docs/architecture/turbopack#unsupported-features

@timneutkens
Copy link

but also complaining about content-collections:

This error looks correct, looking at the content-collections.ts file it only has a default export export default defineConfig({ and no allPosts

@timneutkens
Copy link

Package <packagename> can't be external are warnings, not errors, that are highlighting cases where packages are being used but are not installed so it can fail when running in production. This was already an issue when you were using webpack, it just never warned you that it was missing. This can be fixed by installing the external packages into the project itself.

@timneutkens
Copy link

web:dev:  ⨯ ./node_modules/.pnpm/@[email protected]/node_modules/@esbuild/darwin-arm64/README.md
web:dev: Unknown module type
web:dev: This module doesn't have an associated type. Use a known file extension, or register a loader for it.
web:dev:
web:dev: Read more: https://nextjs.org/docs/app/api-reference/next-config-js/turbo#webpack-loaders
web:dev:
web:dev:
web:dev:
web:dev: ./node_modules/.pnpm/@[email protected]/node_modules/@esbuild/darwin-arm64/bin/esbuild
web:dev: Reading source code for parsing failed
web:dev: An unexpected error happened while trying to read the source code to parse: failed to convert rope into string
web:dev:
web:dev: Caused by:
web:dev: - invalid utf-8 sequence of 1 bytes from index 0

This seems to be caused by importing esbuild somewhere, seems you're running a compiler on code at runtime, which means you're also running eval on untrusted code, sounds unexpected and a potential security vulnerability 🤔

Edit: Did some further digging, it's using mdx-bundler at runtime.

@timneutkens
Copy link

timneutkens commented Nov 6, 2024

Tried to reproduce it by running mdx-bundler but that works fine:

import { bundleMDX } from "mdx-bundler";

const mdxSource = `
---
title: Example Post
published: 2021-02-13
description: This is some description
---

# Wahoo

import Demo from './demo'

Here's a **neat** demo:

<Demo />
`.trim();

export default async function MdxBundler() {
  const result = await bundleMDX({
    source: mdxSource,
    files: {
      "./demo.tsx": `
  import * as React from 'react'
  
  function Demo() {
    return <div>Neat demo!</div>
  }
  
  export default Demo
      `,
    },
  });

  const { code, frontmatter } = result;

  return (
    <div>
      <h1>My MDX Blog</h1>
      <pre>{JSON.stringify(frontmatter, null, " ")}</pre>
      <pre>{code}</pre>
    </div>
  );
}

Only way I can reproduce the error is adding "use client" which causes mdx-bundler to be bundled for the browser and it'll fail on that given that it's not a dependency that works in the browser, so that failure is expected:

CleanShot 2024-11-06 at 11 47 00@2x

@haydenbleasel
Copy link
Owner Author

Hey @timneutkens, thanks for taking a look!

  1. I've added a root layout, thanks for the link.
  2. content-collections refers to the alias, not the file. It's working in webpack.
  3. I'll look into installing the external deps, thanks for the info.

@timneutkens
Copy link

Wrt 2. I'll take a look at reproducing the alias not applying, might be related to the extends or that a file called content-collections.ts exists in the root of the project.

Copy link

coderabbitai bot commented Nov 13, 2024

📝 Walkthrough

Walkthrough

The changes introduced in this pull request include the addition of a new React component named RootLayout in layout.tsx, which provides a basic structure for rendering children components. Additionally, the package.json files for the api, app, and web applications have been updated to include the --turbopack flag in their respective development scripts. New dependencies have also been added to the app and web applications, while the tsconfig.json for the web application has been modified to include new path mappings for improved module resolution.

Changes

File Path Change Summary
apps/api/app/layout.tsx Added new component RootLayout which accepts a children prop and renders basic HTML structure.
apps/api/package.json Modified next script to include --turbopack flag.
apps/app/package.json Updated dev script to include --turbopack flag; added dependencies: @prisma/client, import-in-the-middle, require-in-the-middle.
apps/web/package.json Updated dev script to include --turbopack flag; added dependencies: import-in-the-middle, mdx-bundler, require-in-the-middle, sharp, shiki.
apps/web/tsconfig.json Added new paths configuration for module resolution: @/*, @repo/*, content-collections.

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 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.

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.

haydenbleasel and others added 2 commits November 13, 2024 03:33
Co-Authored-By: Tim Neutkens <[email protected]>
@haydenbleasel
Copy link
Owner Author

@timneutkens All seems to be working now with your recommendations. Feels a bit weird adding dependencies that I'm not directly importing or using + will make it hard to figure out which dependencies are actually needed (can't use depcheck anymore) - is there any other way to deal with this issue?

@haydenbleasel haydenbleasel added minor Increment the minor version when merged and removed patch Increment the patch version when merged labels Nov 13, 2024
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: 2

🧹 Outside diff range and nitpick comments (4)
apps/api/app/layout.tsx (1)

1-1: Consider adding Metadata types for SEO optimization.

Since this is a Next.js root layout, consider importing and implementing metadata types for SEO:

-import type { ReactNode } from 'react';
+import type { ReactNode } from 'react';
+import type { Metadata } from 'next';
apps/web/tsconfig.json (1)

8-8: Consider using a more specific path alias for content-collections

Given the reported issues with content-collections exports in the PR comments, consider using a more specific alias like @content/* to better indicate its scope and prevent potential naming conflicts.

-      "content-collections": ["./.content-collections/generated"]
+      "@content/*": ["./.content-collections/generated/*"]
apps/api/package.json (1)

6-6: Consider adding a fallback mechanism

Given that Turbopack is still in beta and previous discussions highlighted some issues, consider adding a fallback mechanism:

 {
   "scripts": {
     "dev": "concurrently \"pnpm:next\" \"pnpm:stripe\"",
-    "next": "next dev -p 3002 --turbopack",
+    "next": "next dev -p 3002 --turbopack",
+    "next:stable": "next dev -p 3002",
     ...
   }
 }

This allows developers to fall back to the stable webpack-based development server if they encounter issues with Turbopack.

apps/web/package.json (1)

30-30: Review unrelated dependency additions

The following dependencies seem unrelated to the Turbopack implementation:

  • mdx-bundler: MDX compilation
  • sharp: Image processing
  • shiki: Syntax highlighting

While these might be needed for other features, consider:

  1. Creating separate PRs for unrelated changes to maintain clear change history
  2. Using exact versions (0.33.5 instead of ^0.33.5) for better dependency predictability
  3. Documenting the purpose of these additions in the PR description

Also applies to: 37-38

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d6c7661 and 7af3026.

⛔ Files ignored due to path filters (3)
  • packages/typescript-config/nextjs.json is excluded by none and included by none
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml and included by none
  • splash/package.json is excluded by none and included by none
📒 Files selected for processing (5)
  • apps/api/app/layout.tsx (1 hunks)
  • apps/api/package.json (1 hunks)
  • apps/app/package.json (3 hunks)
  • apps/web/package.json (2 hunks)
  • apps/web/tsconfig.json (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
apps/api/app/layout.tsx (1)

Pattern **/*.tsx: Follow React best practices. Ensure proper component typing and use of React.FC for functional components.

🔇 Additional comments (9)
apps/api/app/layout.tsx (3)

3-5: LGTM! Type definition follows best practices.

The type definition is well-structured with proper immutability and typing.


13-13: LGTM! Export follows Next.js conventions.

The default export is correct for Next.js app router layout files.


1-13: Verify Turbopack compatibility.

The root layout implementation satisfies Turbopack requirements. Let's verify there are no conflicting layouts in the API app directory.

✅ Verification successful

No conflicting layouts found in the API app directory

The verification confirms that apps/api/app/layout.tsx is the only layout file present in the API app directory, which is the correct implementation for Turbopack compatibility.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any conflicting layout files in the API app directory
# that might cause issues with Turbopack.

echo "Checking for conflicting layout files..."
fd --type f "layout\.(tsx|jsx|js|ts)$" apps/api/app

Length of output: 168

apps/web/tsconfig.json (1)

4-9: Verify path mappings align with project structure

The path mappings look reasonable, but let's verify the directory structure to ensure they're correctly configured.

✅ Verification successful

Path mappings are correctly configured and actively used

The verification confirms that:

  1. The @repo/* mapping to ../../packages/* is valid and extensively used across the codebase, with imports from all the listed package directories.
  2. The content-collections mapping is actively used in multiple files and has proper dependencies installed (@content-collections/* packages in package.json).
  3. The path mappings align with the monorepo structure and support the Turbopack migration objective.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of directories referenced in path mappings

# Check if packages directory exists and contains files
echo "Checking packages directory..."
if [ -d "packages" ]; then
    fd . packages -t d -d 1
fi

# Check if .content-collections/generated exists
echo "Checking content collections directory..."
if [ -d ".content-collections/generated" ]; then
    ls -la .content-collections/generated
fi

# Look for any existing imports using these path aliases
echo "Checking usage of path aliases..."
rg -t ts -t tsx "from ['\"]@repo/" .
rg -t ts -t tsx "from ['\"]content-collections['\"]" .

Length of output: 774


Script:

#!/bin/bash
# Let's try a different approach to check imports using ripgrep without file type filters
echo "Checking @repo imports..."
rg "from ['\"]@repo/" .

echo -e "\nChecking content-collections imports..."
rg "from ['\"]content-collections['\"]" .

echo -e "\nChecking if .content-collections exists in any form..."
fd -H "content-collections" .

echo -e "\nChecking package.json for related configurations..."
fd "package.json" apps/web -x cat {}

Length of output: 20972

apps/api/package.json (1)

6-6: Verify Turbopack compatibility with workspace dependencies

While enabling Turbopack can improve development speed, there are some considerations to verify:

  1. Ensure all workspace dependencies (@repo/*) are compatible with Turbopack
  2. Confirm that a root layout exists as it's mandatory with Turbopack
  3. Check for any external dependency issues, particularly with @clerk/nextjs and svix
✅ Verification successful

Turbopack setup appears compatible with current configuration

The verification shows that the necessary components are in place:

  • Root layout is properly implemented with the required HTML structure
  • Next.js configuration is clean and uses shared workspace config
  • Workspace dependencies are properly configured with workspace:* protocol

The setup appears ready for Turbopack usage, with no apparent compatibility issues in the configuration or dependencies. The shared config approach through @repo/next-config suggests consistent configuration across apps, which is ideal for Turbopack adoption.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify root layout existence and potential compatibility issues

# Check for root layout file
echo "Checking for root layout..."
fd "layout" "apps/api/app"

# Check for potential compatibility issues in Next.js config
echo "Checking Next.js configuration..."
fd "next.config" "apps/api"

# Look for any experimental flags or special handling
echo "Checking for experimental configurations..."
rg -l "experimental" "apps/api"

Length of output: 367


Script:

#!/bin/bash
# Let's examine the root layout and next.config content

# Check root layout content
echo "=== Root Layout Content ==="
cat "apps/api/app/layout.tsx"

# Check Next.js config content
echo -e "\n=== Next.js Config Content ==="
cat "apps/api/next.config.ts"

# Check for workspace dependencies
echo -e "\n=== Workspace Dependencies ==="
rg "@repo/" "apps/api/package.json"

Length of output: 1232

apps/app/package.json (2)

14-14: LGTM: Prisma client addition

Adding @prisma/client as a direct dependency is correct, as mentioned in the PR discussion about external dependency issues.


25-25: Clarify the need for module interception packages

The addition of import-in-the-middle and require-in-the-middle raises some concerns:

  1. These packages are typically used for module interception and instrumentation, which could have security implications if not used carefully
  2. Using caret ranges (^) could lead to unexpected updates in minor versions

Consider:

  • Documenting why these packages are necessary
  • Using fixed versions instead of caret ranges
  • Adding security measures if these are used for runtime module modification
#!/bin/bash
# Check for any security advisories for these packages
echo "Checking for security advisories..."

gh api graphql -f query='
{
  securityVulnerabilities(first: 5, ecosystem: NPM, package: "import-in-the-middle") {
    nodes {
      advisory {
        summary
        severity
        publishedAt
      }
      vulnerableVersionRange
    }
  }
}
'

gh api graphql -f query='
{
  securityVulnerabilities(first: 5, ecosystem: NPM, package: "require-in-the-middle") {
    nodes {
      advisory {
        summary
        severity
        publishedAt
      }
      vulnerableVersionRange
    }
  }
}
'

Also applies to: 31-31

apps/web/package.json (2)

28-28: Clarify the need for module interception libraries

The addition of import-in-the-middle and require-in-the-middle appears to be related to the external dependency issues discussed in the PR. However, these are typically used for module interception and debugging, which raises some concerns:

  1. These packages are usually development dependencies rather than runtime dependencies
  2. They might impact the production bundle size
  3. They could introduce security risks if not properly configured

Consider:

  • Moving these to devDependencies if they're only needed during development
  • Documenting why these packages are necessary
  • Exploring alternative solutions for handling external dependencies

Let's check if these packages are actually used in the codebase:

#!/bin/bash
# Check usage of module interception packages

echo "Checking usage of import-in-the-middle and require-in-the-middle..."
rg "import.*['\"]import-in-the-middle['\"]|import.*['\"]require-in-the-middle['\"]" "apps/web/src"

Also applies to: 36-36


5-5: Verify Turbopack compatibility with the current setup

The addition of --turbopack aligns with the goal of improving development build speeds. However, based on the PR discussion, please ensure:

  1. Root layouts are properly implemented across all pages
  2. All required dependencies are installed locally to avoid external dependency warnings
  3. Module exports and types are compatible with Turbopack's requirements

Let's verify the presence of root layouts and potential compatibility issues:

✅ Verification successful

Turbopack setup appears compatible with the current project structure

The verification shows:

  1. Root layout is properly implemented at apps/web/app/layout.tsx
  2. Project follows Next.js App Router structure with appropriate directory organization
  3. All required dependencies are present in package.json, including necessary workspace packages

The addition of --turbopack flag is safe to proceed with, as the basic requirements for Turbopack compatibility are met.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for root layouts and potential compatibility issues

# Verify root layouts exist
echo "Checking for root layouts..."
fd "layout.tsx" "apps/web"

# Check for potential compatibility issues in import statements
echo "Checking for potential compatibility issues..."
rg "from ['\"]@" "apps/web/src" --type ts --type tsx

Length of output: 552


Script:

#!/bin/bash
# Let's verify the directory structure and root layout first
echo "Checking directory structure..."
fd . apps/web -t d

echo -e "\nChecking for layout files..."
fd layout "apps/web" -e tsx -e ts -e js -e jsx

echo -e "\nChecking package.json for dependencies..."
cat apps/web/package.json

echo -e "\nChecking for imports from workspace packages..."
rg "from ['\"]@" apps/web --type typescript

Length of output: 2682

Comment on lines +7 to +11
const RootLayout = ({ children }: RootLayoutProperties) => (
<html lang="en">
<body>{children}</body>
</html>
);
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance the layout component with Next.js best practices.

The component should be enhanced with:

  1. React.FC type annotation (per coding guidelines)
  2. Metadata implementation
  3. Required head and viewport meta tags
-const RootLayout = ({ children }: RootLayoutProperties) => (
+export const metadata: Metadata = {
+  title: 'API',
+  description: 'API documentation'
+};
+
+const RootLayout: React.FC<RootLayoutProperties> = ({ children }) => (
   <html lang="en">
+    <head>
+      <meta name="viewport" content="width=device-width, initial-scale=1" />
+    </head>
     <body>{children}</body>
   </html>
 );

Committable suggestion skipped: line range outside the PR's diff.

@@ -2,7 +2,7 @@
"name": "app",
"private": true,
"scripts": {
"dev": "next dev -p 3000",
"dev": "next dev -p 3000 --turbopack",
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Turbopack is compatible but requires security updates

The Next.js version 15.0.3 fully supports Turbopack, however there are two important points to address:

  • The import-in-the-middle dependency has a HIGH severity security vulnerability (versions <= 1.4.1). Please update to the latest version.
  • Consider explicitly enabling Turbopack in next.config.js instead of using the CLI flag for better maintainability.
🔗 Analysis chain

Verify Turbopack compatibility with Next.js version

While enabling Turbopack can improve development speed, please note that it's still in beta and has some limitations. Ensure all team members are aware of:

  1. Potential compatibility issues with certain Next.js features
  2. The requirement for root layouts as mentioned in the PR discussion

Let me gather more information about the Next.js version and Turbopack configuration.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the Next.js version supports Turbopack
# and if there are any known issues

# Get the Next.js version from package.json
NEXT_VERSION=$(cat apps/app/package.json | jq -r '.dependencies.next')

# Check Next.js docs for Turbopack compatibility
echo "Checking Next.js $NEXT_VERSION for Turbopack compatibility..."
curl -s "https://nextjs.org/docs/app/api-reference/next-config-js/turbopack"

# Look for any Turbopack-related issues in the codebase
echo "Checking for potential Turbopack configuration issues..."
fd --type f --extension js,ts,tsx . apps/ --exec grep -l "use client"

Length of output: 877


Script:

#!/bin/bash
# Check Next.js version and Turbopack configuration
echo "Next.js version:"
cat apps/app/package.json | jq '.dependencies.next'

# Check for Turbopack configuration in next.config.js
echo -e "\nTurbopack configuration:"
fd next.config.js apps/ --exec cat {}

# Check for any experimental features
echo -e "\nChecking for experimental features:"
fd next.config.js apps/ --exec grep -A 5 "experimental"

Length of output: 353

@TheCukitoDev
Copy link

@haydenbleasel I had that error when using the Sentry SDK with turbopack in the new Next 15. It first ask me for the import-in-the-middle when using react 19 RC but when i used the react 18 it asked me for the require-in-the-middle package. You can check the full conversation in getsentry/sentry-javascript#8105

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Increment the minor version when merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants