bitumen v3.2.0
Overview
bitumen is a collection of utilities, types, and opinionated configuration for Babel, ESLint, Rollup, TypeScript, and Vitest.
Supported Environments
- Client side: Last two versions of Chrome, Edge, Firefox (+ ESR), and Safari
- Server side: Maintained versions of Node.js
Usage
Configuration
Babel
- Targets maintained versions of Node.js and the last two versions of Chrome, Edge, Firefox (+ ESR), and Safari;
- transpiles TypeScript to JavaScript and rewrites import extensions
.?(c|m)ts?(x)ā.?(c|m)js; - preserves ECMAScript modules (i.e. no CommonJS conversion); and
- enables support for import attributes.
Option 1: š package.json
{
"babel": {
"extends": "bitumen/configuration/babel"
}
}Option 2: š babel.config.js
import base from 'bitumen/configuration/babel';
export default {
...base,
// custom configuration and overrides
};ESLint
Configuration for JavaScript, TypeScript, and optionally React, based on:
| Plugin | Preset(s) |
|---|---|
@eslint/js | recommended |
@typescript-eslint | strict-type-checked, stylistic-type-checked |
eslint-plugin-import-x | recommended, typescript |
eslint-plugin-react | all |
eslint-plugin-react-hooks | recommended |
š .eslintrc.cjs
const base = require('bitumen/configuration/eslint');
const react = require('bitumen/configuration/eslint-react');
/** @type {import('eslint').Linter.Config} */
module.exports = {
...base,
...react,
// custom configuration and overrides
};Rollup
š rollup.config.js
import configure from 'bitumen/configuration/rollup';
import packageJson from './package.json';
export default configure(packageJson);configure() returns a configuration object which:
- Reads entry points from
package.json'sexportsfield (no conditionals, null targets, or patterns). - Writes distributable output to
DIST_PATH, mirroring the directory structure ofBUILD_PATH. - Writes CommonJS modules to
.cjsfiles and ES modules to.jsfiles. - Excludes test directories
__mocks__,__tests__from the output. - Copies Sass stylesheets (
.scss) fromSRC_PATHtoDIST_PATH. - Copies TypeScript type declarations (
.d.ts) fromBUILD_PATHtoDIST_PATH, giving them a.d.tsextension for ESM and a.d.ctsextension for CommonJS.
The following environment variables must be set at runtime:
BUILD_PATH: Where Babel andtscoutput files can be found.DIST_PATH: Where Rollup is to write its distributable output.FORMAT: Type of modules to output; either 'es' (ESM) or 'cjs' (CommonJS).SRC_PATH: Where the original source code is located.
TypeScript
š tsconfig.json
{
"extends": "bitumen/configuration/typescript",
// custom configuration and overrides
}Vitest
- Automatically clears mocks after each test,
- enables globals for automatic DOM clean-up between UI tests,
- looks for tests and mocks under
./src, - requires 100%
istanbulcoverage, - turns off watch mode by default, and
- uses thread workers for reduced overhead.
š vitest.config.js
import base from 'bitumen/configuration/vitest';
/** @type {import('vitest/config').UserConfig} */
export default {
...base,
// custom configuration and overrides
};Library
bitumen exposes named exports from the following entry points:
collectionsconfigurationmixinstypesutils
For example, to implement SortedSet from collections:
import {SortedSet} from 'bitumen/collections';
const set = new SortedSet();Type Declarations
For proper module and type resolution, set option compilerOptions.module to 'NodeNext' in jsconfig.json or tsconfig.json.
š” bitumen's TypeScript configuration is already set up this way.
9 months ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago