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

Acorn: SyntaxError: Identifier 'RefreshRuntime' has already been declared #1361

Closed
tony19 opened this issue Jan 31, 2023 · 5 comments · Fixed by #1370
Closed

Acorn: SyntaxError: Identifier 'RefreshRuntime' has already been declared #1361

tony19 opened this issue Jan 31, 2023 · 5 comments · Fixed by #1370
Labels

Comments

@tony19
Copy link

tony19 commented Jan 31, 2023

Describe the bug

Preview.js cannot render basic React component in newly scaffolded Vite React TypeScript + SWC project. It works fine for the normal Vite React TypeScript template (without SWC).

Screenshot 2023-01-30 at 5 55 24 PM

Logs Unable to render HelloWorld While Preview.js can work out of the box for simple components, you may need a custom configuration to render components that depend on:

a specific state or context (see Wrapping components)
modules imported via aliases
static assets or SVGR
Please see the logs below:

[5:49:58 PM] Unable to parse /Users/atrinh5/src/tmp/vite-tmp/src/components/HelloWorld.tsx with Acorn: SyntaxError: Identifier 'RefreshRuntime' has already been declared (10:7)

at findTopLevelEntityNames (/Users/atrinh5/.vscode/extensions/zenclabs.previewjs-1.17.3/dist/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@previewjs/core/dist/index.cjs:370:11)
at TransformContext.transform (/Users/atrinh5/.vscode/extensions/zenclabs.previewjs-1.17.3/dist/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@previewjs/core/dist/index.cjs:354:35)
at Object.transform (file:///Users/atrinh5/.vscode/extensions/zenclabs.previewjs-1.17.3/dist/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-5e7f419b.js:41506:44)
at async loadAndTransform (file:///Users/atrinh5/.vscode/extensions/zenclabs.previewjs-1.17.3/dist/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-5e7f419b.js:39313:29)

[5:49:58 PM] TypeError: Failed to fetch dynamically imported module: http://localhost:3141/preview/src/components/HelloWorld.tsx

Reproduction

  1. Scaffold a Vite project with npm init vite@latest. Pick React and TypeScript + SWC.
  2. Create src/components/HelloWorld.tsx with sample code:
export const HelloWorld = () => {
  return <h1>Hello world</h1>
}
  1. In VS Code, click Open HelloWorld in Preview.js (shown above component name in HelloWorld.tsx).
  2. Observe the error seen in screenshot.

Preview.js version

v1.17.3

Framework

React 18.2.0

System Info

*command hung on my laptop*

* macOS Ventura
* M1 MAX
* Chrome Version 109.0.5414.87 (Official Build) (arm64) 
* VS Code 1.71.2

Used Package Manager

npm

Extension logs (useful for crashes)

[2023-01-30 17:43:30.122] [exthost] [info] Extension host with pid 18292 started
[2023-01-30 17:43:30.122] [exthost] [info] Skipping acquiring lock for /Users/atrinh5/Library/Application Support/Code/User/workspaceStorage/e08fa41c59503b9df67a6952317b0c27.
[2023-01-30 17:43:30.150] [exthost] [info] ExtensionService#_doActivateExtension vscode.microsoft-authentication, startup: false, activationEvent: 'onAuthenticationRequest:microsoft'
[2023-01-30 17:43:30.161] [exthost] [info] ExtensionService#_doActivateExtension vscode.debug-auto-launch, startup: true, activationEvent: '*'
[2023-01-30 17:43:30.164] [exthost] [info] ExtensionService#_doActivateExtension vscode.git-base, startup: true, activationEvent: '*', root cause: vscode.git
[2023-01-30 17:43:30.168] [exthost] [info] ExtensionService#_doActivateExtension vscode.ipynb, startup: true, activationEvent: '*'
[2023-01-30 17:43:30.170] [exthost] [info] ExtensionService#_doActivateExtension redhat.vscode-yaml, startup: true, activationEvent: '*', root cause: 42Crunch.vscode-openapi
[2023-01-30 17:43:30.191] [exthost] [info] ExtensionService#_doActivateExtension vscode.npm, startup: true, activationEvent: 'workspaceContains:package.json'
[2023-01-30 17:43:30.203] [exthost] [info] ExtensionService#_doActivateExtension antfu.iconify, startup: true, activationEvent: 'workspaceContains:package.json'
[2023-01-30 17:43:30.439] [exthost] [warning] [redhat.vscode-yaml] Accessing a resource scoped configuration without providing a resource is not expected. To get the effective value for '[yaml]', provide the URI of a resource or 'null' for any resource.
[2023-01-30 17:43:30.440] [exthost] [warning] [redhat.vscode-yaml] Accessing a resource scoped configuration without providing a resource is not expected. To get the effective value for '[yaml]', provide the URI of a resource or 'null' for any resource.
[2023-01-30 17:43:30.701] [exthost] [info] ExtensionService#_doActivateExtension vscode.git, startup: true, activationEvent: '*'
[2023-01-30 17:43:30.713] [exthost] [info] ExtensionService#_doActivateExtension vscode.github, startup: true, activationEvent: '*'
[2023-01-30 17:43:30.717] [exthost] [info] ExtensionService#_doActivateExtension 42Crunch.vscode-openapi, startup: true, activationEvent: '*'
[2023-01-30 17:43:31.045] [exthost] [info] ExtensionService#_doActivateExtension hilleer.yaml-plus-json, startup: true, activationEvent: 'workspaceContains:**/**.json,**/**.yml,**/**.yaml'
[2023-01-30 17:43:31.075] [exthost] [info] ExtensionService#_doActivateExtension vscode.github-authentication, startup: false, activationEvent: 'onAuthenticationRequest:github'
[2023-01-30 17:43:31.107] [exthost] [info] Eager extensions activated
[2023-01-30 17:43:31.112] [exthost] [info] ExtensionService#_doActivateExtension vscode.emmet, startup: false, activationEvent: 'onStartupFinished'
[2023-01-30 17:43:31.116] [exthost] [info] ExtensionService#_doActivateExtension vscode.merge-conflict, startup: false, activationEvent: 'onStartupFinished'
[2023-01-30 17:43:31.117] [exthost] [info] ExtensionService#_doActivateExtension bradlc.vscode-tailwindcss, startup: false, activationEvent: 'onStartupFinished'
[2023-01-30 17:43:31.125] [exthost] [info] ExtensionService#_doActivateExtension dbaeumer.vscode-eslint, startup: false, activationEvent: 'onStartupFinished'
[2023-01-30 17:43:31.143] [exthost] [info] ExtensionService#_doActivateExtension eamodio.gitlens, startup: false, activationEvent: 'onStartupFinished'
[2023-01-30 17:43:31.160] [exthost] [info] ExtensionService#_doActivateExtension esbenp.prettier-vscode, startup: false, activationEvent: 'onStartupFinished'
[2023-01-30 17:43:31.178] [exthost] [info] ExtensionService#_doActivateExtension usernamehw.errorlens, startup: false, activationEvent: 'onStartupFinished'
[2023-01-30 17:43:31.180] [exthost] [info] ExtensionService#_doActivateExtension zenclabs.previewjs, startup: false, activationEvent: 'onStartupFinished'
[2023-01-30 17:43:37.453] [exthost] [info] ExtensionService#_doActivateExtension vscode.typescript-language-features, startup: false, activationEvent: 'onLanguage:typescriptreact'
[2023-01-30 17:43:37.469] [exthost] [info] ExtensionService#_doActivateExtension Orta.vscode-twoslash-queries, startup: false, activationEvent: 'onLanguage:typescriptreact'
[2023-01-30 17:43:37.491] [exthost] [info] ExtensionService#_doActivateExtension unifiedjs.vscode-mdx, startup: false, activationEvent: 'onLanguage:typescriptreact'
[2023-01-30 17:43:37.504] [exthost] [info] ExtensionService#_doActivateExtension Vue.volar, startup: false, activationEvent: 'onLanguage:typescriptreact'
[2023-01-30 17:58:55.273] [exthost] [info] ExtensionService#_doActivateExtension vscode.configuration-editing, startup: false, activationEvent: 'onLanguage:json'
[2023-01-30 17:58:55.293] [exthost] [info] ExtensionService#_doActivateExtension vscode.extension-editing, startup: false, activationEvent: 'onLanguage:json'
[2023-01-30 17:58:55.306] [exthost] [info] ExtensionService#_doActivateExtension vscode.json-language-features, startup: false, activationEvent: 'onLanguage:json'

Preview logs (useful for rendering errors)

logs.ts:9 [vite] Internal Server Error
Unable to parse /Users/atrinh5/src/tmp/vite-tmp/src/components/HelloWorld.tsx with Acorn: SyntaxError: Identifier 'RefreshRuntime' has already been declared (10:7)
    at findTopLevelEntityNames (/Users/atrinh5/.vscode/extensions/zenclabs.previewjs-1.17.3/dist/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@previewjs/core/dist/index.cjs:370:11)
    at TransformContext.transform (/Users/atrinh5/.vscode/extensions/zenclabs.previewjs-1.17.3/dist/node_modules/.pnpm/@[email protected]_@[email protected]/node_modules/@previewjs/core/dist/index.cjs:354:35)
    at Object.transform (file:///Users/atrinh5/.vscode/extensions/zenclabs.previewjs-1.17.3/dist/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-5e7f419b.js:41506:44)
    at async loadAndTransform (file:///Users/atrinh5/.vscode/extensions/zenclabs.previewjs-1.17.3/dist/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-5e7f419b.js:39313:29)
(anonymous) @ logs.ts:9
18:00:21.586 logs.ts:9 TypeError: Failed to fetch dynamically imported module: http://localhost:3141/preview/src/components/HelloWorld.tsx

Repo link (if available)

https://github.com/tony19-sandbox/vite-ts-react-swc

Anything else?

No response

@fwouts
Copy link
Owner

fwouts commented Feb 19, 2023

Hey @tony19, sorry about the radio silence. Fix coming soon :)

fwouts added a commit that referenced this issue Feb 19, 2023
@TheYarin
Copy link

Any estimate when will the new version be released to the marketplace?

@fwouts
Copy link
Owner

fwouts commented Feb 19, 2023

@TheYarin aiming for early next week.

@fwouts fwouts reopened this Feb 19, 2023
@TheYarin
Copy link

🙏

@fwouts
Copy link
Owner

fwouts commented Feb 19, 2023

v1.17.4 was just pushed to VS Code Marketplace, should be live within an hour or two.

@fwouts fwouts closed this as completed Feb 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants