2.3.0 ā€¢ Published 2 months ago

bitumen v2.3.0

Weekly downloads
-
License
BSD-2-Clause
Repository
github
Last release
2 months ago

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's exports field (no conditionals, null targets, or patterns).
  • Writes distributable output to DIST_PATH, mirroring the directory structure of BUILD_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) from SRC_PATH to DIST_PATH.
  • Copies TypeScript type declarations (.d.ts) from BUILD_PATH to DIST_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 and tsc 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.3.0

2 months ago

2.2.0

4 months ago

2.1.0

4 months ago

1.2.0

9 months ago

1.1.0

10 months ago

2.0.0

7 months ago

1.0.0

11 months ago

0.10.0

12 months ago

0.11.0

11 months ago

0.9.0

1 year ago

0.8.0

1 year ago

0.7.0

1 year ago

0.3.0

2 years ago

0.5.0

1 year ago

0.4.0

2 years ago

0.3.1

2 years ago

0.6.1

1 year ago

0.6.0

1 year ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago