Skip to content

Commit

Permalink
build: move to ESM only and minimize build
Browse files Browse the repository at this point in the history
This commit moves the library to ESM only, and minimizes the build step by
writing the code in normal JavaScript with JSDoc comments. This reduces the need
for the build step to producing type declarations from the code, while still
maintaining type safety through checking the JSDoc comments.

BREAKING CHANGE: the library is now ESM-only, which means it cannot be used with
`require`.
  • Loading branch information
ianprime0509 committed Feb 4, 2022
1 parent 2899ed4 commit 6f7cff5
Show file tree
Hide file tree
Showing 19 changed files with 6,735 additions and 16,659 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*.d.ts
.vscode
dist
node_modules
website
18 changes: 0 additions & 18 deletions .eslintrc.cjs

This file was deleted.

19 changes: 19 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"root": true,
"extends": ["eslint:recommended"],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"env": {
"es2021": true
},
"overrides": [
{
"files": "test/*.js",
"env": {
"node": true
}
}
]
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
*.d.ts
.vscode
dist
node_modules
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*.d.ts
.vscode
dist
node_modules
website/.docusaurus
website/build
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ You can also use a CDN, such as [esm.sh](https://esm.sh), directly from a
browser or Deno:

```js
import { PitchDetector } from "https://esm.sh/pitchy@3";
import { PitchDetector } from "https://esm.sh/pitchy@4";
```

Note that this package is
[ESM-only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c),
meaning it can't be used with `require`. However, it can still be used from
CommonJS code, albeit only in async contexts, using dynamic `import`:

```js
const { PitchDetector } = await import("pitchy");
```

## Examples and documentation
Expand Down
Loading

0 comments on commit 6f7cff5

Please sign in to comment.