Skip to content

Plugin incompatible with Node.js exports package.json field #104

@ctavan

Description

@ctavan

This plugin tries to resolve the package.json files of processed modules:

const resolved = tryResolve(
`${name}/package.json`,
path.dirname(importer)
);

This breaks with npm modules that make use of the new exports field but do not specify a subpath export for the package.json file.

This issue surfaced in uuidjs/uuid#444

IMO this plugin can no longer expect that every npm module exports the package.json file and the resolver logic has to be adjusted accordingly.

Maybe in

function tryResolve(pkg, importer) {
try {
return relative.resolve(pkg, importer);
} catch (err) {
if (err.code === 'MODULE_NOT_FOUND') return null;
throw err;
}
}

we could add ERR_PACKAGE_PATH_NOT_EXPORTED as an "acceptable" error as well?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions