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

Problems with tsx template #402

Closed
4 tasks done
cernymatej opened this issue Nov 6, 2024 · 10 comments · Fixed by #414
Closed
4 tasks done

Problems with tsx template #402

cernymatej opened this issue Nov 6, 2024 · 10 comments · Fixed by #414
Labels

Comments

@cernymatej
Copy link

cernymatej commented Nov 6, 2024

Reporting a bug?

After upgrading @nuxtjs/i18n from 8.5.3 to v9, I encountered several pre-transform errors. In my main project, it was the following error message: Pre-transform error: '>' expected. I tracked this down to an issue with parsing TSX templates.

While stripping down the project to identify the root cause, I also encountered the following errors:

ERROR  Internal server error: ',' expected.
   10:26:17 AM
  Plugin: unplugin-vue-i18n:directive

and

Pre-transform error: Type expected.

The last one is present in the minimal reproduction linked below.

This issue wasn’t present in @nuxtjs/[email protected].

This seems to work fine:

<script lang="ts">
export default defineComponent((props, ctx) => {
  return () => h('div', ['Test'])
})
</script>

I hope this reproduction is usable, even though it doesn’t directly use unplugin-vue-i18n, as it’s minimal enough to demonstrate the issue and doesn't use any @nuxtjs/i18n features.

Expected behavior

Tsx templates to work.

Reproduction

https://stackblitz.com/edit/github-ffpcjt-qcfsie?file=components%2FTestComponent.vue

Working:
https://stackblitz.com/edit/github-ffpcjt?file=nuxt.config.ts,components%2FTestComponent.vue,app.vue

Issue Package

unplugin-vue-i18n

System Info

System:
    OS: macOS 15.1
    CPU: (12) arm64 Apple M2 Max
    Memory: 5.24 GB / 96.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.9.0 - ~/.nvm/versions/node/v20.9.0/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 10.1.0 - ~/.nvm/versions/node/v20.9.0/bin/npm
    pnpm: 9.9.0 - ~/Library/pnpm/pnpm
    bun: 1.0.25 - ~/.bun/bin/bun
  Browsers:
    Chrome: 130.0.6723.116
    Safari: 18.1

Screenshot

No response

Additional context

No response

Validations

  • Read the Contributing Guidelines.
  • Read the README
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A open a GitHub Discussion.
@kazupon
Copy link
Member

kazupon commented Nov 7, 2024

Thank you for your reporting!

Pre-transform error: Type expected.

Unfortunately, I could not reproduce the about error in my stackblitz environment 😿
Could you try to reproduce with CONSOLA_LEVEL=999 nuxt dev 🙏
That log level is able to output stack error on nuxt log (consola)

And I have a favor to ask. Two type of your github issues have been reported.
Please separate them as separate issues. It makes it easier for us to work on the issue. 🙏

@kazupon kazupon added Status: Need More Info Lacks enough info to make progress and removed Status: Review Needed Request for review comments labels Nov 7, 2024
@ankeycheng
Copy link

ankeycheng commented Nov 7, 2024

@kazupon Hi, please try this reproduction, I think this is another similar issue, when using jsx/tsx in setup mode, the error message shows [plugin:unplugin-vue-i18n:directive] Unterminated regular expression literal.
https://stackblitz.com/edit/github-ffpcjt-6wnhlw?file=components%2FTestComponent.vue

and if you try to reference a variable in node like this:

<script lang="tsx" setup>
const foo = 'foo';
const Test = () => <div>Test{foo}</div>;
</script>

the error message shows [plugin:unplugin-vue-i18n:directive] ',' expected. which @cernymatej mentioned above.

@kazupon
Copy link
Member

kazupon commented Nov 7, 2024

I mean regarding the following error.

Pre-transform error: Type expected.

I recognize about tsx (jsx) issue.

@cernymatej
Copy link
Author

cernymatej commented Nov 7, 2024

Oh, I'm sorry, I only attached the working reproduction.
The error message should be present here: https://stackblitz.com/edit/github-ffpcjt-qcfsie?file=components%2FTestComponent.vue

(I cannot verify that the error message is still present at the moment, since I have only my iPad on me right now, and it cannot start the dev server on StackBlitz. I have written the component code from memory. I'll be able to check it in about 4 hours.)


Btw. could you please help me understand what two types of issues you mean? I thought that this is all related to the same parsing issue.


Edit: So, I've checked it and the reproduction above shows the [plugin:unplugin-vue-i18n:directive] ',' expected. error message. I cannot figure out what I did to get the Pre-transform error: Type expected. error, however, I've managed to create a reproduction for the original Pre-transform error: '>' expected. error, which you can find here:
https://stackblitz.com/edit/github-ffpcjt-6cqg2q?file=components%2FTestComponent.vue,app.vue

@cernymatej
Copy link
Author

cernymatej commented Nov 25, 2024

Hi there, it doesn' look like this was fixed. Still cannot build this:
https://stackblitz.com/edit/github-ffpcjt-wvpad2?file=package.json
(updated @nuxtjs/i18n to 9.1.0, which should include this fix)

@userquin
Copy link
Member

@cernymatej this is another problem with vite directive plugin and vite vue plugin: #420

@cernymatej
Copy link
Author

@userquin I see, but when you download the reproduction and try to build it locally, does it build for you?

I can still see the Pre-transform error:

image

@userquin
Copy link
Member

uhmm, I get this error in your repro:

imagen

@cernymatej
Copy link
Author

cernymatej commented Nov 25, 2024

Yes, this is on Stackblitz and should be related to #420 as you said, but try to build it locally on your computer.

I think the Stackblitz error is masking the other error.

@cernymatej
Copy link
Author

@userquin sorry for the ping but were you able to reproduce it? Should I raise a new issue?

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