Skip to content

Refactor register, create, and config loading so they can be composed manually by consumers #1429

Closed
@cspotcode

Description

@cspotcode

Partially implemented by #1474

Motivation: to support ts-node-esm, plus improve the API in general.

Should be able to read configuration without creating a Service nor loading any extra dependencies.

While we're at it, we should allow create()ing a service and then passing it to register(). Should not be forced to create and register at once.

import * as tsNode from 'ts-node';
// Not to be confused with current, internal readConfig, which is narrower in scope
const config = tsNode.readConfig(/*ReadConfigOptions, similar to CreateOptions*/);
const service = createFromConfig(config);
register(service); // Can we do this with overload?  Do we need new `registerService()` function?

Will allow ts-node-esm to read config, determine it needs to spawn child process, spawn child, and then for child to skip the config parsing step and call create and register.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions