1.0.3 • Published 3 years ago
@rostyslavsh/simple_package v1.0.3
modern-npm-package
An npm package for demonstration purposes using TypeScript to build for both the ECMAScript Module format (i.e. ESM or ES Module) and CommonJS Module format (CJS). It can be used in Node.js and browser applications.
Get Started
- Run npm installin your terminal
- Then run npm run build
- Update the package.jsonfile "name" field with your own package name. Example@username/package-name
- Create an account with npm if you don't have one already. Also be sure to enable two-factor authentication
- Sign in to your npm account in your terminal with npm login
- Run npm publish --access=publicto publish your package
Testing
- Install developer dependencies using the following command in your terminal npm i -D mocha @type/mocha chai @types/chai ts-node
- Create a new file .mocharc.jsonin the root directory with the following contents:{ "extension": ["ts"], "spec": "./**/*.spec.ts", "require": "ts-node/register" }
- Create a testsfolder
- Create an index.spec.tsfile in thetestsfolder
- Write unit tests in the index.spec.tsfile to test the code inindex.ts
- Add a "test"property in thepackage.jsonfile and give it a value of"mocha"
- Run npm testin your terminal from the root folder of the project