Skip to content

Commit

Permalink
BREAKING: Drop CommonJS
Browse files Browse the repository at this point in the history
This library no longer provides CommonJS exports
  • Loading branch information
evanplaice committed Nov 15, 2021
1 parent 8d4dae0 commit 74640b2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 95 deletions.
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
.github/
.vscode
*.spec.js
*.spec.cjs
*.tgz
39 changes: 28 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,42 @@ Mock-Console is a small ES module implementation of a console mock. It allows en
## Features

- ECMAScript Module
- CommonJS Bundle Included
- Typescript Compatible

## Installation
## Imports

This package works isomorphically in browser and server-side JavaScript

### Browser

Import directly from the local path or a CDN

```html
<script type="module">
import { MockConsole } from 'path/to/mock-console/index.js'
</script>
```

The minified version can be imported from

```html
<script type="module">
import { MockConsole } from 'path/to/mock-console/index.min.js'
</script>
```

### Node

Install the package

```sh
npm install @vanillaes/mock-console
```

Import using the module path

```javascript
import MockConsole from '@vanillaes/mock-console';
import { MockConsole } from '@vanillaes/mock-console'
```

## Usage
Expand Down Expand Up @@ -93,14 +118,6 @@ console.log(logger.logs);
> []
```

## CommonJS

A `.cjs` bundle is included for CommonJS compatibility

```javascript
const MockConsole = require('@vanillaes/mock-console').MockConsole;
```

## Typings

Typings are generated from JSDoc using Typescript. They are 100% compatible with VSCode Intellisense and will work seamlessly with Typescript.
56 changes: 0 additions & 56 deletions index.cjs

This file was deleted.

14 changes: 3 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,28 @@
"type": "module",
"exports": {
"import": "./index.js",
"require": "./index.cjs",
"browser": "./index.min.js"
},
"types": "index.d.ts",
"scripts": {
"test": "tape-es",
"test:watch": "tape-watch-es",
"test:compat": "node test/compat.spec.cjs",
"lint": "esmtk lint",
"types": "npx -p typescript tsc index.js -t esnext --allowJS --checkJS --skipLibCheck --noEmit",
"build": "npm run build:cjs && npm run build:min && npm run build:typings",
"build:cjs": "esmtk commonjs index.js index.cjs",
"build": "npm run build:min && npm run build:typings",
"build:min": "esmtk minify index.js index.min.js",
"build:typings": "npx -p typescript tsc index.js -t esnext --allowJS --checkJS --skipLibCheck --declaration --emitDeclarationOnly --noEmitOnError",
"clean": "npm run clean:builds && npm run clean:typings",
"clean:builds": "npx rimraf index.cjs && npx rimraf index.min.js",
"clean:builds": "npx rimraf index.min.js",
"clean:typings": "npx rimraf *.d.ts",
"package": "npx rimraf package && npm pack | tail -n 1 | xargs tar -xf",
"preversion": "npm test && npm run test:compat && npm run lint && npm run types",
"preversion": "npm test && npm run lint && npm run types",
"postversion": "git push --follow-tags"
},
"devDependencies": {
"esmtk": "^0.5.13",
"tape-es": "^1.2.16"
},
"standard": {
"ignore": [
"index.cjs"
]
},
"engines": {
"node": ">=14"
}
Expand Down
16 changes: 0 additions & 16 deletions test/compat.spec.cjs

This file was deleted.

0 comments on commit 74640b2

Please sign in to comment.