devtools icon indicating copy to clipboard operation
devtools copied to clipboard

Devtools make the build slow.

Open vovsemenv opened this issue 8 months ago • 6 comments

Describe the bug

Installed the vite devtools and my build time spikes from 3s to 4minutes.

Image

Vite config -

export default defineConfig({
  css: {
    transformer: "lightningcss",
    modules: {
      localsConvention: "camelCase",
    },
  },
  plugins: [
    DevTools(),
    babel({ presets: [decoratorPreset({ version: "2023-11" })] }),
    tailwindCss(),
    react(),
    {
      name: "inline-svg-spinner-to-html",
      transformIndexHtml: (html) =>
        html.replace(
          "%SVG_SPINNER_INLINE%",
          readFileSync(
            path.resolve(import.meta.dirname, "./icons/external/layout-loader-cis.svg"),
            "utf-8",
          ),
        ),
    },
    viteStaticCopy({
      targets: [...(isSandbox ? [] : swaggerStaticFiles)],
    }),
  ],
  resolve: {
    alias: {
      app: path.resolve(import.meta.dirname, "./src/main/javascript"),
      public: path.resolve(import.meta.dirname, "public"),
    },
  },
  define: {
    __IS_SANDBOX_BUILD__: isSandbox,
  },
  build: {
    outDir: path.resolve(process.cwd(), "build/resources/main/static"),
    assetsDir: ".",
    rollupOptions: {
      output: {
        /**
         * We have to change default chunkFileNames to avoid blocking Adblock.
         * Issue: https://github.com/rollup/rollup/issues/5374
         */
        chunkFileNames: "[name]-testops-[hash].js",
      },
      devtools: {},
    },
  },

Reproduction

missing

System Info

Ok to proceed? (y) 

  System:
    OS: macOS 26.3.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 95.36 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.14.1 - /Users/vladimirsemenov/.vite-plus/js_runtime/node/24.14.1/bin/node
    npm: 11.11.0 - /Users/vladimirsemenov/.vite-plus/js_runtime/node/24.14.1/bin/npm
    bun: 1.3.5 - /Users/vladimirsemenov/.bun/bin/bun
    Deno: 1.24.0 - /Users/vladimirsemenov/.deno/bin/deno
  Browsers:
    Chrome: 146.0.7680.165
    Firefox: 148.0
    Safari: 26.3.1

Used Package Manager

npm

Validations

  • [x] Follow our Code of Conduct
  • [x] Read the Contributing Guide.
  • [x] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • [x] Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • [x] The provided reproduction is a minimal reproducible of the bug.

vovsemenv avatar Mar 26 '26 13:03 vovsemenv

removed everything from the vite config and it looks like this now -


import { defineConfig } from "vitest/config";

export default defineConfig({
  build: {
    rollupOptions: { devtools: {} },
  },
});

the build still takes 3+ minutes so the problem must me inside the rolldownOptions.

My app have 9000 modules to transform

vovsemenv avatar Mar 26 '26 13:03 vovsemenv

Similar experience when trying out devtools:

  • 1120 modules
  • Regular build: 3s
  • With devtools: { enable: true }: 56s

Also I wonder what's the intended scenario for running them with respect to CI/CD? When you add devtools, the build does not stop but runs a local dev server. Do you detect non-interactive environments and automatically disable devtools?

Creating a dynamic Vite configuration (one plain build, one build with devtools) would be ideal IMHO but is a little tricky. The only built-in Vite property we can play with is mode but I already use it for something different. I feel like there should be a command line argument to pass arbitrary properties to Vite, which could be read from a new property on ConfigEnv. Right now the only way I see to achieve this is through env. variables, which are doable but more messy (esp. cross-plat.)

jods4 avatar Mar 26 '26 16:03 jods4

We're aware of the performance issues with DevTools on large projects and are planning to address it. This requires a refactor of the logging architecture on the Rolldown side, so it’ll take some time. Thanks for the feedback! /cc @sapphi-red

webfansplz avatar Mar 27 '26 03:03 webfansplz

Tracking issue on the Rolldown side: https://github.com/rolldown/rolldown/issues/5896

Rolldown team will be working on it in the upcoming months.

sapphi-red avatar Mar 27 '26 03:03 sapphi-red

Similar experience when trying out devtools:

  • 1120 modules
  • Regular build: 3s
  • With devtools: { enable: true }: 56s

Also I wonder what's the intended scenario for running them with respect to CI/CD? When you add devtools, the build does not stop but runs a local dev server. Do you detect non-interactive environments and automatically disable devtools?

Creating a dynamic Vite configuration (one plain build, one build with devtools) would be ideal IMHO but is a little tricky. The only built-in Vite property we can play with is mode but I already use it for something different. I feel like there should be a command line argument to pass arbitrary properties to Vite, which could be read from a new property on ConfigEnv. Right now the only way I see to achieve this is through env. variables, which are doable but more messy (esp. cross-plat.)

I think it's make sense to provide a global environment variable to disable devtools (e.g. VITE_DEVTOOLS_DISABLED) which that users can disable devtools easily in some environments (for example, in a monorepo environment, assuming the user has multiple vite projects, currently disabling needs to be handled separately). But considering that vite devtools (rolldown) can also run independently of vite, I think it would be better to handle this on the devtools side. WDYT? @antfu

webfansplz avatar Mar 27 '26 03:03 webfansplz

Fixed in Rolldown v1.0.0 and Vite 8.0.12

webfansplz avatar May 12 '26 04:05 webfansplz