Closed cinderblock closed 4 years ago
@cinderblock Actually i am publishing npm package through dist folder.
Yes, you should publish the dist folder on npm (and arguably not the src folder).
That doesn't explain why the dist
folder is checked into the git repository. The general consensus is that generated files should not be in repositories.
@cinderblock Yes, i should publish npm package from dist folder. It will require to update the package.json. Will do in next release
It should just take two things:
prepare
script that calls tsc
(or npm run build
) - Not strictly required but is very useful.npmignore
file or add a files
field to package.json
For more details about why these steps are needed/helpful, I'll point you to my SO answer:
Problems with
.gitignore
There is one issue with this option that gets many people. When preparing a dependency, Npm and Yarn will only keep the files that are listed in the
files
section ofpackage.json
.One might see that
files
defaults to all files being included and think they're done. What is easily missed is that.npmignore
mostly overrides thefiles
directive and, if.npmignore
does not exist,.gitignore
is used instead.So, if you have your built files listed in
.gitignore
like a sane person, don't list your built files infiles
, and don't use a.npmignore
file,prepare
will seem broken.If you fix
files
to only include the built files or add an empty.npmignore
, you're all set.
Done
Why are
dist
files not.gitignore
d?