sindresorhus / resolve-pkg Goto Github PK
View Code? Open in Web Editor NEWResolve the path of a package regardless of it having an entry point
License: MIT License
Resolve the path of a package regardless of it having an entry point
License: MIT License
Given a package that has exports
in its package.json
, like this:
{
"exports": {
".": "./dist/index.js",
"./*": {
"types": "./dist/*.d.ts",
"default": "./dist/*.js"
}
}
}
When trying to resolve that package, a MODULE_NOT_FOUND
error is thrown with "Cannot find module '/path/to/my-package/dist/package.json.js'"
Basically the assumption here that you can always resolve the package.json
of a package using node does not hold true anymore in this case. Still I'd like to be able to get the root path of that package, using node module resolution rules. ๐ค
resolve-from/resolve-cwd/resolve-global all throws by default, and have a silent
method to prevent throwing.
Why this package is different. Is there any chance that you make it the same with others? (which will definitely cause a break.)
Attempting to resolve https://github.com/delvedor/hpagent which has conditional exports at it's package.json results to undefined
.
The standard require.resolve
returns the location of the "main" property as specified in the package.json.
Is there a CLI version of this?
Possible to add support for a synchronous version as resolvePkg.sync
?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.