I wrote a vscode extension that exposes an API for use by other extensions (by having the activate() function return a value).
I would like to publish a scoped npm package that exposes a declaration file (.d.ts), that would assist developers of extensions to consume my extension.
My issue is that I cannot reuse the extension's package.json, because it doesn't allow for @ in the package's name (vsce package fails).
If I create a dedicated package.json for the purpose of publishing the declaration file to npm, I end up copying the .d.ts file and all its dependencies from the extension's out directory. This approach seems a bit cumbersome.
I couldn't find documentation that describes the proper way for doing this: publishing vscode extension declaration files to npm (scoped or not).
What is the correct approach to doing this?
This is what I ended up doing:
package.jsonin it:nameproperty and suffixed it with-typesfor clarity.copynpm script that copies artifacts from theoutfolder of the extension's folder. This script usesncpfor cross platform support.@types/vscodeto thedependenciesproperty (notdevDependencies, as noted in publishing declaration files) because my.d.tsfile includes a reference tovscode..npmignorefile to reinclude theoutfolder (using negate:!out) that was excluded in the.gitignorefile..jsfiles from theoutfolder to avoid errors related to missing transitive dependencies. I could have created anothertsconfig.jsonfile that emits only.d.tsfiles (usingemitDeclarationOnly), but ended up using.npmignoreto do this.The above works for me, but there must be a better way, right??