From 5358037aa3ca9efd1b5e097d63a37f7dd54d23ad Mon Sep 17 00:00:00 2001 From: Daniel X Moore Date: Mon, 4 Apr 2022 11:37:40 -0700 Subject: [PATCH] Remove always true if This check has always been true since Node 0.3.0. It was added here: https://github.com/jashkenas/coffeescript/commit/c4a3e170e230d7bf0a2513c1224d71f685dafb43 and seems to rely on the behavior of `Module#_compile` from before `require.extensions`. If `require.extensions` is ever removed (it is deprecated after all) then `CoffeeScript.run` will no longer work. It will pass CoffeeScript source code to `Module#_compile` which is doomed to fail. Browser code doesn't touch this path at all and is unaffected. --- lib/coffeescript/index.js | 6 ++---- src/index.coffee | 5 ++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/coffeescript/index.js b/lib/coffeescript/index.js index 78f7c7ba7b..ee681d48a9 100644 --- a/lib/coffeescript/index.js +++ b/lib/coffeescript/index.js @@ -60,10 +60,8 @@ // Save the options for compiling child imports. mainModule.options = options; // Compile. - if (!helpers.isCoffee(mainModule.filename) || require.extensions) { - answer = CoffeeScript.compile(code, options); - code = (ref = answer.js) != null ? ref : answer; - } + answer = CoffeeScript.compile(code, options); + code = (ref = answer.js) != null ? ref : answer; return mainModule._compile(code, mainModule.filename); }; diff --git a/src/index.coffee b/src/index.coffee index 9356776fcd..205344d1d3 100644 --- a/src/index.coffee +++ b/src/index.coffee @@ -53,9 +53,8 @@ CoffeeScript.run = (code, options = {}) -> mainModule.options = options # Compile. - if not helpers.isCoffee(mainModule.filename) or require.extensions - answer = CoffeeScript.compile code, options - code = answer.js ? answer + answer = CoffeeScript.compile code, options + code = answer.js ? answer mainModule._compile code, mainModule.filename