-
Notifications
You must be signed in to change notification settings - Fork 108
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
Typescript declarations in cts and mts formats #4061
Conversation
8c03131
to
33f8dee
Compare
Leaving a note from the internal discussion for a future reference: The use of
|
* chore: update gitignore * feat(adblocker): update build config * feat(adblocker-content): update build config * chore(adblocker-content): sync declarationDir of tsconfig * feat(adblocker-electron): update build config * feat(adblocker-electron-preload): update build config * feat(adblocker-playwright): update build config * feat(adblocker-puppeteer): update build config * feat(adblocker-webextension): update build config * feat(adblocker-webextension-cosmetics): update build config * chore: update npmignore * chore: clean up - drop "declarationDir" from tsconfig which will cause conflict with @rollup/plugin-typescript - properly specify file location with prefix of "./" - fix up some file orders - fix the declaration directory to "./dist/types" - create npmignore unless exists * feat(adblocker-webextension-example): update build config * chore(adblocker-electron-example): remove accidental build output * feat: update tsconfig for examples commonjs is no longer recommended, switching to nodenext as we now properly support cjs modules
Just a note: a command to check if cts generation was successful: |
closing in favour of #4079 |
This draft updates one package for purpose of demonstrating the direction. If accepted, all packages will be updated in this PR.
Fixes #4054
Typescript assumes that type delacrations for commonjs files will have
.cts
file extension.To achieve that, we had to:
tsc
from the build step@rollup/plugin-typescript
rollup-plugin-copy
As a byproduct of the workaround, the /dist file structure was flatten and now all esm, commonjs and declarations files are next to each other. One positive outcome of that change is that declarations can be automatically picked up without
package.json
referencing them explicitly. We have however kept those references for clarity.New flatten file structure looks like this: