Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

Commit

Permalink
feat: Add support for passing babelOptions to OptionsManager#init (
Browse files Browse the repository at this point in the history
  • Loading branch information
TuckerWhitehouse authored Aug 24, 2020
1 parent 91c05b6 commit c23f28d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ const pkgUp = require('pkg-up');
const { resolvePath } = require('babel-plugin-module-resolver');
const { OptionManager } = require('@babel/core');

function getPlugins(file, cwd) {
function getPlugins(file, cwd, babelOptions) {
try {
const manager = new OptionManager();
const result = manager.init({
babelrc: true,
filename: file,
cwd,
...babelOptions,
});

return result.plugins.filter(plugin => plugin.key === 'module-resolver');
Expand All @@ -25,7 +26,7 @@ function getPlugins(file, cwd) {
}

function getPluginOptions(file, cwd, defaultOptions) {
const instances = getPlugins(file, cwd);
const instances = getPlugins(file, cwd, defaultOptions.babelOptions);

return instances.reduce(
(config, plugin) => ({
Expand Down Expand Up @@ -101,6 +102,7 @@ exports.resolve = (source, file, opts) => {
alias: options.alias || {},
resolvePath: options.resolvePath,
extensions: options.extensions || defaultExtensions,
babelOptions: options.babelOptions || {},
},
);

Expand Down

0 comments on commit c23f28d

Please sign in to comment.