From 0cf7845650cb1a730fc438399d14170e2dbdc145 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 7 Sep 2022 08:48:29 +0100 Subject: [PATCH] Inject process env vars into ES6 bundle to fix crash --- packages/string-templates/package.json | 1 + packages/string-templates/rollup.config.js | 4 ++++ packages/string-templates/yarn.lock | 23 ++++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 329d78894d..4eca9f1081 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -39,6 +39,7 @@ "jest": "^26.6.3", "marked": "^4.0.10", "rollup": "^2.36.2", + "rollup-plugin-inject-process-env": "^1.3.1", "rollup-plugin-node-builtins": "^2.1.2", "rollup-plugin-node-globals": "^1.4.0", "rollup-plugin-node-resolve": "^5.2.0", diff --git a/packages/string-templates/rollup.config.js b/packages/string-templates/rollup.config.js index 5625f8180c..d7f45489c9 100644 --- a/packages/string-templates/rollup.config.js +++ b/packages/string-templates/rollup.config.js @@ -4,6 +4,7 @@ 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 injectProcessEnv from "rollup-plugin-inject-process-env" const production = !process.env.ROLLUP_WATCH @@ -24,6 +25,9 @@ export default [ globals(), builtins(), json(), + injectProcessEnv({ + NO_JS: process.env.NO_JS, + }), production && terser(), ], }, diff --git a/packages/string-templates/yarn.lock b/packages/string-templates/yarn.lock index 7647fa1928..dc7e8f1852 100644 --- a/packages/string-templates/yarn.lock +++ b/packages/string-templates/yarn.lock @@ -568,6 +568,15 @@ magic-string "^0.25.7" resolve "^1.17.0" +"@rollup/plugin-inject@^4.0.0": + version "4.0.4" + resolved "https://registry.yarnpkg.com/@rollup/plugin-inject/-/plugin-inject-4.0.4.tgz#fbeee66e9a700782c4f65c8b0edbafe58678fbc2" + integrity sha512-4pbcU4J/nS+zuHk+c+OL3WtmEQhqxlZ9uqfjQMQDOHOPld7PsCd8k5LWs8h5wjwJN7MgnAn768F2sDxEP4eNFQ== + dependencies: + "@rollup/pluginutils" "^3.1.0" + estree-walker "^2.0.1" + magic-string "^0.25.7" + "@rollup/plugin-json@^4.1.0": version "4.1.0" resolved "https://registry.yarnpkg.com/@rollup/plugin-json/-/plugin-json-4.1.0.tgz#54e09867ae6963c593844d8bd7a9c718294496f3" @@ -3747,6 +3756,13 @@ ripemd160@^2.0.0, ripemd160@^2.0.1: hash-base "^3.0.0" inherits "^2.0.1" +rollup-plugin-inject-process-env@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/rollup-plugin-inject-process-env/-/rollup-plugin-inject-process-env-1.3.1.tgz#2d7660fe76f2b221b976cb35597763ffcaad3db3" + integrity sha512-kKDoL30IZr0wxbNVJjq+OS92RJSKRbKV6B5eNW4q3mZTFqoWDh6lHy+mPDYuuGuERFNKXkG+AKxvYqC9+DRpKQ== + dependencies: + magic-string "^0.25.7" + rollup-plugin-node-builtins@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/rollup-plugin-node-builtins/-/rollup-plugin-node-builtins-2.1.2.tgz#24a1fed4a43257b6b64371d8abc6ce1ab14597e9" @@ -3780,6 +3796,13 @@ rollup-plugin-node-resolve@^5.2.0: resolve "^1.11.1" rollup-pluginutils "^2.8.1" +rollup-plugin-polyfill-node@^0.10.2: + version "0.10.2" + resolved "https://registry.yarnpkg.com/rollup-plugin-polyfill-node/-/rollup-plugin-polyfill-node-0.10.2.tgz#b2128646851fcb9475ddfd5bc22ca1a8c568738d" + integrity sha512-5GMywXiLiuQP6ZzED/LO/Q0HyDi2W6b8VN+Zd3oB0opIjyRs494Me2ZMaqKWDNbGiW4jvvzl6L2n4zRgxS9cSQ== + dependencies: + "@rollup/plugin-inject" "^4.0.0" + 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"