catdadcode / poker-engine

32 stars 13 forks source link

Adding package to project that doesn't already contain typescript fails #8

Open seanstern opened 2 years ago

seanstern commented 2 years ago

Sumamry

This package relies on tsc as part of it's build command in package.json.

However, typescript is a part of devDependencies, which means it is not pulled in when one runs npm add in another project.

As a result, the build fails with the fails with the following message (on Windows)

'tsc' is not recognized as an internal or external command, operable program or batch file

Reproduction Steps

  1. Create a new npm package: npm init
  2. Add @chevtek/poker-engine as a dependency: npm add @chevtek/poker-engine

Suggested fix

There are three options you could consider:

  1. If build needs to be run when adding this package to another project, then it's likely typescript needs to be included as part of depenencies.
  2. Alternatively, if you're assuming that consumers of this package should already have typescript as part of their project, it should be specified that typescript is a part of peerDependencies.
  3. Alternatively, you could publish this package based on what's in the build directory (i.e. raw javascript) and include the typings. In this way typescript could be avoided as part of your dependency chain for consumers of this package. To give you a rough idea, consider the approach outlined here.

    Additional Notes

    I'm going to submit a PR based on option 2.