Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack & tsc plugins #160

Open
samhh opened this issue Jul 25, 2022 · 3 comments
Open

Webpack & tsc plugins #160

samhh opened this issue Jul 25, 2022 · 3 comments

Comments

@samhh
Copy link
Contributor

samhh commented Jul 25, 2022

The current Web workflow works pretty nicely with intlc able to compile everything in under a second, but it adds some extra moving parts separate from the main builds.

What we do right now is compile *.translations.json to *.ts and import from the latter in TypeScript. What we could potentially do instead is import directly from *.translations.json. The Webpack plugin would handle runtime compilation and the tsc plugin, a la typescript-plugin-toml, would handle the language server side of things. The pattern should ideally be configurable in both cases.

The only question is whether the plugin infrastructure supports returning raw TypeScript code for tsc to check, which it'd obtain via a shell call to intlc. I haven't checked if the linked plugin is doing that or returning only computed type information. If the latter that might be doable but it'd be a good chunk more complex.

@OliverJAsh
Copy link
Member

the tsc plugin, a la typescript-plugin-toml, would handle the language server side of things

Reminds me of this for CSS Modules: https://github.com/timothykang/css-module-types

@OliverJAsh
Copy link
Member

OliverJAsh commented Nov 27, 2022

The Webpack plugin would handle runtime compilation and the tsc plugin, a la typescript-plugin-toml, would handle the language server side of things.

How would this work when we run tsc to type check the project? If I understand correctly, TS language service plugins don't effect tsc. Taken from https://github.com/RyanCavanaugh/sample-ts-plugin:

Examples of things language plugins cannot do:

  • Customize the type system to change what is or isn't an error when running tsc

I think we'd still need to manually compile translation JSON to TS before we run tsc.

Related TS issues:

@samhh
Copy link
Contributor Author

samhh commented Nov 28, 2022

You're right, if typechecking is limited to the editor then we'd be losing type safety versus compiling directly via intlc first and then running tsc.

Might it be worth considering ttypescript given how pervasive translation imports are?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants