-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Dev Experience + Bundler Overhaul + BBUI in monorepo #1361
Conversation
…oundwork for server proxying
…or dev experience through envoy.
… and removing builder security while auth is being worked on - added an option to start stack without server so that user can start it in a debug mode if desired.
Awesome work 🔥 - this makes life so much easier for everyone and makes the platform much easier to develop on. However I am seeing an issue when running on my branch:
When I hit localhost:10000/builder I'm getting:
Seems like it might just be something misconfigured in envoy and it can't reach the load balancer targets (getting 503). @kevmodrome is having the same issue. (Mac related maybe?) |
Ah - it appears to be the IP addresses added to the envoy config for dev.
This won't work on linux though 😖 |
Damn this is something I was worried about, finding some way for envoy to redirect requests outside of docker is quite difficult, its pretty abnormal behaviour for a docker environment. Wondering if we could do something like detect where the request came from with envoy and bounce the request back to that address but a different port... actually that probably won't work with virtual machines and running the browser etc outside the VM. I'm thinking what we might have to do is in the |
Found this: docker/for-linux#264 |
…the server can set builder token on.
Adding this to Envoy config in dev might be worth a try, i'll give it go locally, looks like its mentioned as a rough workaround? |
Codecov Report
@@ Coverage Diff @@
## next #1361 +/- ##
==========================================
- Coverage 84.83% 84.64% -0.19%
==========================================
Files 116 116
Lines 3191 3211 +20
Branches 415 417 +2
==========================================
+ Hits 2707 2718 +11
- Misses 230 239 +9
Partials 254 254
Continue to review full report at Codecov.
|
VERY hyped about this! Looks great @aptkingston 🥳 |
…not to be edited.
Cheers for the contributions to get this working cross-platform! |
Description
This PR adds BBUI to the monorepo, and totally overhauls the whole experience of developing Budibase.
This is pretty much impossible to review - but the best way would be to check it out and try it.
TLDR
/tmp
directorysvelte
keyword inpackage.json
) and bundle ithost:10000/builder
rather thanhost:4001/_builder
Dev setup
Currently we use a script
symlinkDev
to link our local packages together, and some of them had relative paths going outside of the package to reach another package (eg requesting../client
from thebuilder
package). Instead, lerna now links all dependencies together, which means that the packages in eachnode_modules
folders are actually symlinks to your version on disk. That means that you only need to worry about a single file path in dev or prod. As we don't publish the builder package, the builder still outputs production builds to the server package, but this is the only exception.lerna link
is the command that does this, and it's been added to both thebootstrap
command and also to top leveldev
command, to ensure everything is always linked.Bundlers
Currently we have rollup running inside the builder, BBUI, standard components, string templates and client. Each of these packages uses the built output of the others, and then recompiles when changes are detected. This means that making a change to
standard-components
causesstandard-components
to recompile, followed byclient
, followed bybuilder
, and finally the sever will reload. This takes anywhere from 20-60 seconds depending on the speed of your machine.Now, each package uses the source of the other packages and bundles it directly, cutting out the "middle men" bundlers. If you make a change to
standard-components
then theclient
directly picks that up and recompiles without any intermediate step of bundlingstandard-components
itself, reducing the overload load on the dev machine and the amount of time spent bundling.The builder, BBUI and standard components all use Vite now instead of rollup, although neither BBUI or standard component run any sort of dev server now - because the builder directly uses the source code. The builder does run a Vite dev server on port 3000, and envoy has been updated to proxy through to it.
budibase-client.js
and backwards compatibilityThe management and bundling of the client library is a tricky subject due to our requirements, but it's been simplified now. We require a separate client library to be built, so that apps can be versioned and maintained in the long term - otherwise we could simply bundle up the client inside the builder and be done with it.
Currently, the client library is bundled and symlinked to the
/tmp/.budibase
directory. The server then serves this latest version in dev, or serves the stored version for an app in prod. The server also has endpoints to serve the client library bundle to preview apps, and to serve the builder with component definitions of the client library. Currently these endpoints are not in sync, which means the component list that the builder gets is not always correct for the version of the client library that the app is using.With these changes, the client library is bundled as normal and no symlinking is required. Due to lerna symlinking all packages together automatically, the server can now reference the latest version of the client lib in its
node_modules
directory. The server also ensures that all endpoints referencing client library are in sync - that's to say that the version of the client library being served and the component definitions returned are always correct for the version of the client library. There is also a new client library bundle URL sent down in the app package. The builder injects this URL into the iframe preview - meaning that now you can actually develop an old app with the correct version of the client library, whereas previously the builder iframe preview and the builders component list always used the latest version of the client library.Here's how the client library versions are now handled:
All we need to implement now is a way to manually choose to update your client library version, and then we would be well on our way to properly supporting backwards compatibility - at least in terms of the client library.
Builder assets
Any builder assets can be properly imported into svelte files as needed, and they will be bundled with the builder. This also means that only the assets that are actually used are now bundled with the builder. This makes it much easier to also manage import paths to assets. For instance, here's how using an image now looks:
Previously all assets were imported in the
main.js
file, and things like images relied on using hardcoded URL's which were expected to exist at runtime.