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

JSX Render Functions in Nuxt 2 with Nuxt Bridge are failing #17

Closed
loweoj opened this issue Oct 13, 2021 · 12 comments · Fixed by nuxt/framework#922 or #1046
Closed

JSX Render Functions in Nuxt 2 with Nuxt Bridge are failing #17

loweoj opened this issue Oct 13, 2021 · 12 comments · Fixed by nuxt/framework#922 or #1046
Labels
bug Something isn't working webpack

Comments

@loweoj
Copy link

loweoj commented Oct 13, 2021

Environment

Nuxt CLI v3.0.0-27234503.d5127e9
RootDir: /sandbox
Nuxt project info:


  • Operating System: Linux
  • Node Version: v14.17.6
  • Nuxt Version: 2.16.0-27226092.034b9901
  • Package Manager: Yarn
  • Bundler: Webpack
  • User Config: buildModules
  • Runtime Modules: -
  • Build Modules: @nuxt/[email protected]

Describe the bug and expected behavior

Attempting to use JSX inside a render function is now failing with Syntax Error: Unexpected token, expected ","

Steps to reproduce

View the compilation error in context here:
https://codesandbox.io/s/suspicious-euclid-g904s?

I expect to see "Hello Nuxt!" wrapped in a div with a class of "a-container-class".

Additional context

This code was working without the upgrade nuxt bridge.

@loweoj loweoj added bridge bug Something isn't working labels Oct 13, 2021
@604587986
Copy link

+1

@tylerforesthauser
Copy link

I just wanted to check in on the status of this. I am facing issues with syntax errors when attempting to run my Nuxt 2 project with Bridge. Is there a way to configure my project to use Vite instead of webpack? Would that resolve my issue?

@loweoj
Copy link
Author

loweoj commented Nov 15, 2021

The Code Sandbox I attached here is still failing to build, despite some work in the right direction. What more needs to be done to fix this? Happy to submit a PR if someone can point me in the right direction?

@604587986
Copy link

+1,if use defineNuxtConfig babel presets will be unuseful

@zafarich
Copy link

zafarich commented Apr 1, 2022

+1

@danielroe danielroe transferred this issue from nuxt/framework Apr 13, 2022
@lauer3912
Copy link

+1

@danielroe
Copy link
Member

danielroe commented Jul 9, 2022

Yes, I can confirm the issue persists (reproduction - and working without Bridge), though a workaround is to enable vite mode @tylerforesthauser:

import { defineNuxtConfig } from '@nuxt/bridge'

export default defineNuxtConfig({
  bridge: {
    vite: true,
  },
})

@danielroe danielroe added webpack and removed bridge labels Jul 9, 2022
@homerjam
Copy link

homerjam commented Dec 13, 2022

Does anyone have a workaround for this? Apart from Vite which unfortunately is a no-go at the moment

@Chapaev17
Copy link

+1

@gokalpfirat
Copy link

@danielroe Any updates for webpack?

@chuckadams
Copy link

chuckadams commented Aug 29, 2023

The workaround to enable vite does not work for me, though it does give me nicer-looking error messages:

 ERROR  [commonjs--resolver] Unexpected token (Note that you need plugins to import files that are not JavaScript)                                           9:12:36 AM
file: [redacted]
225: 
226:         return (
227:             <div class={['p-splitter p-component', 'p-splitter-' + this.layout]}>
                 ^
228:                 {this.$slots.default}
229:                 {

 ERROR  Unexpected token (Note that you need plugins to import files that are not JavaScript)                                                                9:12:36 AM

The error appears to go away when I edit the <script> tag to <script lang="jsx">. This is in a third-party library however, so it's not feasible for me to patch, and it worked without the change prior to migrating to nuxt bridge.

@wattanx
Copy link
Collaborator

wattanx commented Jan 16, 2024

If you use jsx/tsx with nuxt/bridge, you need to add the isTSX option.(It is possible that it will not be needed in the future.)
#1064

export default defineNuxtConfig({
  birdge: {
    typescript: { isTSX: true }
  }
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working webpack
Projects
None yet
Development

Successfully merging a pull request may close this issue.