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

Fix dev warnings #342

Merged
merged 5 commits into from
Jan 30, 2025
Merged

Fix dev warnings #342

merged 5 commits into from
Jan 30, 2025

Conversation

satococoa
Copy link
Contributor

Summary

This pull request fixes these problems in development.

tailwind warning

warn - Your `content` configuration includes a pattern which looks like it's accidentally matching all of `node_modules` and can cause serious performance issues.
warn - Pattern: `./packages/**/*.ts`
warn - See our documentation for recommendations:
warn - https://tailwindcss.com/docs/content-configuration#pattern-recommendations

require-in-the-middle can't be external

⚠ ./node_modules/.pnpm/https://github.com/[email protected]_@[email protected]/node_modules/@opentelemetry/instrumentation/build/esm/platform/node
Package require-in-the-middle can't be external
The request require-in-the-middle matches serverExternalPackages (or the default list).
The request could not be resolved by Node.js from the project directory.
Packages that should be external need to be installed in the project directory, so they can be resolved from the output files.
Try to install it into the project directory by running npm install require-in-the-middle from the project directory.

This error occurs because Next.js (Turbopack) fails to resolve require-in-the-middle, a dependency of @opentelemetry/instrumentation, due to pnpm's strict node_modules structure.

public-hoist-pattern is a temporary workaround to hoist require-in-the-middle to the root node_modules, making it accessible to Turbopack.

This is a temporary fix for vercel/next.js#68805. We should monitor the issue for a permanent Turbopack fix and remove this workaround when resolved.

prepare-font.js is not download fonts even if FORCE_DOWNLOAD_FONTS=1

Previously, Bun automatically loads .env and .env.local, but Node.js (and thus pnpm scripts) requires explicit configuration.

`pnpm dev` shows this waning:

```
warn - Your `content` configuration includes a pattern which looks like it's accidentally matching all of `node_modules` and can cause serious performance issues.
warn - Pattern: `./packages/**/*.ts`
warn - See our documentation for recommendations:
warn - https://tailwindcss.com/docs/content-configuration#pattern-recommendations
```
This commit adds `public-hoist-pattern[] = require-in-the-middle` to .npmrc to resolve the build error:

```
⚠ ./node_modules/.pnpm/@opentelemetry[email protected]_@[email protected]/node_modules/@opentelemetry/instrumentation/build/esm/platform/node
Package require-in-the-middle can't be external
The request require-in-the-middle matches serverExternalPackages (or the default list).
The request could not be resolved by Node.js from the project directory.
Packages that should be external need to be installed in the project directory, so they can be resolved from the output files.
Try to install it into the project directory by running npm install require-in-the-middle from the project directory.
```

This error occurs because Next.js (Turbopack) fails to resolve `require-in-the-middle`, a dependency of `@opentelemetry/instrumentation`, due to pnpm's strict `node_modules` structure.

`public-hoist-pattern` is a temporary workaround to hoist `require-in-the-middle` to the root `node_modules`, making it accessible to Turbopack.

This is a temporary fix for [vercel/next.js#68805](vercel/next.js#68805).  We should monitor the issue for a permanent Turbopack fix and remove this workaround when resolved.
Copy link

vercel bot commented Jan 30, 2025

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

Name Status Preview Comments Updated (UTC)
giselle ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 30, 2025 2:45am

This commit updates `prepare-font.js` to use `@next/env` for loading environment variables.

Bun automatically loads `.env` and `.env.local`, but Node.js (and thus pnpm scripts) requires explicit configuration.

By switching to `@next/env`, we leverage Next.js's built-in environment variable loading mechanism, which correctly handles `.env`, `.env.local`, and environment-specific files. This ensures consistent environment variable loading across different environments and package managers.

This change resolves an issue introduced when migrating from Bun to pnpm, where environment variables were not being correctly loaded in `prepare-font.js`.
Copy link
Member

@shige shige left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@satococoa satococoa merged commit 86a6587 into main Jan 30, 2025
9 checks passed
@satococoa satococoa deleted the fix-dev-warnings branch January 30, 2025 08:13
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.

3 participants