Skip to content

Create a Structure for Conductor Bundles #848

Description

@leeyi45

Right now bundles are required to have src/index.ts as their main "exported" entry point, while Typescript code that consumes that bundle usually imports from src/functions (or anywhere that doesn't import context).

Moving forward, bundles will as their main export end up exporting a ModulePlugin. But this poses several issues:

  1. Testing is difficult/impossible, since Vitest can't currently handle decorators (see vitest can't import a bundle's own index.ts: decorators aren't downleveled for SSR, and Node doesn't support them natively yet #816). We may have to test plugins separately from implementation details.
  2. Documentation is difficult, since all docstrings would have to be defined on the methods defined in the module plugin itself for it to be detected by Typedoc.
  3. Following from the above, if Typescript consumers want to import functions from another bundle, the docstrings aren't available (or have to be duplicated).
  4. Also, Typescript consumers probably shouldn't have to import the ModulePlugin just to use the code from another bundle.

Previously, the functions.ts file was assumed to be the documentation entry point for bundles. This hasn't been necessary for a long time since the bundles were restructured to behave like regular ES Modules, so Typedoc can get all its information from index.ts. Perhaps it is time to revisit such a solution.

A potential structure could be like this:

curve
├── src
│   ├── plugin.ts
│   └── functions.ts
├── tsconfig.json
└── manifest.json

Then plugin.ts and functions.ts effectively serve as two different entrypoints for two different purposes (to be loaded by Conductor and to be processed as regular Typescript). This structure might even be language agonstic if we start writing modules in other languages.

We can set our own conventions in package.json using the exports field: custom export conditions have been around for some time, though that is Javascript specific.

There will likely be a necessity to expand buildtools to work with this structure.

Related Issues:

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