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

Backend Integration multiple child component hmr failed (PHP) #9700

Closed
7 tasks done
SouthLink opened this issue Aug 16, 2022 · 5 comments
Closed
7 tasks done

Backend Integration multiple child component hmr failed (PHP) #9700

SouthLink opened this issue Aug 16, 2022 · 5 comments

Comments

@SouthLink
Copy link

SouthLink commented Aug 16, 2022

Describe the bug

The hmr failure was encountered in the back-end(PHP) integrated multi-page mode.
everything worked fine when a single component was introduced

The latest update..

Details please refer to the smallest copy, when I use to start the project with http://localhost:3009/dist/index.html access, HMR is normal,By introducing father http://localhost:3009/dist/index.php PHP file parent components can do normal HMR, child components HMR fails

I think it's because PHP files don't support refreshing

Because my current project is very old, PHP version 5.6, and does not use the Laravel framework

What should I do to use hot update mode normally

Reproduction

minimal reproducible example

System Info

System:
    OS: Windows 10 10.0.18363
    CPU: (6) x64 Intel(R) Core(TM) i5-8500 CPU @ 3.00GHz
    Memory: 3.76 GB / 15.80 GB
  Binaries:
    Node: 16.5.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.18 - C:\Program Files\nodejs\yarn.CMD
    npm: 7.19.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 102.0.5005.115
    Edge: Spartan (44.18362.1533.0)
    Internet Explorer: 11.0.18362.1
  npmPackages:
    @vitejs/plugin-basic-ssl: ^0.1.1 => 0.1.1
    @vitejs/plugin-react: ^2.0.1 => 2.0.1
    vite: ^3.0.6 => 3.0.6

Used Package Manager

npm

Logs

No response

Validations

@github-actions
Copy link

Hello @SouthLink. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.

@SouthLink SouthLink changed the title Backend Integration multiple child component hmr failed Backend Integration multiple child component hmr failed (PHP) Aug 17, 2022
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 22, 2022
@Niputi Niputi reopened this Aug 22, 2022
@SouthLink
Copy link
Author

I update a Vite plugin to solve this problem
vite-plugin-backend-hmr

@sapphi-red
Copy link
Member

That is one of the intended ways to make HMR work with backend integration.
Vite does not/cannot know which files are used so a plugin is needed to handle by Vite.

@SouthLink
Copy link
Author

这是使 HMR 与后端集成一起工作的预期方法之一。 Vite 不知道/不能知道使用了哪些文件,因此 Vite 需要一个插件来处理。

I found that HMR in the HTML file is success, but HMR in the PHP file fails.
After searching, I found that in the deep level introduction, vite hmr only updates the current file and does not update to the top parent component, so the hot update fails.
So I used the module importers the file to find the top-level component update.
Isthat right please?

@sapphi-red
Copy link
Member

Ah, I understand what you were saying about.

This was because you were importing http://localhost:3009/@react-refresh in index.php.

import RefreshRuntime from 'http://localhost:3009/@react-refresh'

This should be importing http://localhost:3009/dist/@react-refresh. (index.html has this, so it's working.)

Related issue: #5656

@github-actions github-actions bot locked and limited conversation to collaborators Sep 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants