Fix requires
This commit is contained in:
parent
2339030fe2
commit
16ca7bbc45
|
@ -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, {})
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue