Open vjpr opened 1 year ago
There is no way to get an entrypoint from only the path to the package.json file.
package.json
I want to get the main package import from a package path.
E.g. If I have /path/to/package.json, I want to use Bun's algorithm to find it's entry point.
/path/to/package.json
Something like: Bun.resolveSync('.', '/path/to/package.json')
Bun.resolveSync('.', '/path/to/package.json')
const from = '/path/to/package.json' // name: 'foo' Bun.resolveSync('.', from) Bun.resolveSync('./', from) Bun.resolveSync(from) Bun.resolveSync('foo', path.dirname(from))
--
It is possible to manually read the package.json#exports, but would prefer to have Bun take care of this for consistency.
package.json#exports
Related: https://github.com/oven-sh/bun/issues/1137
This should work but the second argument is supposed be a directory.
it doesnt seem to resolve package subpaths though
What is the problem this feature would solve?
There is no way to get an entrypoint from only the path to the
package.json
file.What is the feature you are proposing to solve the problem?
I want to get the main package import from a package path.
E.g. If I have
/path/to/package.json
, I want to use Bun's algorithm to find it's entry point.Something like:
Bun.resolveSync('.', '/path/to/package.json')
What alternatives have you considered?
--
It is possible to manually read the
package.json#exports
, but would prefer to have Bun take care of this for consistency.