slidevjs / slidev

Presentation Slides for Developers
https://sli.dev
MIT License
33.49k stars 1.37k forks source link

Some code snippet can make slidev crash #151

Closed Toilal closed 3 years ago

Toilal commented 3 years ago

I try to embed this code in a slide, but it seems to make slidev crash.

###> nelmio/cors-bundle ###
CORS_ALLOW_ORIGIN=^https?://(?:api[\.-])?{{core.domain.sub}}\.{{core.domain.ext}}$
###< nelmio/cors-bundle ###

To reproduce, run npm init slidev and add this snippet surrounded with usual three backticks and langage into first slide.

Toilal commented 3 years ago

Please note that removing ^https?://(?:api[\.-])?{{core.domain.sub}}\.{{core.domain.ext}}$ part from the snippet make things work, so it seems there's something in the regex that triggers the crash.

Toilal commented 3 years ago

I have narrowed things down, and it seems to crash because of the mustache {{...}} pattern if it occurs more that one time.

Pass

{{a}}

Pass

{{b}}

Fail

{{a}} {{b}}
Toilal commented 3 years ago

And the stacktrace, it seems to crash in vite vue plugin.

[vite] Internal server error: Cannot read property 'line' of undefined
  Plugin: vite:vue
  File: /@slidev/slides/10.md
      at createRollupError (C:\Users\FRUP67305\projects\MENJ-Accompagnement-Dev-Workflow\node_modules\@vitejs\plugin-vue\dist\index.js:4092:29)
      at C:\Users\FRUP67305\projects\MENJ-Accompagnement-Dev-Workflow\node_modules\@vitejs\plugin-vue\dist\index.js:4346:51
      at Array.forEach (<anonymous>)
      at transformMain (C:\Users\FRUP67305\projects\MENJ-Accompagnement-Dev-Workflow\node_modules\@vitejs\plugin-vue\dist\index.js:4346:12)
      at TransformContext.transform (C:\Users\FRUP67305\projects\MENJ-Accompagnement-Dev-Workflow\node_modules\@vitejs\plugin-vue\dist\index.js:4665:16)
      at Object.transform (C:\Users\FRUP67305\projects\MENJ-Accompagnement-Dev-Workflow\node_modules\vite\dist\node\chunks\dep-e9a16784.js:44268:53)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)
      at async transformRequest (C:\Users\FRUP67305\projects\MENJ-Accompagnement-Dev-Workflow\node_modules\vite\dist\node\chunks\dep-e9a16784.js:58540:29)
      at async viteTransformMiddleware (C:\Users\FRUP67305\projects\MENJ-Accompagnement-Dev-Workflow\node_modules\vite\dist\node\chunks\dep-e9a16784.js:58678:32)
antfu commented 3 years ago

image Works fine for me, have you upgraded to the latest version?

Toilal commented 3 years ago

Slidev v0.12.1, installer with npm.

Toilal commented 3 years ago

Important stuff, and i'm sorry about that, I run on Windows NodeJS 14.17.0. I'll give a try on my linux computer right now.

antfu commented 3 years ago

Ah, why are you using ### instead of ```? If they are not inside of code blocks, mustache are treated as Vue template interpretations.

Toilal commented 3 years ago

### are comments inside the snippet I want to display in slide. But anyway, I can reproduce the error without those symbols, on Linux Ubuntu too.

Please clone this minimal reproduction repository : https://github.com/Toilal/slide-issue-repro

npm install & npm run dev, you should be able to reproduce the crash.

Ahacad commented 3 years ago

I can reproduce this error on my machine with create-slidev@0.12.1:

[plugin:vite:vue] ENOENT: no such file or directory, open '/@slidev/slides/1.md'

strange message, not sure where is the problem yet.