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

Check for package key module in addition to main #224

Open
dan-kez opened this issue Oct 16, 2018 · 2 comments
Open

Check for package key module in addition to main #224

dan-kez opened this issue Oct 16, 2018 · 2 comments

Comments

@dan-kez
Copy link

dan-kez commented Oct 16, 2018

Hi all!

It would be fantastic to have the ability to configure what "mainFields" to resolve similar to webpack.

Right now I have a main field that points to lib/index.js. The lib directory is used when I publish to npm. However, internal to my monorepo I transpile my node_modules by using the module key in package.json. The key points to src/index.js.

The code in question is here:

const pkgPath = path.join(moduleRoot, 'package.json');
const pkgMain = fs.existsSync(pkgPath) && require(pkgPath).main || 'index.js';
const mainPath = normalizePath(path.dirname(path.resolve(moduleRoot, pkgMain)));

Happy to provide additional context!

@jdalton
Copy link
Member

jdalton commented Oct 16, 2018

Hi @dan-kez!

Thanks for the suggestion. I'm open to a PR if you'd like to contribute!

@dan-kez
Copy link
Author

dan-kez commented Oct 16, 2018

Awesome! I'll take a look this week and write something up

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants