oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.34k stars 2.78k forks source link

vite + vue takes up too much memory #15294

Open aquinary opened 1 day ago

aquinary commented 1 day ago

What version of Bun is running?

1.1.36

What platform is your computer?

Linux 6.6.52 x86_64 unknown

What steps can reproduce the bug?

I use this guide: https://bun.sh/guides/ecosystem/vite And install element-plus:

bun add element-plus unplugin-vue-components unplugin-auto-import
// main.ts
import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'

const app = createApp(App)

app.use(ElementPlus)
app.mount('#app')

Add volar support

// tsconfig.json
{
  "compilerOptions": {
    // ...
    "types": ["element-plus/global"]
  }
}
// vite.config.ts
import { defineConfig } from 'vite'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

export default defineConfig({
  // ...
  plugins: [
    // ...
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
})

restart vite server

What is the expected behavior?

Fast start-up, appropriate consumption RAM

What do you see instead?

I wait 2-3 minutes. In btop, I see how the node process loads 1 core by 100% (sometimes 2 by 50%). The amount of memory used is constantly increasing until it falls off. And only after that I can open 127.0.0.1:5172

Additional information

I tried to repeat 1 in 1 with deno, and everything works fine there. It starts up quickly, does not load the processor and takes up less memory Image

aquinary commented 1 day ago

Well... I repeated this for deno. The gist is this: I use .envrc and flake.nix to deploy a working environment in a specific directory. In it I run the command bun create vite.

The structure looks like this:

project
  .envrc
  flake.nix
  src/ // vue source
 ... and other files, кwhich were generated by the command  `bun create vite .`

And unfortunately this leads to my problem. In this case, the problem occurs IMMEDIATELY, on a clean installation, without any dependencies (regardless of whether it is bun or deno) If I use the bun create vite project subdirectory, then everything is ok. However, this results in unnecessary nesting of directories, which is not desirable for me (project/project disgusting). At the same time, I also cannot refuse flake.nix.

aquinary commented 1 day ago

I also repeated this trick with pure nodejs