Skip to content

Update packaging to use subpath exports and moduleResolution node16 #784

@cprice404

Description

@cprice404

Today, we release our packages with all of the code nested in a dist dir. This is fine except that it means that in order to avoid forcing our users to have really weird/ugly imports that dig down into dist, we need to export all the important names from the main index.

node/ts/webpack all seem to support this newer concept called "subpath exports":

https://nodejs.org/api/packages.html#packages_subpath_exports

which would allow us to add exports like "./vector" -> "./dist/src/messages/responses/vector". Then our users could do imports like import {CreateVectorIndex} from @gomomento/sdk/vector, with none of the weird dist` stuff.

However, this requires consumers to use moduleResolution of node16 or bundler. These seem to be the preferred / best practice choices for "modern" applications:

https://www.typescriptlang.org/tsconfig#moduleResolution

but they are not the defaults, and thus I am concerned that it is too risky to introduce a change like this in our 1.x series.

We should definitely try to do this whenever we do a 2.0.

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