From 20661ca0685953580255d8fcf70a5f89691eceee Mon Sep 17 00:00:00 2001 From: Stan Chang Khin Boon Date: Tue, 28 Apr 2020 22:38:32 +0800 Subject: [PATCH] fix(babel): Make babel to recognize TypeScript extensions in dev mode This is to fix an issue with child process not inheriting the extensions option passed to the babel cli. --- lib/process/master.js | 5 +++++ package.json | 1 + 2 files changed, 6 insertions(+) diff --git a/lib/process/master.js b/lib/process/master.js index bf5899d63..0c7712dbd 100644 --- a/lib/process/master.js +++ b/lib/process/master.js @@ -27,6 +27,11 @@ if (!('toJSON' in Error.prototype)) { process.on('message', function(msg) { switch (msg.cmd) { case 'init': + if (process.env.NODE_ENV !== 'production') { + require('@babel/register').default({ + extensions: ['.js', '.jsx', '.ts', '.tsx'] + }); + } processor = require(msg.value); if (processor.default) { // support es2015 module. diff --git a/package.json b/package.json index 0c13b87b1..cabe7e0c5 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "license": "MIT", "readmeFilename": "README.md", "dependencies": { + "@babel/register": "^7.7.7", "bluebird": "^3.5.3", "cron-parser": "^2.5.0", "debuglog": "^1.0.0",