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

fix: chunks are analysed multiple times #2541

Merged
merged 1 commit into from Apr 4, 2021

Conversation

rpetersen27
Copy link
Contributor

In my special case, I have 1500 entry points which will result in every file being analyzed multiple times by the 'vite:import-analysis' plugin. I am still not 100% convinced, that there is no endless loop but I was not able to find it or reproduce it with a smaller example.

You might ask: Why do you have 1500 entry points? That is, because I need to be able to still reference the source files in run-time, as I work on a platform with multiple plugins, that are only present during run-time. Therefore, we do not know, which files might be used by other plugins and therefore we provide any file as an entry point.

You can find an excerpt of our config below:

export default defineConfig({
  root: './src',
  build: {
    minify: 'esbuild',
    target: 'esnext',
    outDir: '../dist',
    emptyOutDir: true,
    polyfillDynamicImport: false,
    rollupOptions: {
      external: [
        '../../../oxguard/auth'
      ],
      input: { ... all files under src/ },
      output: {
        entryFileNames: '[name].js'
      }
    }
  },
  ...
})

We collect all the entry points with our own plugin.

Some interesting side-notes: The problem is, that if (and only if) we set the minify option to either 'esbuild' or 'terser', it seems like the build process gets stuck after the "generateChunks" messages. We had it run for like 15 Minutes and then aborted it. I tried to debug, whether there is some kind of endless loop, but I was not able to find it. If we switch off minification, the build runs just fine. If we add this fix, minification works as well.

I am not sure, whether this fix is applicable, but I would appreciate any help, that points me in the right direction.

@Shinigami92 Shinigami92 added the p3-minor-bug An edge case that only affects very specific usage (priority) label Mar 21, 2021
@patak-dev patak-dev merged commit 1451b78 into vitejs:main Apr 4, 2021
patak-dev added a commit that referenced this pull request Apr 25, 2021
@patak-dev
Copy link
Member

@Holorium we had to revert this PR because it created a regression after it was released in v2.2.0.
Check here #3144.
These were the issues: #3084 #3101
Could you create a new issue detailing the problem so we can track another solution? You could try to create another PR including some tests based on these issues so we avoid another regression. Thanks!

@rpetersen27
Copy link
Contributor Author

@patak-js Thanks for the feedback and sorry for the inconvenience with this fix. I created a new PR with more information and a new fix. See #3154

@rpetersen27 rpetersen27 deleted the prevent-duplicate-analysis branch April 26, 2021 08:50
TobiasMelen pushed a commit to TobiasMelen/vite that referenced this pull request May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants