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

Issues with vite dev server #23

Open
kvndrsslr opened this issue Mar 31, 2023 · 7 comments
Open

Issues with vite dev server #23

kvndrsslr opened this issue Mar 31, 2023 · 7 comments

Comments

@kvndrsslr
Copy link

So I tried to get this component to work for a couple hours now, finally realized that vite (in a fresh project initialized with pnpm create vite) dev server does in fact not play well with it.

Have not yet figured out what exactly is stopping it from working, but wanna leave this issue here in the meantime so others are aware.
If you're using vite, the awkward but possible workaround is to vite build --watch and vite preview, then this component will work as expected.

@FrancescoCoding
Copy link

Steps to replicate this fix:

Ensure you have these in your package.json scripts:
"build-watch": "tsc && npx vite build --watch",
"preview": "vite preview"

Ensure you have a key-value pair for the preview in your vite.config.ts:
export default defineConfig({ plugins: [react()], preview: { port: 8085,| }, });

Open terminal in your src folder and run npm run build-watch
Open another terminal in your src folder and run npm run preview

Now the project will be built on save, in my case, I have to reload the page as well after each build.

@TomYeoman
Copy link

I have this problem also

@kvndrsslr
Copy link
Author

@TomYeoman
I haven't had the time to dig into the reasons this doesn't work with the dev server as an npm dependency.
However if you just copy the code in this repo and the chengsokdara/async-hook repo into your project and fix a few references, it will work also with the dev server.

@TomYeoman
Copy link

Thanks for the info @kvndrsslr, may do this just to get development flow working. I'm using https://crxjs.dev/vite-plugin for extension development, and running in watch mode doesn't work at all for content scripts.

@jcdogo
Copy link

jcdogo commented May 25, 2023

Yes, this is definitely a Vite dev server problem. Running the same exact code in a fresh create-react-app typescript template project worked just fine.

@sudhakar29495
Copy link

sudhakar29495 commented May 29, 2023

@kvndrsslr - I was experiencing the same issue in vitejs, I implemented a workaround by installing the required dependency lamejs and imported that into my component without using it.

const { Mp3Encoder } = await import('lamejs'); or import { Mp3Encoder } from 'lamejs';

Not sure about the issue with Vitejs or lamejs.

smk131314 pushed a commit to LoKo-DevGirls/memory-journey-fe that referenced this issue Jun 17, 2023
@Ami777
Copy link

Ami777 commented Jul 26, 2023

kvndrsslr

Thank you for your reply. It literally saved my day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants