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 the custom cwd option from babel-resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
Tommy Leunen committed Nov 6, 2016
1 parent 9c19f29 commit 0a0d42c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"devDependencies": {
"babel-jest": "^16.0.0",
"babel-plugin-module-resolver": "^3.0.0-beta.1",
"babel-plugin-module-resolver": "^2.3.0",
"eslint": "^3.3.0",
"eslint-config-airbnb-base": "^8.0.0",
"eslint-plugin-import": "^1.16.0",
Expand All @@ -43,7 +43,7 @@
"standard-version": "^3.0.0"
},
"peerDependencies": {
"babel-plugin-module-resolver": "^3.0.0-beta"
"babel-plugin-module-resolver": "^2.3.0"
},
"scripts": {
"lint": "eslint src test",
Expand Down
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,16 @@ exports.resolve = (source, file, options) => {
const babelConfig = findBabelConfig.sync(path.dirname(file));
const babelrcPath = babelConfig.file;
const config = babelConfig.config;
const cwd = babelrcPath
let cwd = babelrcPath
? path.dirname(babelrcPath)
: process.cwd();

try {
const pluginOpts = getPluginOpts(config);
if (pluginOpts.cwd !== 'babelrc') {
cwd = pluginOpts.cwd || cwd;
}

const src = mapModule(source, file, pluginOpts, cwd) || source;
return {
found: true,
Expand Down

0 comments on commit 0a0d42c

Please sign in to comment.