This setup normalizes a from source usage for all environments (node/browser+modules/commonjs). It babel compiles the commonjs files into /dist
and it (from jsdoc) compiles both docs (in /docs
) and typescript types (alongside the source in /src
).
It sets up a single test that is used in headless, browser and node modes, has a sane set of lint rules and husky bindings to make sure you:
- don't have to do any of it manually
- it all stays up to date
- You write in a single format
- The source you are writing is executable as-is in node + the browser
- 1 file to rule them all
This allows you to use either source tree for compilation as well.
You need a copy of jq
installed in order to initialize
fork as a template in github then clone it locally
OR
use the github cli to create a template from the repo
gh repo create --template="@environment-safe/template" <new-repo-name>
OR
Use degit to copy the repo with no history
mkdir <new-repo-name>
cd <new-repo-name>
npx degit environment-safe/template
git init
THEN
Once you've done that, change directories into the project directory and run ./initialize
which will configure your package.json
, your LICENSE
and your README.md
(this file) and remove any artifacts as well as itself and stage the changes for commit.
LAST
When you commit, the rest of the artifacts will be generated and added to your commit.
When you come back this will all be gone. Good Luck!
- - submodule for minimal project footprint
- - support windows development
- - support multiple licenses
- - support electron
- - support cordova
Run the es module tests to test the root modules
npm run import-test
to run the same test inside the browser:
npm run browser-test
to run the same test headless in chrome:
npm run headless-browser-test
to run the same test inside docker:
npm run container-test
Run the commonjs tests against the /dist
commonjs source (generated with the build-commonjs
target).
npm run require-test
All work is done in the .mjs files and will be transpiled on commit to commonjs and tested.
If the above tests pass, then attempt a commit which will generate .d.ts files alongside the src
files and commonjs classes in dist