Add readme
This commit is contained in:
parent
719062ab2f
commit
792283d8b5
|
@ -13,7 +13,7 @@
|
||||||
"build": "node ./scripts/build.js",
|
"build": "node ./scripts/build.js",
|
||||||
"postbuild": "copyfiles -f ../client/dist/budibase-client.js ../client/manifest.json client && copyfiles -f ../../yarn.lock ./dist/",
|
"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",
|
"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:isolated-vm-libs": "yarn build:isolated-vm-lib:string-templates",
|
||||||
"build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput",
|
"build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput",
|
||||||
"debug": "yarn build && node --expose-gc --inspect=9222 dist/index.js",
|
"debug": "yarn build && node --expose-gc --inspect=9222 dist/index.js",
|
||||||
|
|
|
@ -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
|
||||||
|
```
|
|
@ -7,7 +7,7 @@ import url from "url"
|
||||||
import crypto from "crypto"
|
import crypto from "crypto"
|
||||||
import querystring from "querystring"
|
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 {
|
class ExecutionTimeoutError extends Error {
|
||||||
constructor(message: string) {
|
constructor(message: string) {
|
||||||
|
|
|
@ -49,7 +49,7 @@ function runBuild(entry, outfile) {
|
||||||
preserveSymlinks: true,
|
preserveSymlinks: true,
|
||||||
loader: {
|
loader: {
|
||||||
".svelte": "copy",
|
".svelte": "copy",
|
||||||
".ivm.bundle.js.txt": "text",
|
".ivm.bundle.js": "text",
|
||||||
},
|
},
|
||||||
metafile: true,
|
metafile: true,
|
||||||
external: [
|
external: [
|
||||||
|
@ -61,7 +61,7 @@ function runBuild(entry, outfile) {
|
||||||
"bcrypt",
|
"bcrypt",
|
||||||
"bcryptjs",
|
"bcryptjs",
|
||||||
"graphql/*",
|
"graphql/*",
|
||||||
"bson"
|
"bson",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue