typed-ember / glint

TypeScript powered tooling for Glimmer templates
https://typed-ember.gitbook.io/glint
MIT License
109 stars 51 forks source link

Expose loadConfig to consumers #579

Closed egorio closed 1 year ago

egorio commented 1 year ago

I'm working on a tool to migrate JS to TS, including Glint project. The tool needs access to glint config values from tsconfig.json file and team is implementing a function to do this, but there are few challenges there to make it work right.

As you know, the standard TS functions to parse config ignore glint option, so you can't use them. It's required to implement a function to search for this value recursively across all tsconfig hierarchy and merge all found glint values.

Glint has its own function to load the config to do this as well.

The basic implementation of the function to load config is not complex, but if we want to have it typed and validated then we need to "reimplement" the glint/packages/core/src/config/ which sounds counter-productive while glint has it already.

It's also a good practice to provide such functionality for open-source community, for example prettier's resolvaConfig or eslint's calculateConfigForFile.

So the question is could Glint has loadCondig and it's types (already exposed) to be exported to end user?

egorio commented 1 year ago

I can come with PR if Glint team will agree to export it.

dfreeman commented 1 year ago

It's also a good practice to provide such functionality for open-source community, for example prettier's resolvaConfig or eslint's calculateConfigForFile.

As a reminder, none of the programmatic interfaces exposed from @glint/core are officially public, and while we'll make a good-faith effort not to break those interfaces unnecessarily, they're intentionally undocumented and not a part of the semver contract for the package. Given that, comparing to ESLint and Prettier's public APIs isn't necessarily the best point of reference for "good practice" đŸ˜‰

That said, since we already provide access to the GlintConfig instance to consumers who run analyzeProject, it seems reasonable to me to offer a way to load that config without forcing a full project analysis.

I can come with PR if Glint team will agree to export it.

I think exposing the loadConfig function that we already import and use in analyzeProject makes sense, and would be happy to review a PR to add that export.

egorio commented 1 year ago

@dfreeman here is the PR