facebook / lexical

Lexical is an extensible text editor framework that provides excellent reliability, accessibility and performance.
https://lexical.dev
MIT License
17.37k stars 1.43k forks source link

Feature: Use api-extractor when generating the .d.ts files for distribution #5921

Open etrepum opened 1 week ago

etrepum commented 1 week ago

It's easy to make a mistake that will export an internal type. TypeScript doesn't seem to have any options to roll-up or inline types, but they do suggest using api-extractor in the stripInternal docs.

I have a hotfix up in #5920 to address #5918, this would be the better long-term solution.

tsup might be worth looking into as an alternative as well

StyleT commented 5 days ago

Short summary here of my research done in https://github.com/facebook/lexical/pull/5920:

StyleT commented 5 days ago

So likely some custom solution (probably based on rollup-plugin-ts) needed here

etrepum commented 5 days ago

Is tsc's hardcoded esnext target a problem in our situation? I don't recall running into any issue with it when I prototyped it locally, but invoking tsup for each package is very much noticeably slower running tsc over the whole repository (tsup for even a single package seemed slower than the whole-repo tsc). Fixing up the output is not that big of a deal so long as we are certain about what to remove.

Trying rollup-plugin-ts sounds like a pretty good idea though, especially if it can be combined with the existing rollup usage which would hopefully be more performant.

StyleT commented 5 days ago

Yeah, I got TS errors as ESNext is more strict comparing to the target lexical uses now. Not all packages had them, but lexical did