lob-npm-template v1.0.1
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
- In Settings -> Languages & Frameworks -> Node.js click to add a new Node Interpreter
- In the popup select Add -> Add Remote -> Docker Compose
- In Service select your
lob-npm-template
service name. Save and exit - In Configurations add a new npm configuration with Node Interpreter set to your created interpreter
- Use the
invoke
script for development - Set a breakpoint in
src/index.ts
and debug run the configuration
VS Code
- Open Remote Window -> Add Dev Container Configuration Files... -> Add configuration to workspace (for commiting)
- Select From 'docker-compose.yml'
- Install additional features if needed
- Open workspace in dev container
- Select Run and Debug -> Javascript Debug Terminal
- Set a breakpoint in
src/index.ts
- In the terminal run
npm run invoke
1 year ago