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

Vite 3.0.8 compatibility #124

Closed
maxstue opened this issue Aug 17, 2022 · 6 comments
Closed

Vite 3.0.8 compatibility #124

maxstue opened this issue Aug 17, 2022 · 6 comments
Labels
bug need info Incomplete bug report

Comments

@maxstue
Copy link

maxstue commented Aug 17, 2022

Hi

After upgrading to Vite 3.0.8 i encountered a problem.

Rollup/vite config:

import { defineConfig, loadEnv, PluginOption } from 'vite';
import react from '@vitejs/plugin-react';
import { visualizer } from 'rollup-plugin-visualizer';

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, process.cwd(), '');

  return {
    resolve: {
      preserveSymlinks: true,
      alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url)),
      },
    },
    define: {
      APP_VERSION: JSON.stringify(env.npm_package_version),
    },
    build: {
      emptyOutDir: true,
      sourcemap: mode !== 'production',
    },
   // ...
    plugins: [
      react(),
      // ...
      visualizer({
        brotliSize: true,
        gzipSize: true,
        template: 'treemap',
        filename: 'stats/rollup-stats.html',
        title: 'D-Main - Rollup (Build) stats',
      }),
    ],
  };
});

Versions and OS:

  • macbook pro m1 macos 12.5
  • vite: 3.0.8
  • rollup-plugin-visualizer: 5.7.1

Error:

  • Type '(PluginOption[] | Plugin)[]' is not assignable to type 'PluginOption[]'.

If I remove "visualizer(...)" or cast it as "PluginOption" than the error goes away.
This error occurred only after upgrading from 3.0.1 to 3.0.8

Is this rollup plugin not compatible anymore with the newest version?

@btd
Copy link
Owner

btd commented Aug 18, 2022

Hi, i personally have not tried yet vite 3. Would you mind to prepare small repro case that i can just run?

@btd btd added bug need info Incomplete bug report labels Aug 18, 2022
@maxstue
Copy link
Author

maxstue commented Aug 19, 2022

@btd I couldn't reproduce it on stackblitz so I created a GitHub repository
https://github.com/maxstue/rollup-vite-repro

It uses pnpm but I think that shouldn't matter because on my project where I encountered the problem first I use yarn.

@zmrl010
Copy link

zmrl010 commented Aug 19, 2022

I had this problem the other day with another plugin after upgrade to vite 3.08. In my case, it was caused by a change in type signature that rollup uses found in 2.78:

rollup/rollup#4600

My solution for now was to pin rollup to 2.77.3 until vite can update their type defs (I believe this is planned for 3.1).

Typedef changes like this should be breaking IMO

@btd
Copy link
Owner

btd commented Aug 20, 2022

@zmrl010 seems right, i will wait until vite 3.1. As workaround just cast to PluginOptions or pin rollup to 2.77.3

@btd btd pinned this issue Aug 20, 2022
@btd
Copy link
Owner

btd commented Aug 30, 2022

I looked on repro case that was provided, it seems at least npm install 2 rollups:

npm ls rollup      
test-rollup@0.0.0 /home/den/rollup-vite-repro
├─┬ rollup-plugin-visualizer@5.8.0
│ └── rollup@2.78.1
└─┬ vite@3.0.9
  └── rollup@2.77.3

In this plugin peer dependencies is set rollup >= 2, but in some reason it seem it means take the last from rollup. In this case it appeared 2 set of types. We will see what 3.1 will bring, by idea if they will stop limit upper version it should be fixed

@btd
Copy link
Owner

btd commented Sep 3, 2022

I added rollup to be optional peer dependency and it seems fixed the issue (need to drop node modules and lock file)

npm ls rollup
test-rollup@0.0.0 /home/den/rollup-vite-repro
├─┬ rollup-plugin-visualizer@5.8.1
│ └── rollup@2.77.3
└─┬ vite@3.0.9
  └── rollup@2.77.3 deduped

@btd btd closed this as completed Sep 3, 2022
@btd btd unpinned this issue Sep 3, 2022
@btd btd mentioned this issue May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug need info Incomplete bug report
Projects
None yet
Development

No branches or pull requests

3 participants