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

"npm run build" ends in error "[vite:esbuild] Transform failed - ERROR: Expected ">" but found "setup" #1844

Open
bLuma opened this issue Aug 27, 2024 · 4 comments

Comments

@bLuma
Copy link

bLuma commented Aug 27, 2024

Describe the bug

"npm run build" ends in error "[vite:esbuild] Transform failed with 1 error - ERROR: Expected ">" but found "setup"" with just initialized slidev project. Its probably same error as previously encountered in #1808.

Minimal reproduction

Steps to reproduce the behavior:

  1. npm init slidev@latest
  2. npm run build

Environment

  • Slidev version:
  • slidev@ c:\Users\r\Downloads\slidevn\slidev
    +-- @slidev/cli@0.49.29
    +-- @slidev/theme-default@0.25.0
    +-- @slidev/theme-seriph@0.25.0
    `-- vue@3.4.38
  • slidev is not installed globally
  • Browser: -
  • OS: Windows 11 Home
  • Node v22.7.0, originally tested with v20, no improvements
  • NPM 10.8.2
  Slidev  v0.49.29

  theme       @slidev/theme-seriph
  css engine  unocss
  entry       c:\Users\r\Downloads\slidevn\slidev\slides.md
vite v5.4.2 building for production...
✓ 340 modules transformed.
x Build failed in 3.42s
[vite:esbuild] Transform failed with 1 error:
C:/Users/r/Downloads/slidevn/slidev/node_modules/@slidev/client/internals/SlideLoading.vue?vue&type=script&setup=true&lang.ts:1:8: ERROR: Expected ">" but found "setup"
file: C:/Users/r/Downloads/slidevn/slidev/node_modules/@slidev/client/internals/SlideLoading.vue?vue&type=script&setup=true&lang.ts:1:8

Expected ">" but found "setup"
1  |  <script setup lang="ts">
   |          ^
2  |  import { onMounted, ref } from 'vue'
3  |

    at failureErrorWithLog (c:\Users\r\Downloads\slidevn\slidev\node_modules\vite\node_modules\esbuild\lib\main.js:1472:15)
    at c:\Users\r\Downloads\slidevn\slidev\node_modules\vite\node_modules\esbuild\lib\main.js:755:50
    at responseCallbacks.<computed> (c:\Users\r\Downloads\slidevn\slidev\node_modules\vite\node_modules\esbuild\lib\main.js:622:9)
    at handleIncomingPacket (c:\Users\r\Downloads\slidevn\slidev\node_modules\vite\node_modules\esbuild\lib\main.js:677:12)
    at Socket.readFromStdout (c:\Users\r\Downloads\slidevn\slidev\node_modules\vite\node_modules\esbuild\lib\main.js:600:7)
    at Socket.emit (node:events:520:28)
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)
    at Pipe.onStreamRead (node:internal/stream_base_commons:191:23) {
  errors: [Getter/Setter],
  warnings: [Getter/Setter],
  frame: '\n' +
    '\x1B[33mExpected ">" but found "setup"\x1B[39m\n' +
    '1  |  <script setup lang="ts">\n' +
    '   |          ^\n' +
    "2  |  import { onMounted, ref } from 'vue'\n" +
    '3  |  \n',
  loc: {
    column: 8,
    file: 'C:/Users/r/Downloads/slidevn/slidev/node_modules/@slidev/client/internals/SlideLoading.vue?vue&type=script&setup=true&lang.ts',
    length: 5,
    line: 1,
    lineText: '<script setup lang="ts">',
    namespace: '',
    suggestion: '>'
  },
  code: 'PLUGIN_ERROR',
  plugin: 'vite:esbuild',
  hook: 'transform',
  id: 'C:/Users/r/Downloads/slidevn/slidev/node_modules/@slidev/client/internals/SlideLoading.vue?vue&type=script&setup=true&lang.ts',
  watchFiles: [

Maybe its platform (Windows) related, I tested your "sandbox" environment and know that there build is fine. I'm familiar to Node and react, but not to vue / vite / esbuild, not sure where to look more specifically for error/help with this issue.

@Llois41
Copy link

Llois41 commented Aug 28, 2024

I don't know if this is helpful but I think this issue is more related to the interaction between vite, esbuild or one of the plugins used to transform the vue code.
We get this exact same error in our project (and don't use slidev at all) and saw that the esbuild step in our building/bundling process received the .vue SFC file when it was expecting TypeScript code.
But this error occures only occasionally so it is very hard to debug.

However I hope this helps to point in the right direction.

@bLuma
Copy link
Author

bLuma commented Aug 28, 2024

And I forgot to mention that I have no error when starting dev server or doing export to pdf. Only build operation is failing.

@KermanX
Copy link
Member

KermanX commented Aug 28, 2024

Possibly vitejs/vite-plugin-vue#431. There is a workaround in dcloudio/uni-preset-vue#102 (comment). What's the @vitejs/plugin-vue version you're using?

@bLuma
Copy link
Author

bLuma commented Aug 28, 2024

I have 5.1.2 and ends in error.

| | +-- @vitejs/plugin-vue-jsx@4.0.1 deduped
| | +-- @vitejs/plugin-vue@5.1.2 deduped
| | +-- unplugin-vue-markdown@0.26.2 deduped
| | +-- vite-plugin-vue-server-ref@0.4.2 deduped
| +-- @vitejs/plugin-vue-jsx@4.0.1
| +-- @vitejs/plugin-vue@5.1.2
| +-- unplugin-vue-components@0.27.4
| +-- unplugin-vue-markdown@0.26.2
| +-- vite-plugin-vue-server-ref@0.4.2

Tried mentioned version ~5.0.4, which resulted again in error:

| | +-- @vitejs/plugin-vue-jsx@4.0.1 deduped
| | +-- @vitejs/plugin-vue@5.0.5 overridden
| | +-- unplugin-vue-markdown@0.26.2 deduped
| | +-- vite-plugin-vue-server-ref@0.4.2 deduped
| +-- @vitejs/plugin-vue-jsx@4.0.1
| +-- @vitejs/plugin-vue@5.0.5 overridden
| +-- unplugin-vue-components@0.27.4
| +-- unplugin-vue-markdown@0.26.2
| +-- vite-plugin-vue-server-ref@0.4.2

I tested it also on another computer, where i have windows and it works with plugin-vue 5.1.2. In fact I compared output of "npm ls -a" and i got all packages on same versions on both computers. Yet on one it works and on second still no. To be sure i copied entire project with all installed node modules from working computer to my not working, run build and again got error. So exactly same code works on work computer with Win 10 22H2 and not works on my home computer with Win 11.

And because this looks like some error connected to vite/esbuild feel free to close this issue as this is probably unsolvable by slidev.

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

No branches or pull requests

6 participants
@bLuma @Llois41 @KermanX and others