bitumen v2.3.0
Overview
bitumen
is a collection of classes, types, utilities, and opinionated configuration for Babel, ESLint, JavaScript, rollup.js, and TypeScript.
Supported Environments
- Client side: Last two versions of Chrome, Edge, Firefox (+ ESR), and Safari
- Server side: Maintained versions of Node.js
Usage
Configuration
Babel
Option 1: š package.json
{
"babel": {
"extends": "bitumen/configuration/babel"
}
}
Option 2: š babel.config.cjs
const base = require('bitumen/configuration/babel');
module.exports = {
...base,
// custom configuration and overrides
};
ESLint
š .eslintrc.cjs
const base = require('bitumen/configuration/eslint');
const react = require('bitumen/configuration/eslint-react');
module.exports = {
...base,
...react,
// custom configuration and overrides
};
rollup.js
š 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
'sexports
field (no conditionals, null targets, or patterns). - Writes distributable output to
DIST_PATH
, mirroring the directory structure ofBUILD_PATH
. - Writes CommonJS modules to
.cjs
files and ES modules to.js
files. - Excludes Jest directories
__mocks__
,__tests__
from the output. - Copies Sass stylesheets (
.scss
) fromSRC_PATH
toDIST_PATH
. - Copies TypeScript type declarations (
.d.ts
) fromBUILD_PATH
toDIST_PATH
, giving them a.d.ts
extension for ECMAScript and a.d.cts
extension for CommonJS.
The following environment variables must be set at runtime:
BUILD_PATH
: Where Babel andtsc
write their.js
and.d.ts
files.DIST_PATH
: Where rollup.js is to write its distributable output.FORMAT
: Type of modules to output; either 'es' (ES) or 'cjs' (CommonJS).SRC_PATH
: Where the original source code is located.
TypeScript
š jsconfig.json
{
"extends": "bitumen/configuration/javascript"
}
š tsconfig.json
{
"extends": "bitumen/configuration/typescript",
// `exclude`, `files`, and `include` paths must be set locally;
// see https://github.com/microsoft/TypeScript/issues/45050
"include": ["./src/"]
}
Library
bitumen
exposes named exports from the following entry points:
collections
configuration
mixins
types
utils
For example, to implement SortedSet
from collections
:
import {SortedSet} from 'bitumen/collections';
const set = new SortedSet();
Type Declarations
For proper module and type resolution, use the following project settings:
š jsconfig.json
{
"compilerOptions": {
"checkJs": true,
"module": "NodeNext",
"strictNullChecks": true // optional but recommended
}
}
š tsconfig.json
{
"compilerOptions": {
"module": "NodeNext"
}
}
š” bitumen
's JavaScript and TypeScript configurations are already set up this way.
2 months ago
4 months ago
4 months ago
9 months ago
10 months ago
7 months ago
11 months ago
12 months ago
11 months ago
1 year ago
1 year ago
1 year ago
2 years ago
1 year ago
2 years ago
2 years ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago