1.9.0 • Published 2 years ago

my-pubsub v1.9.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Getting started


This small library is bundled via webpack and the output to a lib folder.

To run this project locally you can:

npm install will install all necessary packages - be sure you are using Node >= 10

npm start will start webpack and evaluate changes in real time. This can be useful when linking with another app to test a new component or change.


Versioning and Publishing


In order to publish your own version of this library, you will need to create an NPM account https://www.npmjs.com/

After making the proper changes, you can run the one of the following commands to create a new version of your library and publish it to the npm registry so others can use it.

npm version minor should be used for the majority of changes which should be any NON-BREAKING change

npm version major should be used for any BREAKING change and you and the reviewer should agree on whether this version upgrade is appropriate or not

npm version patch should be reserved for hotfixes. For example, if we have recently published v1.3.0 but our front end app is using v1.2.0 and has a breaking error but we do not want the changes included in v1.3.0 then we will need to branch off v1.2.0 and make a patch to fix the issue introduced in this version without introducing unwanted changes in the most recent version.

After successfully creating the new version, publish it to npm using the following command: npm publish


How to npm-link


You will want to test your changes as they would appear in the front end using this library. You can achieve this using npm link

In this library terminal - npm link and then npm start

In the front end application terminal - npm link my-pubsub or whatever the name area in your package.json file contains.

If you run into issues it's best to nuke all node_modules in your front end app, reinstall and then re-link the library.


TODO


Uh oh, looks like someone published a version of this library with a broken test.

Fix the broken test by implementing the logic then npm link this project with the following repo: to ensure it works.

Once you've confirmed the functionality is working as expected, publish a new version (minor version).

To publish your own version of this library:

  1. Create an account on npmjs.com
  2. In your terminal npm login and follow the prompts to login
  3. Change the name of the app in package.json to whatever you want your app to be named
  4. npm version [minor | major | patch]
  5. npm publish
  6. Navigate to your account on npmjs.com and check that your library has been successfully published

How can you ensure that this kind of mistake does not happen again? Try adding a code-pipeline using Github Actions or a simple check before the npm version command to make sure tests pass.

BONUS: update the webpack config to exclude any test files in the bundle. I mean why include tests when they're not needed for the end user?