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

Check for package key module in addition to main #224

@dan-kez

Description

@dan-kez

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!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions