From 6dae8a83ec716decdb5dab851fc1b4dab98beacc Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 31 Mar 2021 19:07:09 +0100 Subject: [PATCH] Update string-templates to use a better node polyfill rollup plugin --- packages/string-templates/package.json | 5 ++-- packages/string-templates/rollup.config.js | 28 +++++++++++----------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 3c29eed5fe..1fe979d590 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -2,7 +2,7 @@ "name": "@budibase/string-templates", "version": "0.8.9", "description": "Handlebars wrapper for Budibase templating.", - "main": "dist/bundle.cjs", + "main": "src/index.cjs", "module": "dist/bundle.mjs", "license": "AGPL-3.0", "types": "dist/index.d.ts", @@ -32,9 +32,8 @@ "jest": "^26.6.3", "marked": "^2.0.0", "rollup": "^2.36.2", - "rollup-plugin-node-builtins": "^2.1.2", - "rollup-plugin-node-globals": "^1.4.0", "rollup-plugin-node-resolve": "^5.2.0", + "rollup-plugin-polyfill-node": "^0.6.2", "rollup-plugin-terser": "^7.0.2", "typescript": "^4.1.3" }, diff --git a/packages/string-templates/rollup.config.js b/packages/string-templates/rollup.config.js index a8fd48730f..3f41e4b006 100644 --- a/packages/string-templates/rollup.config.js +++ b/packages/string-templates/rollup.config.js @@ -2,8 +2,7 @@ import commonjs from "@rollup/plugin-commonjs" import resolve from "rollup-plugin-node-resolve" import json from "@rollup/plugin-json" import { terser } from "rollup-plugin-terser" -import builtins from "rollup-plugin-node-builtins" -import globals from "rollup-plugin-node-globals" +import polyfillNode from "rollup-plugin-polyfill-node" const production = !process.env.ROLLUP_WATCH @@ -13,8 +12,7 @@ const plugins = [ preferBuiltins: true, }), commonjs(), - builtins(), - globals(), + polyfillNode(), production && terser(), json(), ] @@ -29,14 +27,16 @@ export default [ }, plugins, }, - { - input: "src/index.cjs", - output: { - sourcemap: !production, - format: "cjs", - file: "./dist/bundle.cjs", - exports: "named", - }, - plugins, - }, + // This is the valid configuration for a CommonJS bundle, but since we have + // no use for this, it's better to leave it out. + // { + // input: "src/index.cjs", + // output: { + // sourcemap: !production, + // format: "cjs", + // file: "./dist/bundle.cjs", + // exports: "named", + // }, + // plugins, + // }, ]