Bud is compiling very slow

I’m using Laragon on my Windows machine and figuring out why Bud is taking too much time to compile on WSL2 with a clean Bedrock and Sage install. I’ve read a lot of topics about it, but they haven’t worked for me. I was trying to switch to Laravel Mix, because Bud is pushing me to learn the new way with Sage 10 and can’t get it to work.

I saw that Sage 10 beta 1 was working with Laravel Mix, so I tried to implement Mix to the current version of Sage, but I got Symfony errors that the manifest.json file was not found.

I’m also getting errors proxying to localhost:3000 and I saw that a topic was already created about this (Yarn dev error with bud), but on Bud 5.7.6. I’m getting the same error. I have tried to switch permanently to BrowserSync and that was compiling fine, but localhost:3000 kept loading after it.

yarn run v1.22.18
$ bud dev
[99%] [done] MultiCompiler plugins

┌ assets ─────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                                                                                 │
│                                                                                                                 │
│  ✔    app                      app.js                      64.98 kB                                             │
│  ✔    editor                   editor.js                   55.96 kB                                             │
│  ✔    vendor/bud.app.editor    vendor/bud.app.editor.js    50.23 kB                                             │
│  ✔    ᠃                        manifest.json               113 bytes                                            │
│  ✔    ᠃                        entrypoints.json            109 bytes                                            │
│  ✔    ᠃                        wordpress.json              33 bytes                                             │
│                                                                                                                 │
│                                                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
 duration    41s 215ms

 mode    development    hash       86ed3a1be2de59e2f4d7
 bud     5.7.6          webpack    5.70.0

 server url:    http://localhost:3000/
 proxy url:     http://bedrock.test/


[proxy] › ✖  [HPM] Error occurred while proxying request localhost:3000/ to http://bedrock.test/ [ECONNREFUSED] (https:/[proxy] › ✖  [HPM] Error occurred while proxying request localhost:3000/favicon.ico to http://bedrock.test/ [ECONNREFUSED] (https://nodejs.org/api/errors.html#errors_common_system_errors)

Not a solution to the slow compilation on your machine, but if you do want to go down the Mix route, this might be worth checking out: Sage 10 with Laravel Mix instead of Bud

Yes, I saw that topic too, but that is not the final version of it I think. You need to manually add the entrypoints.json and manifest.json to the public folder or you will get an error from Symfony Encore that the manifest.json isn’t found.

It would be nice if I only use Mix for compiling and not Symfony Encore.

Hey there, I’m the creator of the laravel mix package.
I already added the manifest.json as well as the entrypoints.json to the latest versions, so it should now work.

Compilation works without symfony encore, however if you split it up in multiple files, you have to update the entrypoints.json file manually.

Hi @patrickzach! Thanks for the package. I have also tried to create my own Mix package with the current version of Sage. The beta 1 version of Sage was using it, so I tried to copy the webpack.mix.js and package.json config to it, but it seems not to work. I want to update Sage when I create a new project and try to understand how I can replace Bud with Laravel Mix.

The package you made requires manifest.json and entrypoints.json that are automatically created with Symfony Encore, so this still exists. What I want is only Mix. Like @lgt said in the topic, you will get an error in setup.php because Symfony Encore is expects a entrypoints.json. See below:

add_action('wp_enqueue_scripts', function () {
    bundle('app')->enqueue();
}, 100);

That is not what I want. I just want to use Laravel Mix for my entire project, so I’m trying to figure that out. Bud is pushing me to learn the new framework, but the compile time is way to slow on my machine. I still want to explore it, but also can’t figure that out. Maybe that you have a solution for me, @kellymears?

I have tried to copy the Laravel Mix config from the beta 1 of Sage like I said, but somehow it also asks for manifest.json and entrypoints.json.

It’s impossible to help figure out why your build is slow with the provided information. Can you provide a repo that reproduces your slow build? I know there are WSL users who are using bud without issue.

✖  [HPM] Error occurred while proxying request localhost:3000/ to http://bedrock.test/ [ECONNREFUSED]

Is bedrock.test accessible? http-proxy-middleware says its not.

From the environment where bud is running what is this output?

curl http://bedrock.test -i -s | sed -n 1,5p

You know how to complain that the proxy server is still running even though you are using browsersync. But, do you know how to disable the proxy server?

bud.proxy(false)

Hi @kellymears, thank you for your reply. First of all let’s make something clear that I’m just figuring out why is it so slow and not complaining :slight_smile: besides that I have figured a way to use Laravel Mix without Bud, but instead of changing this I want to use Bud how it is setup in Sage10.

I have also tested my Laravel Mix variant on powershell and wsl2. It looks like there is something wrong with my wsl2 installation, because it takes 5.4s to compile while powershell compiles it in 910ms. For the first 10 seconds it looks like wsl2 is stuck with compiling and compiles a little bit after that, so normally it takes more than 5.4s. It is the same with powershell, but a little bit faster.

