From e125b9905f524a1d5b005210f9e39a73bef92326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9e=20Kooi?= Date: Sat, 20 Jan 2018 18:30:42 +0100 Subject: [PATCH] Catch errors in statically evaluated expressions This will just not replace expressions that cannot be evaluated because of a runtime error. This is needed for https://github.com/browserify/brfs/pull/83 which fixes https://github.com/browserify/brfs/issues/81. --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 577984c..78de88c 100644 --- a/index.js +++ b/index.js @@ -308,7 +308,11 @@ module.exports = function parse (modules, opts) { }); if (callee !== undefined) { - res = callee.apply(null, args); + try { + res = callee.apply(null, args); + } catch (err) { + // Evaluate to undefined + } } }