withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
44.34k stars 2.31k forks source link

If the -- open flag is used, any modifications to the packagist.json file will reopen the browser at this time #11374

Closed ajiho closed 3 days ago

ajiho commented 2 weeks ago

Astro Info

unnecessary

If this issue only occurs in one browser, which browser is a problem?

chrome

Describe the Bug

If the -- open flag is used in the development script, every time the package.json file browser is modified, it will open a new tab script:

"dev": "astro --config src/config/astro.config.mjs dev --open",

Here is a more detailed video demonstration:

https://github.com/withastro/astro/assets/107699138/5d8aa80e-4d94-4679-9aae-d38f32319941

Warehouse for reproducing examples: https://github.com/ajiho/astro-build-boilerplate

What's the expected result?

The correct behavior should be to modify package.json, which should not have any response,I don't know if it's an issue with Astro or Vite regarding the occurrence of this behavior,If there are no issues with both, please tell me what to do? I have ensured that my vscdoe editor does not have any extensions that may affect it, image

Link to Minimal Reproducible Example

https://github.com/ajiho/astro-build-boilerplate

Participation

florian-lefebvre commented 1 week ago

I think that's because we do a full restart of the vite dev server each time a config file changes, so we tell vite to open a browser tab each time. @bluwy what do you think we should do?

ajiho commented 1 week ago

@florian-lefebvre I have also provided feedback on this issue in vitepress based on vite, and they also have this issue, but they have already resolved it,issues/4001 I think you can refer to how it was resolved

florian-lefebvre commented 1 week ago

Thanks, the exact commit is https://github.com/vuejs/vitepress/commit/d837e82bc8bde63df737be2a1290a2e70c8a0bf3

florian-lefebvre commented 1 week ago

We probably need to tweak this condition https://github.com/withastro/astro/blob/main/packages/astro/src/core/dev/container.ts#L61

ajiho commented 1 week ago

Sorry, I can't be of much help. I just want to humbly ask the Astro team if this issue is difficult to handle? I'm just troubled by opening a new tab every time I modify packagejson.

florian-lefebvre commented 1 week ago

Good first issue!

This is an opportunity for astro users to learn about how astro works by fixing a small but real bug. You can expect to get help setting up the dev environment, and understanding the project structure in #contribute channel of our discord server (https://astro.build/chat).

What's the bug?

When using astro dev --open, updating a config file reopens a new tab.

What's going wrong here?

When a config file changes, a full restart happens and the Vite dev server is recreated. That means a new tab will reopen each time.

Where do I start looking?

This condition needs to be updated. You'll need to use the isRestart parameter and test manually

RickyC0626 commented 1 week ago

I can take a look