Yes, bedrock.test is accessible.

Nothing :slightly_smiling_face:

I have a fresh installation of Sage10 and changed only the bud.config.js file with proxy and serve. I have tested several times with a new installation, but it gives me the same result.

The very first of time yarn build gives me this:

yarn run v1.22.18
$ bud build
[99%] [cache] begin idle

┌ assets ─────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                                                                                 │
│                                                                                                                 │
│  ⚡    app        app.521c12.css       4.03 kB                                                                  │
│  ⚡    runtime    runtime.194772.js    1.24 kB                                                                  │
│  ⚡    editor     editor.5f39da.js     769 bytes                                                                │
│  ⚡    app        app.f5abda.js        623 bytes                                                                │
│  ⚡    editor     editor.31d6cf.css    0 bytes                                                                  │
│        ᠃          manifest.json        171 bytes                                                                │
│  ✔     ᠃          entrypoints.json     162 bytes                                                                │
│  ✔     ᠃          wordpress.json       33 bytes                                                                 │
│                                                                                                                 │
│                                                                                                                 │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
 duration    72s 378ms (22s 826ms + 49s 552ms)

 mode    production    hash       ae5ae51fbdbb41f02e06
 bud     5.7.6         webpack    5.70.0

[99%] [cache] shutdown

Done in 110.33s.

One thing that’s interesting is your overall build duration shows that literally the entire build is slow:

72s 378ms (22s 826ms + 49s 552ms)

The first parenthetical number (22s) is bud’s pre-compilation timing. The second (49s) is the actual webpack compilation. In relation to one another, these two numbers seem about right (without caching bud takes about 1/2 the time webpack does).

Once bud has passed the config to webpack it’s pretty much done (when running bud build, at least). So, it’s like an across-the-board slowness. It doesn’t seem like there is a hotspot to debug.

So, my next question: is there any type of throttling happening? There are two key differences between mix and bud which may be relevant here, in my mind:

  • mix is almost 100% synchronous while bud is almost 100% asynchronous
  • bud writes to disk a great deal more than mix does

If you have a system monitoring utility you can tap in the context of the VM I wonder what the disk and RAM usage looks like…

Hi @kellymears, I’ve (finally) figured it out. It has to do with WSL2, because the performance across OS file systems is too slow. Instead in WSL1 it works fine.

I also have installed a clean Bedrock + Sage installation on WSL2 and tested Bud and in fact it was fast, but my problem isn’t solved here. I’m looking for a way like Laragon on my Windows machine and want to use the same setup (or an alternative) in WSL2, because it automatically creates everything like database, pretty url, etc. I can’t - so far I know - do that on WSL2. I’ve also seen posts with Docker and want to give it a try, but I think I will face a problem for every project I’m developing on, because each project has it’s own container and so on, but it is a good option for Windows.

So basically I want to use Sage, but without Bud and I don’t want to replace that with another like Mix or Vite, because I think Sage has some configuration files with Bud and I don’t want to touch them. I want to know how others are using Roots on Windows. Do you know that maybe?

@dogukale: I would recommend that you put the source code onto the Linux file system (~/src/) and use GitLab or another Git repository to push your changes onto it. It works great with VSCode (it integrates git and XDebug seamlessly). This solves all performance issues for me.

1 Like

Hi @strarsis! Yes, I know :slight_smile: But how do you do deal with stuff like php, node, mysql, live server, etc? I assume that you install that separetely and set it for each project. This is in fact a way to do it, but I’m looking for a more flexible way.

With Laragon on Windows it is just 1 click and it sets everything up for me. It has installed the things that I wrote above. It also writes a custom url in the host file. I only create a folder in the www folder and restart Laragon. That’s all. It would be nice if there is a solution like this for WSL2.

WSL 2 + Docker for Desktop + VSCode is the dream team here, fully integrated and everything.

Edit: You may want to look for a WSL (2) WordPress container or server, luckily support for WSL should be good now for these tools.

1 Like

Ah, so to be sure you have installed the requirements like php, node, etc. with a Docker image, not in WSL2? Do you have placed the project in WSL2 or Windows btw?

So the tools for development can be either installed as Docker containers or directly on the WSL system. For me this would be overkill in some cases, so I installed node using nvm directly and also the PHP CLI (can be switched using update-alternatives), mainly used for composer, can usually also be directly used on the system, as long as the PHP version is similar enough (composer uses the PHP version as kind of reference for compatibility).

But the server part, PHP-FPM + nginx + MariaDB would run in a docker compose setup.
You can either set this up yourself or you can choose from existing GitHub repos that have those setups.
(Like that PHP-FPM Bedrock image, as this one GitHub - strarsis/docker-php-bedrock: Docker image for PHP with roots.io Bedrock)

Thanks for that, I will give it a try!