What is this project about?
This contribution is made to gornanization/1k. If you would like to find more info - I strongly recommend reading this post first.
PR:
https://github.com/gornanization/1k/pull/33/files
Details:
I decided to do some Proof of Concept and publish game logic as a NPM package.
It’s not fully finished yet, but I would love to show you how it really works outside my development environment.
If you familiar with my previous contributions, in one of them I have provided ready state for a battle in unit tests. I have picked this case and put into plunker:
I recommend you to open your browser console and observe an output. Nothing interesting there, four throwing card actions made, that’s it. But the fact is, this package can be used now!
We have additional benefit of such move. It will give me knowledge, how the end shape of API should looks like, what helper functions must be included to public API, etc.
What was required to publish this typescript-based project as a npm package?
Few changes was made to the project:
Firstly, index.ts
was created. It will include public API available of package users. As we do have huge number of helper functions used internally, we do not want to publish all of them to end users, right?
Secondly, typescript config was changed, to automatically generate typings. It will be helpful for further library usage.
Next, package.json
file was extended with new fields. I added prepublish
script to package.json
. It forces project to be fully recompiled into es5. It looks like:
rm -rf dist && tsc
Two entries was also added. main
is a path to compiled version of index.ts, which is basically the public API for package users. types
fields on the other hand is a path to typings, generated automatically by typescript compiler.
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
Finally, 1k package was publish with 0.0.1 version. You can see it here. As I mentioned earlier, it’s not yet finished, but I hope it’s a huge step towards “production-ready” state of the package!
All the best, readers!
Posted on Utopian.io - Rewarding Open Source Contributors
Thank you for the contribution. It has been approved.
You can contact us on Discord.
[utopian-moderator]
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hey @adasq I am @utopian-io. I have just upvoted you!
Achievements
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit