KeJunMao / unplugin-preprocessor-directives

preprocessor directives for jsx,tsx,js,ts,html,css,vue and more
MIT License
70 stars 7 forks source link

Cannot read properties of undefined (reading 'match') error when using comments without space before text #6

Closed Vorion86 closed 8 months ago

Vorion86 commented 8 months ago

Hi, after upgrading to version 1.0.0 (and also the latest 1.0.2) I'm getting the following error using the vite plugin (unplugin-preprocessor-directives/vite)

Cannot read properties of undefined (reading 'match')

After some testing, I found that this error seems to occur if a javascript comment does not contain a space after "//". This comment creates an error : "//error comment", while this works without any issue "// working comment". I've also created a playground demonstrating the issue at stackblitz: https://stackblitz.com/edit/vitejs-vite-hy77nf?file=package.json,src%2FApp.vue (Comment is in App.vue)

Thanks.

Edit: After rechecking stackblitz with Firefox I get an erorr saying "comment is undefined", Chrome shows the error above.

KeJunMao commented 8 months ago

thank you! try v1.0.3