crxjs / chrome-extension-tools

Bundling Chrome Extensions can be pretty complex. It doesn't have to be.
https://crxjs.dev/vite-plugin
2.76k stars 182 forks source link

React refresh preamble was not loaded. Something is wrong. #769

Closed yanglee2421 closed 1 year ago

yanglee2421 commented 1 year ago

Build tool

Vite

Where do you see the problem?

Describe the bug

When using @crxjs/vite-plugin@2 and @vitejs/plugin-react-swc@3 at the same time, the following error occurs in the development mode.

Error:React refresh preamble was not loaded. Something is wrong.

But in production mode, the result generated by build seems to be normal.

Reproduction

https://github.com/yanglee2421/vite-template/tree/main/crx

Logs

Error: React refresh preamble was not loaded. Something is wrong.
    at content.tsx.js:3:33

System Info

System:
    OS: Windows 10 10.0.22621
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 36.06 GB / 63.63 GB
  Binaries:
    Node: 18.16.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
    npm: 9.5.1 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.6.12 - C:\Program Files\nodejs\pnpm.CMD
  Browsers:
    Edge: Spartan (44.22621.2134.0), Chromium (115.0.1901.203)
    Internet Explorer: 11.0.22621.1

Severity

blocking an upgrade

Toumash commented 1 year ago

Out of curiosity: why not @vitejs/plugin-react?

Im using

    "@crxjs/vite-plugin": "^2.0.0-beta.18",
    "vite": "^4.4.6",
    "typescript": "5.1.6",
    "@vitejs/plugin-react": "^4.0.3",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
yanglee2421 commented 1 year ago

Yes, I switched to plugin-react and it solved the problem.

从 Windows 版邮件https://go.microsoft.com/fwlink/?LinkId=550986发送

发件人: Tomasz @.> 发送时间: 2023年8月20日 19:30 收件人: @.> 抄送: @.>; @.> 主题: Re: [crxjs/chrome-extension-tools] React refresh preamble was not loaded. Something is wrong. (Issue #769)

Out of curiosity: why not @vitejs/plugin-react?

Im using

***@***.***/vite-plugin": "^2.0.0-beta.18",

"vite": "^4.4.6",

"typescript": "5.1.6",

***@***.***/plugin-react": "^4.0.

"react": "^18.2.0",

"react-dom": "^18.2.0",

— Reply to this email directly, view it on GitHubhttps://github.com/crxjs/chrome-extension-tools/issues/769#issuecomment-1685260384, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A5GNBTEXWDPCVLRFC6B2TVLXWHYLTANCNFSM6AAAAAA3TNVWAU. You are receiving this because you authored the thread.Message ID: @.***>

Toumash commented 1 year ago

Lets close it then

sovetski commented 9 months ago

I have the same problem, I am using "@vitejs/plugin-react-swc": "^3.5.0", and "@crxjs/vite-plugin": "^2.0.0-beta.21"

Toumash commented 9 months ago

I have the same problem, I am using "@vitejs/plugin-react-swc": "^3.5.0", and "@crxjs/vite-plugin": "^2.0.0-beta.21"

Use @vitejs/plugin-react then :P

I was trying to get the warning into the docs https://github.com/crxjs/chrome-extension-tools/pull/770

sovetski commented 9 months ago

I have the same problem, I am using "@vitejs/plugin-react-swc": "^3.5.0", and "@crxjs/vite-plugin": "^2.0.0-beta.21"

Use @vitejs/plugin-react then :P

I was trying to get the warning into the docs #770

Thank you, it worked without SWC