Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/rewire.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Ewald <johannes.ewald@peerigon.com>2018-04-09 21:49:49 +0300
committerJohannes Ewald <johannes.ewald@peerigon.com>2018-04-09 22:00:59 +0300
commit9b77ed9a293c538ec3eb5160bcb933e012ce517f (patch)
tree9b3d93d4cedeeef376d54a412636b7c862229e6a /testLib/throwError.js
parentcbb2802ea5e30b47003298f2756c62ce20b41bb0 (diff)
Replace babel with a regex-based transformation
This regex replacement is not 100% safe because transforming JavaScript requires an actual parser. However, parsing (e.g. via babel) comes with its own problems because now the parser needs to be aware of syntax extensions which might not be supported by the parser, but the underlying JavaScript engine. In fact, rewire used to have babel in place but required an extra transform for the object spread operator (check out commit d9a81c0cdacf6995b24d205b4a2068adbd8b34ff or see https://github.com/jhnns/rewire/pull/128). It was also notable slower (see https://github.com/jhnns/rewire/issues/132). There is another issue: replacing const with let is not safe because of their different behavior. That's why we also have ESLint in place which tries to identify this error case. There is one edge case though: when a new syntax is used *and* a const re-assignment happens, rewire would compile happily in this situation but the actual code wouldn't work. However, since most projects have a seperate linting step which catches these const re-assignment errors anyway, it's probably still a reasonable trade-off. Fixes https://github.com/jhnns/rewire/issues/132
Diffstat (limited to 'testLib/throwError.js')
-rw-r--r--testLib/throwError.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/testLib/throwError.js b/testLib/throwError.js
index ffb6a71..e85ea36 100644
--- a/testLib/throwError.js
+++ b/testLib/throwError.js
@@ -1,4 +1,4 @@
-// Using const here because we know that Babel will transform that part
+// Using deliberately const here because we know that we're transform const to let
const test = 1;
module.exports = function () {