Fix bundling

This commit is contained in:
Adria Navarro 2024-03-21 11:28:06 +01:00
parent aed98cfaa4
commit a6d3840141
1 changed files with 26 additions and 13 deletions

View File

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