Skip to content

Uncaught SyntaxError: Unexpected identifier 'injectIntoGlobalHook' #484

Closed
@Lugribossk

Description

@Lugribossk

Related plugins

Describe the bug

When upgrading from @vitejs/plugin-react-swc v3.8.1 to either v3.9.0 or v3.10.0, the page is now suddenly broken when running with vite dev. The console reports Uncaught SyntaxError: Unexpected identifier 'injectIntoGlobalHook' and examining the page source reveals this text:

<!DOCTYPE html><html translate="no"><head><script type="module">import { injectIntoGlobalHook } from "/@react-refresh"injectIntoGlobalHook(window);window.$RefreshReg$ = () => {};window.$RefreshSig$ = () => (type) => type;</script>

While the working v3.8.1 gives:

<!DOCTYPE html><html translate="no"><head><script type="module">import { injectIntoGlobalHook } from "/@react-refresh";injectIntoGlobalHook(window);window.$RefreshReg$ = () => {};window.$RefreshSig$ = () => (type) => type;</script>

Note the semicolon before injectIntoGlobalHook

Reproduction

Sorry this is for an internal project so I can't share it

Steps to reproduce

vite dev, open page in browser.

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (16) x64 13th Gen Intel(R) Core(TM) i7-1360P
    Memory: 5.80 GB / 31.62 GB
  Binaries:
    Node: 22.11.0 - ~\scoop\apps\volta\current\appdata\tools\image\node\22.11.0\node.EXE
    npm: 10.9.0 - ~\scoop\apps\volta\current\appdata\tools\image\npm\10.9.0\bin\npm.CMD
    bun: 1.2.12 - ~\scoop\shims\bun.EXE
  Browsers:
    Edge: Chromium (133.0.3065.59)
    Internet Explorer: 11.0.26100.1882
  npmPackages:
    @vitejs/plugin-react-swc: 3.10.0 => 3.10.0 
    vite: 6.3.5 => 6.3.5

Used Package Manager

npm

Logs

localhost/:1 Uncaught SyntaxError: Unexpected identifier 'injectIntoGlobalHook'

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions