jtz-js-utils
v0.0.1
Published
Random utilities, WIP
Downloads
1
Readme
Tiny bits of code that I often reach for across projects.
Work in progress, use at your own risk, etc.
NodeJS Versions Supported
To ship ESM only, this supports Node V >= 12.17.0
, since those versions support ESM imports out-of-the-box.
Build Setup
There are a few peculiarities worth noting about the build setup used here:
- TypeScript
- Config has libs set to include
DOM
in all TS files, not just those undersrc/web
. This is slightly unsafe, as it won't catch me doing something silly like usingdocument.location
insidesrc/node/index.ts
- I'm doing this because isolating libs to specific files is almost impossible with TypeScript at the moment - triple slash directives bleed into other files, and VSCode doesn't play nice with multiple root tsconfigs, so the only way to do this correctly would be to split each subdirectory into a completely isolated build and bundling step... still might be worth exploring at some point
- Config has libs set to include
- Bundling
- Using Rollup
- Targeting UMD for browser, ESM for NodeJS (since most live versions support now)
Testing
Tests are ran using Ava, which can execute them in parallel.
Due to an issue with NodeJS ESM requiring file extensions to be included in import syntax - but this breaking TS-Node completely - I am running Ava against the transpiled JS (
/dist
) instead of the raw TypeScript source (which would require TS-Node).