Skip to content
This repository was archived by the owner on Feb 9, 2023. It is now read-only.

Commit 23077fe

Browse files
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.
1 parent 1957356 commit 23077fe

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

extract.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,16 @@ function loadBabelOpts (opts) {
133133
if (Array.isArray(fileOpts[key]) && !fileOpts[key].length) {
134134
continue;
135135
}
136-
// because some options need to be passed to parser also
136+
137137
opts[key] = fileOpts[key];
138-
opts.parserOpts[key] = fileOpts[key];
138+
139+
if (Array.isArray(fileOpts[key]) && Array.isArray(opts.parserOpts[key])) {
140+
// combine arrays for plugins
141+
opts.parserOpts[key] = opts.parserOpts[key].concat(fileOpts[key]);
142+
} else {
143+
// because some options need to be passed to parser also
144+
opts.parserOpts[key] = fileOpts[key];
145+
}
139146
}
140147
return opts;
141148
}

0 commit comments

Comments
 (0)