1
0
Fork 0
mirror of synced 2024-07-03 21:40:55 +12:00

Fix requires

This commit is contained in:
Adria Navarro 2024-02-21 22:35:30 +01:00
parent 2339030fe2
commit 16ca7bbc45
2 changed files with 8 additions and 4 deletions

View file

@ -1,7 +1,7 @@
import { date, duration } from "./date"
// https://github.com/evanw/esbuild/issues/56
const externalCollections: Record<string, () => any> = {
const getExternalCollections = (): Record<string, () => any> => ({
math: require("@budibase/handlebars-helpers/lib/math"),
array: require("@budibase/handlebars-helpers/lib/array"),
number: require("@budibase/handlebars-helpers/lib/number"),
@ -11,7 +11,7 @@ const externalCollections: Record<string, () => any> = {
object: require("@budibase/handlebars-helpers/lib/object"),
regex: require("@budibase/handlebars-helpers/lib/regex"),
uuid: require("@budibase/handlebars-helpers/lib/uuid"),
}
})
export const helpersToRemoveForJs = ["sortBy"]
@ -28,7 +28,7 @@ export function getJsHelperList() {
}
helpers = {}
for (let collection of Object.values(externalCollections)) {
for (let collection of Object.values(getExternalCollections())) {
for (let [key, func] of Object.entries(collection)) {
// Handlebars injects the hbs options to the helpers by default. We are adding an empty {} as a last parameter to simulate it
helpers[key] = (...props) => func(...props, {})

View file

@ -1,9 +1,9 @@
import fs from "fs"
import { createContext, runInNewContext } from "vm"
import { create } from "handlebars"
import { registerAll, registerMinimum } from "./helpers/index"
import { preprocess, postprocess } from "./processors"
import { atob, btoa, isBackendService } from "./utilities"
const manifest = require("../manifest.json")
import {
FIND_HBS_REGEX,
FIND_ANY_HBS_REGEX,
@ -252,7 +252,11 @@ export function isValid(string, opts) {
* This manifest provides information about each of the helpers and how it can be used.
* @returns The manifest JSON which has been generated from the helpers.
*/
let manifest
export function getManifest() {
if (!manifest) {
manifest = fs.readFileSync(require.resolve("../manifest.json"), "utf-8")
}
return manifest
}