-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
customElement register error #4470
Comments
maybe we could add conditional when register if (!customElements.get(overlayId)) {
customElements.define(overlayId, ErrorOverlay);
} |
I create a discussions a few days ago: #3911... wish this issue can change something... |
This sounds good. Would you like to create a PR @agileago? We should check if this is enough, and all the micro frontends are able to use the first registered one, but it seems that it will be fine to me |
I think you are fixing wrong issue here. You are loading |
@patak-js someone has done. please check it. thanks @webfansplz |
We should first resolve the comment from @sionzee to justify the need for this check |
@agileago I have got an email with your removed message. It is a good practice to strikethrough the text rather than removing it completely. Anyway, we are on the same side. We too uses two vite applications but the vite client is being injected by the code during import. Unfortunately nothing which could be somehow prevented without touching vite source code. Using the workaround mentioned in the example above could run into next issues for e.g.: triggering hot updates twice, and soo on. That's because all vite handling will be there twice and more times if using more applications. |
@patak-js in my opinion Vite shouldn't inject the client whatever is happening. Developer is responsible for adding the client import to the page. I believe by removing the auto injection it will resolve this and other similar issues. The docs also doesn't mention the auto injection so it behaves as a bug. If it must stay there due compatibility then adding an option to turn it off will be really welcomed. |
Vite shouldn't be auto injecting in this case, but maybe there is an issue with the setup of the OP |
Hello @agileago. Please provide a minimal reproduction using a GitHub repository or codesandbox. Issues marked with |
@patak-js Sounds like tree-shaking is not working here: This line is served to browser and it tries to import client.mjs where the: const overlayId = 'vite-error-overlay';
customElements.define(overlayId, ErrorOverlay); is being called. In my scenario the client.mjs is included by .vue file (will update soon with more details)
import { createHotContext as __vite__createHotContext } from "/editor/esm/@vite/client";import.meta.hot = __vite__createHotContext("/src/vue/EditorView.vue") That is another link to @vite/client. I have tried to remove both references for the @vite/client and the error is not happening anymore. |
@patak-js https://github.com/agileago/vite-mfe |
Describe the bug
when i mixin multiple vite project in one vite project(micro frontend). customElements overlay register will reregister and error
Reproduction
https://github.com/agileago/vite-mfe
vite/packages/vite/src/client/overlay.ts
Lines 184 to 185 in 3df736b
System Info
Used Package Manager
yarn
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: