1
0
Fork 0
mirror of synced 2024-06-12 15:34:54 +12:00

Add readme

This commit is contained in:
Adria Navarro 2024-02-06 10:18:58 +01:00
parent 719062ab2f
commit 792283d8b5
5 changed files with 19 additions and 4 deletions

View file

@ -13,7 +13,7 @@
"build": "node ./scripts/build.js",
"postbuild": "copyfiles -f ../client/dist/budibase-client.js ../client/manifest.json client && copyfiles -f ../../yarn.lock ./dist/",
"check:types": "tsc -p tsconfig.json --noEmit --paths null",
"build:isolated-vm-lib:string-templates": "esbuild --minify --bundle src/jsRunner/bundles/index-helpers.ts --outfile=src/jsRunner/bundles/index-helpers.ivm.bundle.js.txt --platform=node --format=esm --external:handlebars",
"build:isolated-vm-lib:string-templates": "esbuild --minify --bundle src/jsRunner/bundles/index-helpers.ts --outfile=src/jsRunner/bundles/index-helpers.ivm.bundle.js --platform=node --format=esm --external:handlebars",
"build:isolated-vm-libs": "yarn build:isolated-vm-lib:string-templates",
"build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput",
"debug": "yarn build && node --expose-gc --inspect=9222 dist/index.js",

View file

@ -0,0 +1,15 @@
# Bundles for isolated-vm
[Isolated-vm](https://github.com/laverdet/isolated-vm) requires for us to have some libraries, such as string-templates helpers, built in a single file without external dependencies. These libraries are pretty much static. To avoid building this in every dev command, in every test command and in every pipeline, these libraries are already compiled and commited into the repo.
## How are they consumed?
These libaries are compiled with a special extension: .ivm.bundle.js. This extension is configured in [esbuild](/scripts/build.js) in order to not be bundled as javascript, and to be treated as a `string` instead. This will allow us to read it's context on runtime and inject it to `isolated-vm`.
## How to update it?
These libraries are pretty much static, but they might require some updates from time to time when something changes on the source code. In order to do this, we just need to run the following command and commit the updated bundles:
```
yarn build:isolated-vm-libs
```

View file

@ -7,7 +7,7 @@ import url from "url"
import crypto from "crypto"
import querystring from "querystring"
const helpersSource = require("./bundles/index-helpers.ivm.bundle.js.txt")
const helpersSource = require("./bundles/index-helpers.ivm.bundle.js")
class ExecutionTimeoutError extends Error {
constructor(message: string) {

View file

@ -49,7 +49,7 @@ function runBuild(entry, outfile) {
preserveSymlinks: true,
loader: {
".svelte": "copy",
".ivm.bundle.js.txt": "text",
".ivm.bundle.js": "text",
},
metafile: true,
external: [
@ -61,7 +61,7 @@ function runBuild(entry, outfile) {
"bcrypt",
"bcryptjs",
"graphql/*",
"bson"
"bson",
],
}