From 23077fe36e15a51b98b724de57e45e3376368de3 Mon Sep 17 00:00:00 2001 From: Jacob Rienstra Date: Fri, 28 Feb 2020 01:24:38 -0500 Subject: [PATCH] Fix babel parsing plugins (typescript) I was mystified as to why stylelint stopped working when I switched from .jsx to .tsx, and it turns out it was this. It was overriding that set of plugins with Babel's automatically detected ones, and so would fail if you were using tsc, or in my case, had babel typescript installed in a gatsby plugin, which babel missed. I imagine there are some other problems this might solve too though. Please give feedback or edit yourself, I'm not able to thoroughly test this. --- extract.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/extract.js b/extract.js index 170749a..4db5f7e 100644 --- a/extract.js +++ b/extract.js @@ -133,9 +133,16 @@ function loadBabelOpts (opts) { if (Array.isArray(fileOpts[key]) && !fileOpts[key].length) { continue; } - // because some options need to be passed to parser also + opts[key] = fileOpts[key]; - opts.parserOpts[key] = fileOpts[key]; + + if (Array.isArray(fileOpts[key]) && Array.isArray(opts.parserOpts[key])) { + // combine arrays for plugins + opts.parserOpts[key] = opts.parserOpts[key].concat(fileOpts[key]); + } else { + // because some options need to be passed to parser also + opts.parserOpts[key] = fileOpts[key]; + } } return opts; }