Skip to content

Lazy loading for ts-node + optional peer-dependecies #79

Closed
@timofei-iatsenko

Description

@timofei-iatsenko

Hey, thanks for the job.

Currently, loader implemented in such a way that it doesn't matter does the cosmiconfig found a .ts file or not ts-node is trying to load.
The cosmiconfg + cosmiconfig-typescript-loader is usually used on the projects (libraries) where authors want to give users some flexibility of config files. It means some part of users want to use .rc files with json content, another .js and some .ts.

But once you add this loader to the project, ts-node become a required dependency even if you don't use typescript configs. And application would break if you will not install ts-nodem which might be not necessary for pure js projects.

Related issue: lingui/js-lingui#1401

Currently, i implemented a workaround, which lazy-load a cosmiconfig-typescript-loader only if a *.ts file is trying to be loaded. But I think this logic could be implemented in loader itself.

Also, that would be great to mention in the readme, for library authors. If they are going to use it in theirs project, they have to add all peer-depedencies from this loader to the upstream project. (as optional, if lazy-loading would be implemented)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions