Ezra Henley
Ezra Henley

Reputation: 349

How can I export types for my npm package without /dist/ in the package path?

I've searched for this question and haven't found anything that fixes my issue. Here's the problem:

I've got a package called @clioplaylists/clio that's using a src/ folder for all its code. I'm building the source code with typescript into the dist/ folder and copying package.json over into it as well. I'm using "declaration": true in my tsconfig.json file, so the types .d.ts files are getting generated correctly in the dist/ folder. Then I tried running npm publish --access public in the root directory of the project, which published everything, but once I tried and access it it's saying certain folders are imported like import * from '@clioplaylists/clio/dist/dataplane/...', and I don't want the /dist/ in there.

I tried cding into the dist/ folder and running npm publish --access public to publish my package only with the code in the dist/ folder (which has the package.json file in there). Everything publishes fine, except when I import the @clioplaylists/clio package in another project I can't import anything. Attached is a picture of what the editor says is inside import * from '@clioplaylists/clio/

image showing that only 3 things are able to be imported, none of them useful

What's the right way to publish my package such that all of my types files are included but the /dist/ folder is not included in the import path?

Upvotes: 0

Views: 10

Answers (0)

Related Questions