Some fixes, still dealing with problems of illegal re-assignment in rollup.

This commit is contained in:
Michael Drury 2021-01-30 00:20:13 +00:00
parent 93a7abf160
commit 699046ccb8
7 changed files with 1866 additions and 155 deletions

View File

@ -26,7 +26,7 @@
"rollup-plugin-node-globals": "^1.4.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-svelte": "^6.1.1",
"rollup-plugin-terser": "^4.0.4",
"rollup-plugin-terser": "^7.0.2",
"svelte": "^3.30.0",
"svelte-jester": "^1.0.6"
},

View File

@ -2,6 +2,7 @@ import commonjs from "@rollup/plugin-commonjs"
import resolve from "@rollup/plugin-node-resolve"
import builtins from "rollup-plugin-node-builtins"
import svelte from "rollup-plugin-svelte"
import { terser } from "rollup-plugin-terser"
const production = !process.env.ROLLUP_WATCH
@ -25,6 +26,7 @@ export default {
}),
commonjs(),
builtins(),
production && terser(),
],
watch: {
clearScreen: false,

File diff suppressed because it is too large Load Diff

View File

@ -2,8 +2,9 @@
"name": "@budibase/string-templates",
"version": "0.6.2",
"description": "Handlebars wrapper for Budibase templating.",
"main": "dist/bundle.js",
"module": "dist/bundle.js",
"main": "src/index.js",
"module": "src/index.js",
"browser": "dist/bundle.js",
"license": "AGPL-3.0",
"types": "dist/index.d.ts",
"scripts": {
@ -27,6 +28,7 @@
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-globals": "^1.4.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-terser": "^7.0.2",
"typescript": "^4.1.3"
}
}

View File

@ -3,15 +3,17 @@ import resolve from "rollup-plugin-node-resolve"
import builtins from "rollup-plugin-node-builtins"
import globals from "rollup-plugin-node-globals"
import json from "@rollup/plugin-json"
import { terser } from "rollup-plugin-terser"
const production = !process.env.ROLLUP_WATCH
export default {
input: "src/index.js",
output: [
{
sourcemap: true,
format: "umd",
format: "es",
file: "./dist/bundle.js",
name: "string-templates",
name: "templates",
exports: "named",
},
],
@ -24,6 +26,7 @@ export default {
commonjs(),
globals(),
builtins(),
production && terser(),
json(),
],
}

View File

@ -20,6 +20,7 @@ function testObject(object) {
}
}
module.exports = {
/**
* Given an input object this will recurse through all props to try and update any handlebars statements within.
* @param {object|array} object The input structure which is to be recursed, it is important to note that
@ -27,7 +28,7 @@ function testObject(object) {
* @param {object} context The context that handlebars should fill data from.
* @returns {Promise<object|array>} The structure input, as fully updated as possible.
*/
module.exports.processObject = async (object, context) => {
processObject: async (object, context) => {
testObject(object)
for (let key of Object.keys(object)) {
if (object[key] != null) {
@ -40,7 +41,7 @@ module.exports.processObject = async (object, context) => {
}
}
return object
}
},
/**
* This will process a single handlebars containing string. If the string passed in has no valid handlebars statements
@ -49,10 +50,10 @@ module.exports.processObject = async (object, context) => {
* @param {object} context An object of information which will be used to enrich the string.
* @returns {Promise<string>} The enriched string, all templates should have been replaced if they can be.
*/
module.exports.processString = async (string, context) => {
processString: async (string, context) => {
// TODO: carry out any async calls before carrying out async call
return module.exports.processStringSync(string, context)
}
},
/**
* Given an input object this will recurse through all props to try and update any handlebars statements within. This is
@ -62,7 +63,7 @@ module.exports.processString = async (string, context) => {
* @param {object} context The context that handlebars should fill data from.
* @returns {object|array} The structure input, as fully updated as possible.
*/
module.exports.processObjectSync = (object, context) => {
processObjectSync: (object, context) => {
testObject(object)
for (let key of Object.keys(object)) {
let val = object[key]
@ -73,7 +74,7 @@ module.exports.processObjectSync = (object, context) => {
}
}
return object
}
},
/**
* This will process a single handlebars containing string. If the string passed in has no valid handlebars statements
@ -82,7 +83,7 @@ module.exports.processObjectSync = (object, context) => {
* @param {object} context An object of information which will be used to enrich the string.
* @returns {string} The enriched string, all templates should have been replaced if they can be.
*/
module.exports.processStringSync = (string, context) => {
processStringSync: (string, context) => {
let clonedContext = removeNull(cloneDeep(context))
clonedContext = addConstants(clonedContext)
// remove any null/undefined properties
@ -93,23 +94,23 @@ module.exports.processStringSync = (string, context) => {
// this does not throw an error when template can't be fulfilled, have to try correct beforehand
const template = hbsInstance.compile(string)
return processors.postprocess(template(clonedContext))
}
},
/**
* Simple utility function which makes sure that a templating property has been wrapped in literal specifiers correctly.
* @param {string} property The property which is to be wrapped.
* @returns {string} The wrapped property ready to be added to a templating string.
*/
module.exports.makePropSafe = property => {
makePropSafe: property => {
return `[${property}]`.replace("[[", "[").replace("]]", "]")
}
},
/**
* Checks whether or not a template string contains totally valid syntax (simply tries running it)
* @param string The string to test for valid syntax - this may contain no templates and will be considered valid.
* @returns {boolean} Whether or not the input string is valid.
*/
module.exports.isValid = string => {
isValid: string => {
const specialCases = ["isNumber", "expected a number"]
// don't really need a real context to check if its valid
const context = {}
@ -121,15 +122,15 @@ module.exports.isValid = string => {
const foundCase = specialCases.find(spCase => msg.includes(spCase))
// special case for maths functions - don't have inputs yet
return !!foundCase
}
}
},
/**
* We have generated a static manifest file from the helpers that this string templating package makes use of.
* 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.
*/
module.exports.getManifest = () => {
getManifest: () => {
return manifest
},
}

View File

@ -472,7 +472,7 @@
dependencies:
"@rollup/pluginutils" "^3.0.8"
"@rollup/pluginutils@^3.0.8":
"@rollup/pluginutils@^3.0.8", "@rollup/pluginutils@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b"
integrity sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==
@ -1311,6 +1311,16 @@ cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3:
inherits "^2.0.1"
safe-buffer "^5.0.1"
cjs-es@^0.8.2:
version "0.8.2"
resolved "https://registry.yarnpkg.com/cjs-es/-/cjs-es-0.8.2.tgz#3a4358f8cbc6caffcabf3282e5b56052cb1e7962"
integrity sha512-Z3AHuD0KH36hntFdT5M4c921ygkALhuRRaX8QyYhuOgoHBLeZItE5G3CMg/+m5NQ6b1revYp7Th2h6F8J56i2g==
dependencies:
estree-walker "^0.6.1"
is-reference "^1.1.2"
magic-string "^0.25.2"
rollup-pluginutils "^2.8.1"
cjs-module-lexer@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/cjs-module-lexer/-/cjs-module-lexer-0.6.0.tgz#4186fcca0eae175970aee870b9fe2d6cf8d5655f"
@ -1389,6 +1399,11 @@ combined-stream@^1.0.6, combined-stream@~1.0.6:
dependencies:
delayed-stream "~1.0.0"
commander@^2.20.0:
version "2.20.3"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
component-emitter@^1.2.1:
version "1.3.0"
resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0"
@ -1741,6 +1756,15 @@ error-symbol@^0.1.0:
resolved "https://registry.yarnpkg.com/error-symbol/-/error-symbol-0.1.0.tgz#0a4dae37d600d15a29ba453d8ef920f1844333f6"
integrity sha1-Ck2uN9YA0VopukU9jvkg8YRDM/Y=
es-info@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/es-info/-/es-info-0.3.0.tgz#d95a6c2a8f1f12ae07d9c8a51d99bd97562ac028"
integrity sha512-mcw8DZ6/PiZzT6lvwL5yUz9y1U8BJc4CLNsblFQwquc+VX0ByqzHgg/31smKU2LB2exlKAZXMABksL/F96Lhbw==
dependencies:
estree-walker "^0.6.1"
is-reference "^1.1.2"
rollup-pluginutils "^2.8.1"
escape-string-regexp@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
@ -3044,7 +3068,7 @@ jest-watcher@^26.6.2:
jest-util "^26.6.2"
string-length "^4.0.1"
jest-worker@^26.6.2:
jest-worker@^26.2.1, jest-worker@^26.6.2:
version "26.6.2"
resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-26.6.2.tgz#7f72cbc4d643c365e27b9fd775f9d0eaa9c7a8ed"
integrity sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ==
@ -3893,7 +3917,7 @@ qs@~6.5.2:
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"
integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==
randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5:
randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5, randombytes@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a"
integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==
@ -4109,6 +4133,15 @@ ripemd160@^2.0.0, ripemd160@^2.0.1:
hash-base "^3.0.0"
inherits "^2.0.1"
rollup-plugin-cjs-es@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/rollup-plugin-cjs-es/-/rollup-plugin-cjs-es-1.0.1.tgz#81c55e40d1e8b4f0c5bda1120f43723fae93517e"
integrity sha512-I8PUM9VCOEc1Kyyjuvg9PfVcxEFDu3eeA9OyzMgOpdDdrAUVSgkuqGzgqezyyBbxUfRFai7/n3TBpbM8iCNu7A==
dependencies:
"@rollup/pluginutils" "^3.1.0"
cjs-es "^0.8.2"
es-info "^0.3.0"
rollup-plugin-commonjs@^10.1.0:
version "10.1.0"
resolved "https://registry.yarnpkg.com/rollup-plugin-commonjs/-/rollup-plugin-commonjs-10.1.0.tgz#417af3b54503878e084d127adf4d1caf8beb86fb"
@ -4153,6 +4186,16 @@ rollup-plugin-node-resolve@^5.2.0:
resolve "^1.11.1"
rollup-pluginutils "^2.8.1"
rollup-plugin-terser@^7.0.2:
version "7.0.2"
resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz#e8fbba4869981b2dc35ae7e8a502d5c6c04d324d"
integrity sha512-w3iIaU4OxcF52UUXiZNsNeuXIMDvFrr+ZXK6bFZ0Q60qyVfq4uLptoS4bbq3paG3x216eQllFZX7zt6TIImguQ==
dependencies:
"@babel/code-frame" "^7.10.4"
jest-worker "^26.2.1"
serialize-javascript "^4.0.0"
terser "^5.0.0"
rollup-pluginutils@^2.3.1, rollup-pluginutils@^2.8.1:
version "2.8.2"
resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e"
@ -4243,6 +4286,13 @@ semver@~2.3.1:
resolved "https://registry.yarnpkg.com/semver/-/semver-2.3.2.tgz#b9848f25d6cf36333073ec9ef8856d42f1233e52"
integrity sha1-uYSPJdbPNjMwc+ye+IVtQvEjPlI=
serialize-javascript@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-4.0.0.tgz#b525e1238489a5ecfc42afacc3fe99e666f4b1aa"
integrity sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==
dependencies:
randombytes "^2.1.0"
set-blocking@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"
@ -4358,7 +4408,7 @@ source-map-resolve@^0.5.0:
source-map-url "^0.4.0"
urix "^0.1.0"
source-map-support@^0.5.6:
source-map-support@^0.5.6, source-map-support@~0.5.19:
version "0.5.19"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61"
integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==
@ -4381,7 +4431,7 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1:
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
source-map@^0.7.3:
source-map@^0.7.3, source-map@~0.7.2:
version "0.7.3"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383"
integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==
@ -4572,6 +4622,15 @@ terminal-link@^2.0.0:
ansi-escapes "^4.2.1"
supports-hyperlinks "^2.0.0"
terser@^5.0.0:
version "5.5.1"
resolved "https://registry.yarnpkg.com/terser/-/terser-5.5.1.tgz#540caa25139d6f496fdea056e414284886fb2289"
integrity sha512-6VGWZNVP2KTUcltUQJ25TtNjx/XgdDsBDKGt8nN0MpydU36LmbPPcMBd2kmtZNNGVVDLg44k7GKeHHj+4zPIBQ==
dependencies:
commander "^2.20.0"
source-map "~0.7.2"
source-map-support "~0.5.19"
test-exclude@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-6.0.0.tgz#04a8698661d805ea6fa293b6cb9e63ac044ef15e"