nucleus04-template
v1.0.9
Published
This repository provides a template for building a JavaScript/TypeScript package. Follow the instructions below to set up, develop, test, build, and publish your package.
Downloads
3
Readme
Template Package
This repository provides a template for building a JavaScript/TypeScript package. Follow the instructions below to set up, develop, test, build, and publish your package.
Getting Started
1. Install Dependencies
To get started, clone the repository and install the necessary dependencies:
npm install
2. Develop Your Module
- The main logic of your module should be placed in the
src
folder. Ensure that your code is written as an ES module. - Make sure to add TypeScript definitions for your functions to enable auto-suggestions and type checking when the module is used.
3. Testing Your Module
- Create your test scripts using Jest and place them in the
tests
directory. - To run the tests and verify that all functions and methods work correctly, execute:
npm test
4. Bundling Your Module
If all tests pass and the module works as expected, you can proceed to build the package:
npm run build
This command will generate a minified version of your code and the corresponding TypeScript definitions in the dist
directory.
5. Publishing to npm
Once your package is built, you can publish it to npm:
- First, log in to your npm account using the legacy authentication method:
npm login --auth-type=legacy
- Then, publish the package:
npm publish
Project Structure
.
├── jest.config.js
├── package-lock.json
├── package.json
├── rollup.config.js
├── src
│ ├── HelloWorld.d.ts
│ ├── HelloWorld.js
│ ├── index.d.ts
│ └── index.js
├── tests
│ └── HelloWorld.test.js
└── tsconfig.json
src/
: Contains the source code and TypeScript definitionstests/
: Contains Jest test filesjest.config.js
: Configuration for Jest testing frameworkrollup.config.js
: Configuration for Rollup bundlertsconfig.json
: TypeScript compiler configuration
Scripts
npm test
: Run Jest testsnpm run build
: Build the package using Rollupnpm run clean
(if available): Clean the dist directory