1
0
Fork 0
mirror of synced 2024-06-27 02:20:35 +12:00

Fix bundling

This commit is contained in:
Adria Navarro 2024-03-21 11:28:06 +01:00
parent aed98cfaa4
commit a6d3840141

View file

@ -1,17 +1,30 @@
import { date, duration } from "./date"
import {
math,
array,
number,
url,
string,
comparison,
object,
regex,
uuid,
// @ts-expect-error
} from "@budibase/handlebars-helpers"
// https://github.com/evanw/esbuild/issues/56
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"),
url: require("@budibase/handlebars-helpers/lib/url"),
string: require("@budibase/handlebars-helpers/lib/string"),
comparison: require("@budibase/handlebars-helpers/lib/comparison"),
object: require("@budibase/handlebars-helpers/lib/object"),
regex: require("@budibase/handlebars-helpers/lib/regex"),
uuid: require("@budibase/handlebars-helpers/lib/uuid"),
})
const externalCollections = {
math,
array,
number,
url,
string,
comparison,
object,
regex,
uuid,
}
export const helpersToRemoveForJs = ["sortBy"]
@ -28,8 +41,8 @@ export function getJsHelperList() {
}
helpers = {}
for (let collection of Object.values(getExternalCollections())) {
for (let [key, func] of Object.entries(collection)) {
for (let collection of Object.values(externalCollections)) {
for (let [key, func] of Object.entries<any>(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: any) => func(...props, {})
}