1.0.1 • Published 1 year ago

lob-npm-template v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

lob-npm-template

This is a work in progress and is not ready for use

How to use this template

This template was designed to quickly stand up a new npm package that is compatible with CommonJS and ES Modules.

Follow these steps to set up your new package: 1. Update all references to lob-npm-template to your package name. Lob npm package names should begin with lob-. 2. Update the description, author, bugs.url, homepage, etc. in package.json accordingly. 3.

Tests

Tests are separated into two directories

  • unit is where your package specific tests should go.
  • modules is for testing that your package is compatible with CommonJS and ES Modules. A simple test runs for both that check for successful importing of your package. These tests should not be modified.

Docker

Does your package need to run in a specific environment?

If so, a docker-compose.yml and Dockerfile have been provided. Change lob-npm-template in docker-compose.yml to your package name.

Otherwise, these can be deleted.

Node Version

If you need to set a specific version of node for the package, add engines to package.json. Example:

  "engines" : { 
    "npm" : ">=9.0.0",
    "node" : ">=18.8.0"
  }

and in .nvmrc. Check out this guide to have node version with nvm automatically pick up the version in .npmrc

Local Development

Debugging With Docker Containers

IntelliJ

  1. In Settings -> Languages & Frameworks -> Node.js click to add a new Node Interpreter
  2. In the popup select Add -> Add Remote -> Docker Compose
  3. In Service select your lob-npm-template service name. Save and exit
  4. In Configurations add a new npm configuration with Node Interpreter set to your created interpreter
  5. Use the invoke script for development
  6. Set a breakpoint in src/index.ts and debug run the configuration

VS Code

  1. Open Remote Window -> Add Dev Container Configuration Files... -> Add configuration to workspace (for commiting)
  2. Select From 'docker-compose.yml'
  3. Install additional features if needed
  4. Open workspace in dev container
  5. Select Run and Debug -> Javascript Debug Terminal
  6. Set a breakpoint in src/index.ts
  7. In the terminal run npm run invoke
1.0.1

1 year ago