-
Notifications
You must be signed in to change notification settings - Fork 5
Babel throws an error when a preset is passed options but doesn't accept them #6
Comments
same issue and have not been able to compile code |
Same issue here. :/ This seems to fix it: function mapPreset(preset, options) {
var info = getPresetInfo(preset);
if (!info) {
return preset;
}
if (options.findRollupPresets && hasRollupVersionOfPreset(info.name, options.resolve || resolve.sync)) {
return [info.name + '-rollup', info.options];
} else if (options.addModuleOptions) {
const options = info.name === 'es2015' ? _extends({}, info.options, { modules: false }) : []
return [info.name].concat(options);
} else {
return preset;
}
} Not sure which other modules accept options? I just made the change above temporarily so I could publish. |
I'm having the same issue. Any updates? |
To disable that behavior:
|
@brabeji where do you put that config? |
In your |
Hi @eventualbuddha, I think the fix described by @sebinsua is much better. I don't consider In that situation you will then get an error ie. you have to add in manually to your Simply put the I was having issues because I need the following for AVA (and any other normal es w/ modules)
but this plugin incorrectly adds For the time being I have to loop over the presets returned by UPDATE In addition to this it turns out some presets can also refuse any options at all! :( So in the case of So even if modules option was only added if es2015, the following will still add an option to some presets that don't accept any options (because it returns the array).
This is my hacky fix in my config to undo any problematic preset option transformation.
in config...
|
I'm happy to let someone else take over this project, or to review a PR that fixes this. |
You can quite easily pass custom options to babel and still have a global .babelrc file; import babel from 'rollup-plugin-babel';
export default {
plugins: [
babel({
presets: [['env', { modules: false }], 'stage-2'],
exclude: 'node_modules/**',
babelrc: false
}),
],
}; Hopefully it will help anyone 😄 |
I ran into an issue using this lib because it passes options (
{modules: false}
) to all presets; e.g.babel-preset-react
, even if that preset doesn't accept options. When this happens Babel errors out.The text was updated successfully, but these errors were encountered: