Skip to content

Add Package::exports() to replace Package::namespace().exports #1330

Description

@DavisVaughan

From #1306 (comment)

This should be a Package::exports() query mirroring File::exports(). I thought I had implemented it already, > but can't find it (maybe it was abandoned at some point).

There will be some complex resolution in the future (e.g. for regex exportPattern), so we should call a single > method everywhere exports are needed.

It'd return a vector of names that you can then resolve with top-level Package::resolve().

And maybe namespace() should be private?

I had some outstanding questions about this from this request:

  • What do we do with other existing calls to namespace().exports? We have a few, like

    for export in &pkg.namespace().exports {

  • Do the documented symbols get added to Package::exports()'s output?

    // Start from explicit `NAMESPACE` exports
    let mut exports = package.namespace(context.db).exports.clone().into_vec();
    // Add all documented symbols. This should cover documented datasets to avoid some
    // false positives in favor of allowing some false negatives. This is admittedly a
    // bit of a stopgap!
    if let Some(index) = package.index(context.db) {
    exports.extend(index.names().iter().cloned());
    }

  • What is the exact return value Vec<Name>?

  • Is Package::resolve() actually relevant here?

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