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

use import.meta.hot in a vitepress plugin #10486

Closed
7 tasks done
emersonbottero opened this issue Oct 16, 2022 · 11 comments · Fixed by #12184
Closed
7 tasks done

use import.meta.hot in a vitepress plugin #10486

emersonbottero opened this issue Oct 16, 2022 · 11 comments · Fixed by #12184
Labels

Comments

@emersonbottero
Copy link

Describe the bug

Trying to implement client server communication in a vite-plugin I'm receiving Property 'hot' does not exist on type 'ImportMeta' just like in #416.

Try to import vite/hmr but it is not exported
but importing vite/client fix it (at least volar and build stop complaining...)

but when I run client I got an error in the import line

https://github.com/emersonbottero/vitepress-plugin-search/blob/flexsearch/src/Search.vue#L4

GET http://localhost:5173/@fs/C:/Users/emers/Source/Repos/vitepress-plugin-search/dist/Search.vue net::ERR_ABORTED 500 (Internal Server Error)

P.S.:
I'm trying to improve the vitepress-plugin-search so it is easy to provide options to the builder and search.
in the current version is hard to add languages for example

Reproduction

press . on my repository within the browser 😁

Steps to reproduce

pnpm i
pnpm build
cd demo
pnpm i
pnpm dev

System Info

System:
    OS: Windows 10 10.0.22621
    CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
    Memory: 6.20 GB / 15.92 GB
  Binaries:    Node: 16.18.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.5 - ~\AppData\Roaming\npm\yarn.CMD    npm: 8.1.3 - ~\AppData\Roaming\npm\npm.CMD
  Browsers:
    Chrome: 106.0.5249.119
    Edge: Spartan (44.22621.746.0), Chromium (106.0.1370.42)
    Internet Explorer: 11.0.22621.1

Used Package Manager

pnpm

Logs

No response

Validations

@emersonbottero
Copy link
Author

I make it work with
import type from "vite/client";
and took a wile to discover

this should be updated in the docs

@bluwy
Copy link
Member

bluwy commented Nov 23, 2022

import.meta.hot intellisense should be set similar to https://vitejs.dev/guide/env-and-mode.html#intellisense-for-typescript. Feel free to update the docs with that info though.

@bluwy bluwy added contribution welcome needs documentation Documentations are needed and removed pending triage labels Nov 23, 2022
@github-actions
Copy link

Hello @emersonbottero. We like your proposal/feedback and would appreciate a contribution via a Pull Request by you or another community member. We thank you in advance for your contribution and are looking forward to reviewing it!

@pratik-codes
Copy link

is anyone working on this ? @emersonbottero @bluwy

@bluwy
Copy link
Member

bluwy commented Dec 24, 2022

I don't think so. Feel free to take it!

@pratik-codes
Copy link

@bluwy @emersonbottero

Can you guide me on which exact snippet should i update with this import?
A little more context would help me

import type from "vite/client";

@emersonbottero
Copy link
Author

I should have created a branch and keep that state there.

while trying to communicate between server and client and when I tried to use https://vitejs.dev/guide/api-plugin.html#client-to-server I needed to add
import type from "vite/client";

so the build stop complaining..
but I didn't implemented , couldn't make it work, my intent was to pass data to the server, the server computed the values and sent it back to the client...

and I would use Client-server Communication and Server-Client communication for that.

@pratik-codes
Copy link

@emersonbottero in that case it isnt the solution its just a hack if i am not wrong?

@emersonbottero
Copy link
Author

I think we still need better documentation for
The need of import type from "vite/client" in ts files and preferebly an working example of using client/server server/client communication

@bluwy
Copy link
Member

bluwy commented Feb 6, 2023

Shouldn't this fix the issue? I was suggesting to add a similar info of that to the plugin API docs too.

@emersonbottero
Copy link
Author

Yes.

But I tried to replicate the messages using the examples in the docs and it didn't worked.

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

Successfully merging a pull request may close this issue.

3 participants