diff --git a/.gitignore b/.gitignore index c6d0d10..3bd6c94 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ -/node_modules -/index.js +/cjs +/esm /index.d.ts +/index.js +/node_modules /test.js +/umd diff --git a/README.md b/README.md index 1f2c2c0..a823fc0 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ ## Features - Flow and TypeScript declarations included. +- CommonJS, UMD and ESM modules provided. - Zero dependencies. ## Installation diff --git a/package.json b/package.json index a486d1f..b8a2f8f 100644 --- a/package.json +++ b/package.json @@ -11,19 +11,25 @@ "intersect", "subset" ], - "main": "index.js", + "main": "cjs/index.js", "author": "Haydn Ewers", "license": "MIT", "private": false, "scripts": { - "build": "tsc index.ts --downlevelIteration --lib ES2015 -d", + "build": "yarn build:declaration && yarn build:cjs && yarn build:umd && yarn build:esm", + "build:declaration": "tsc index.ts --downlevelIteration --declaration --emitDeclarationOnly", + "build:cjs": "tsc index.ts --downlevelIteration --target ES2015 --module CommonJS --outDir cjs", + "build:umd": "tsc index.ts --downlevelIteration --target ES2015 --module UMD --outDir umd", + "build:esm": "tsc index.ts --target ESNext --module ESNext --outDir esm", "test": "tsc test.ts --downlevelIteration --lib ES2015 && node test.js", "release": "np" }, "files": [ "index.d.ts", "index.js.flow", - "index.js", + "cjs/index.js", + "umd/index.js", + "esm/index.js", "LICENSE", "README.md" ], diff --git a/test.ts b/test.ts index 3ecc8b0..833e858 100644 --- a/test.ts +++ b/test.ts @@ -10,7 +10,7 @@ import { strictSubset, superset, strictSuperset -} from "./"; +} from "./index"; assert.deepEqual(set(), new Set());