Remove index.cjs entry point

This commit is contained in:
Adria Navarro 2024-02-09 10:27:22 +01:00
parent 34edf19965
commit ec7adfb1b1
11 changed files with 11 additions and 54 deletions

View File

@ -2,13 +2,13 @@
"name": "@budibase/string-templates", "name": "@budibase/string-templates",
"version": "0.0.0", "version": "0.0.0",
"description": "Handlebars wrapper for Budibase templating.", "description": "Handlebars wrapper for Budibase templating.",
"main": "src/index.cjs", "main": "src/index.js",
"module": "dist/bundle.mjs", "module": "dist/bundle.mjs",
"license": "MPL-2.0", "license": "MPL-2.0",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
"exports": { "exports": {
".": { ".": {
"require": "./src/index.cjs", "require": "./src/index.js",
"import": "./dist/bundle.mjs" "import": "./dist/bundle.mjs"
}, },
"./package.json": "./package.json", "./package.json": "./package.json",

View File

@ -4,7 +4,7 @@ const { LITERAL_MARKER } = require("../helpers/constants")
const { getJsHelperList } = require("./list") const { getJsHelperList } = require("./list")
// The method of executing JS scripts depends on the bundle being built. // The method of executing JS scripts depends on the bundle being built.
// This setter is used in the entrypoint (either index.cjs or index.mjs). // This setter is used in the entrypoint (either index.js or index.mjs).
let runJS let runJS
module.exports.setJSRunner = runner => (runJS = runner) module.exports.setJSRunner = runner => (runJS = runner)

View File

@ -1,43 +0,0 @@
const templates = require("./index.js")
/**
* CJS entrypoint for rollup
*/
module.exports.isValid = templates.isValid
module.exports.makePropSafe = templates.makePropSafe
module.exports.getManifest = templates.getManifest
module.exports.isJSBinding = templates.isJSBinding
module.exports.encodeJSBinding = templates.encodeJSBinding
module.exports.decodeJSBinding = templates.decodeJSBinding
module.exports.processStringSync = templates.processStringSync
module.exports.processObjectSync = templates.processObjectSync
module.exports.processString = templates.processString
module.exports.processObject = templates.processObject
module.exports.doesContainStrings = templates.doesContainStrings
module.exports.doesContainString = templates.doesContainString
module.exports.disableEscaping = templates.disableEscaping
module.exports.findHBSBlocks = templates.findHBSBlocks
module.exports.convertToJS = templates.convertToJS
module.exports.setJSRunner = templates.setJSRunner
module.exports.FIND_ANY_HBS_REGEX = templates.FIND_ANY_HBS_REGEX
module.exports.helpersToRemoveForJs = templates.helpersToRemoveForJs
if (!process.env.NO_JS) {
const { VM } = require("vm2")
const { setJSRunner } = require("./helpers/javascript")
/**
* Use vm2 to run JS scripts in a node env
*/
setJSRunner((js, context) => {
const vm = new VM({
sandbox: context,
timeout: 1000,
})
return vm.run(js)
})
}
const errors = require("./errors")
for (const error in errors) {
module.exports[error] = errors[error]
}

View File

@ -8,7 +8,7 @@ const {
doesContainString, doesContainString,
disableEscaping, disableEscaping,
findHBSBlocks, findHBSBlocks,
} = require("../src/index.cjs") } = require("../src/index.js")
describe("Test that the string processing works correctly", () => { describe("Test that the string processing works correctly", () => {
it("should process a basic template string", async () => { it("should process a basic template string", async () => {

View File

@ -1,4 +1,4 @@
const { processString } = require("../src/index.cjs") const { processString } = require("../src/index.js")
describe("Handling context properties with spaces in their name", () => { describe("Handling context properties with spaces in their name", () => {
it("should allow through literal specifiers", async () => { it("should allow through literal specifiers", async () => {

View File

@ -1,4 +1,4 @@
const { convertToJS } = require("../src/index.cjs") const { convertToJS } = require("../src/index.js")
function checkLines(response, lines) { function checkLines(response, lines) {
const toCheck = response.split("\n") const toCheck = response.split("\n")

View File

@ -1,4 +1,4 @@
const { processString, processObject, isValid } = require("../src/index.cjs") const { processString, processObject, isValid } = require("../src/index.js")
const tableJson = require("./examples/table.json") const tableJson = require("./examples/table.json")
const dayjs = require("dayjs") const dayjs = require("dayjs")
const { UUID_REGEX } = require("./constants") const { UUID_REGEX } = require("./constants")

View File

@ -1,4 +1,4 @@
const { processStringSync, encodeJSBinding } = require("../src/index.cjs") const { processStringSync, encodeJSBinding } = require("../src/index.js")
const { UUID_REGEX } = require("./constants") const { UUID_REGEX } = require("./constants")
const processJS = (js, context) => { const processJS = (js, context) => {

View File

@ -15,7 +15,7 @@ jest.mock("@budibase/handlebars-helpers/lib/uuid", () => {
} }
}) })
const { processString } = require("../src/index.cjs") const { processString } = require("../src/index.js")
const tk = require("timekeeper") const tk = require("timekeeper")
const { getParsedManifest, runJsHelpersTests } = require("./utils") const { getParsedManifest, runJsHelpersTests } = require("./utils")

View File

@ -1,4 +1,4 @@
const { processString } = require("../src/index.cjs") const { processString } = require("../src/index.js")
describe("specific test case for whether or not full app template can still be rendered", () => { describe("specific test case for whether or not full app template can still be rendered", () => {
it("should be able to render the app template", async () => { it("should be able to render the app template", async () => {

View File

@ -5,7 +5,7 @@ const {
convertToJS, convertToJS,
processStringSync, processStringSync,
encodeJSBinding, encodeJSBinding,
} = require("../src/index.cjs") } = require("../src/index.js")
function tryParseJson(str) { function tryParseJson(str) {
if (typeof str !== "string") { if (typeof str !== "string") {