vuejs / vue-eslint-parser

The ESLint custom parser for `.vue` files.
MIT License
435 stars 74 forks source link

Major performance degrade after updating nuxt from `3.6.5` to `3.7` #216

Closed SimonSimCity closed 5 months ago

SimonSimCity commented 5 months ago

In a project of mine I updated the package nuxt from version 3.6.5 to 3.7.0 (https://github.com/bcc-code/bmm-web/commit/3ecf83c1a8ea429acccf362fceaaf835e5bbce26) after which the performance of eslint degraded by a huge margin. What before was a matter of seconds, now took minutes!

I've chatted a bit in the nuxt forum, and one suggested that this might be an issue with this package.

I created a cpu profile of what was happening [...] Screenshot 2024-01-16 at 09 20 12

and narrowed it all down to a single vue-operation of my vue-file - a v-for expression (red in the picture above, focussed in the picture below). Screenshot 2024-01-16 at 09 18 36

What was astonishing now was, that in here, I could see, that the function createDiagnosticExplainingFile, provided by typescript, was called more than once, and the first call took almost equally long before and after updating. But the fact, that after the update it was called multiple times for evaluating the one v-for operation, was an explanation to be for this massive slow-down.

Here's the file I was linting when creating the cpu profile: https://github.com/bcc-code/bmm-web/blob/3ecf83c1a8ea429acccf362fceaaf835e5bbce26/components/MediaPlayer.vue

EDIT: I found the issue #65, and my problem here has the exact same properties - it's slow when providing the parser-option project - but I couldn't confirm that the parser espree or the package typescript-eslint-parser-for-extra-files helped solving the issue.

SimonSimCity commented 5 months ago

Here are some additional tests I tried to check what it was that made my project so slow:

Now, when looking at the file .nuxt/types/imports.d.ts - it's a 2745 lines long generated file of import definitions 😱 - fair enough, before the update it was on 1594 lines and it took 16s user time without and 21.00s with a reference to this file; so there must be something either within the file or in the handling of something.

Comparing this file generated before and after updating revealed, that the import statement of the packages is different. Before it was import('vue') and afterwards the path was changed to an absolute path import('../../node_modules/.pnpm/vue@3.4.14_typescript@5.3.3/node_modules/vue')... this seems suspicious, and my tsconfig runs fast again if I replace it by the old value... I think I found my problem 😅

Here's a flame graph before and after replacing the paths: Screenshot 2024-01-18 at 15 38 20

SimonSimCity commented 5 months ago

Moved the discussion to the nuxt repo https://github.com/nuxt/nuxt/discussions/25257