Closed BenJeau closed 7 months ago
From what it looks like, the react preset uses babelMerge
https://github.com/neutrinojs/neutrino/blob/cdb08011793d4a6eb4509655a1fab2906a7c4356/packages/react/index.js#L21
babelMerge
specifically looks for duplicates in the plugins array
https://github.com/neutrinojs/babel-merge/blob/d24260a025d6416a4cd52e72a8a024f4f403de2f/src/index.js#L13
return [...source, ...overrides].reduce((reduction, override) => {
const overrideName = resolve(Array.isArray(override) ? override[0] : override);
const overrideOptions = Array.isArray(override) ? override[1] : {};
const base = reduction.find((base) => {
const baseName = resolve(Array.isArray(base) ? base[0] : base);
return baseName === overrideName || baseName.includes(overrideName);
});
const index = reduction.includes(base) ? reduction.indexOf(base) : reduction.length;
const baseName = base ? resolve(Array.isArray(base) ? base[0] : base) : overrideName;
const baseOptions = Array.isArray(base) ? base[1] : {};
const options = merge(baseOptions, overrideOptions, {
arrayMerge,
isMergeableObject: value => Array.isArray(value),
...deepmergeOpts
});
reduction[index] = Object.keys(options).length ? [baseName, options] : baseName;
It seems there is already an open issue to support the name
third parameter in @neutrinojs/babel-merge
https://github.com/neutrinojs/babel-merge/issues/35
Maybe the logic to identify the baseName
could be adapted to support the third parameter form
Oh sorry, wasn't sure where this originated from. Thanks for the info and quick code explanation! I'll look at potentially making a fix/PR for @neutrinojs/babel-merge
if I have time and it's only related to this section
Bug
Ex:
.neutrinorc.js
and the output from
neutrino --inspect --mode development
(only the relevant babel part):It seems like its ignoring the third element in the plugins array? How would someone using
neutrinojs
use the same babel plugin multiple times?