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

Having a folder named ".env" in the root of a project will cause a full reload when any component in the app directory is opened and saved #65229

Open
MichaelCharles opened this issue May 1, 2024 · 0 comments
Labels
bug Issue was opened via the bug report template.

Comments

@MichaelCharles
Copy link

Link to the code that reproduces this issue

https://github.com/michaelcharles/nextjs-reload-bug

To Reproduce

  1. Create a new nextjs project using pages router
  2. Add a folder named .env
  3. Add a folder named app
  4. Add a component to app, say a Foobar.tsx that just loads a div
  5. Add a .vscode/launch.json file, and run the debugger
  6. Open Foobar.tsx and save.

After saving a full reload will be performed.

Current vs. Expected behavior

Currently, if you take the steps listed to reproduce and save Foobar, even if the component is not loaded anywhere on the page, a full reload will occur refreshing the page in the browser.

I expect a fast refresh, a refresh that will not reload the page. Especially since this occurs even if the Foobar component is not explicitly used anywhere on the page.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.4.0: Fri Mar 15 00:10:42 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 18.19.0
  npm: 10.2.3
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.2.3 // Latest available version is detected (14.2.3).
  eslint-config-next: 14.2.3
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.4.5
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not sure

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

This occurred because we were storing example .env files in the .env folder. I simply have changed to saving example .env files as example.env.local and the problem has disappeared. So this isn't exactly a high priority, but it is an odd bug.

@MichaelCharles MichaelCharles added the bug Issue was opened via the bug report template. label May 1, 2024
@MichaelCharles MichaelCharles changed the title Having a folder named ".env" in the root of a project will cause a full reload when any component in the app directory Having a folder named ".env" in the root of a project will cause a full reload when any component in the app directory is edited May 1, 2024
@MichaelCharles MichaelCharles changed the title Having a folder named ".env" in the root of a project will cause a full reload when any component in the app directory is edited Having a folder named ".env" in the root of a project will cause a full reload when any component in the app directory is opened and saved May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

1 participant