Skip to content

Commit

Permalink
Restructure exports in package.json
Browse files Browse the repository at this point in the history
I mainly followed the recommendations from https://github.com/frehner/modern-guide-to-packaging-js-library with one exception: We don't use `browser` anymore, but consider the browser-versions the default. Node 12+ will automatically resolve to the node-version as it supports the new `exports` syntax.

`arethetypeswrong` and `publint` are also happy:

```
$ npx @arethetypeswrong/cli --pack .
tus-js-client v4.1.0

Build tools:
- typescript@^5.4.5

 No problems found 🌟

┌───────────────────┬─────────────────┬──────────────────────────────┐
│                   │ "tus-js-client" │ "tus-js-client/package.json" │
├───────────────────┼─────────────────┼──────────────────────────────┤
│ node10            │ 🟢              │ 🟢 (JSON)                    │
├───────────────────┼─────────────────┼──────────────────────────────┤
│ node16 (from CJS) │ 🟢 (CJS)        │ 🟢 (JSON)                    │
├───────────────────┼─────────────────┼──────────────────────────────┤
│ node16 (from ESM) │ 🟢 (ESM)        │ 🟢 (JSON)                    │
├───────────────────┼─────────────────┼──────────────────────────────┤
│ bundler           │ 🟢              │ 🟢 (JSON)                    │
└───────────────────┴─────────────────┴──────────────────────────────┘
$ npx publint
tus-js-client lint results:
All good!
```
  • Loading branch information
Acconut committed May 17, 2024
1 parent 3407b9b commit 4e349f5
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,45 @@
"name": "tus-js-client",
"version": "4.1.0",
"description": "A pure JavaScript client for the tus resumable upload protocol",
"type": "module",
"main": "lib.es5/node/index.js",
"module": "lib.esm/node/index.js",
"files": [
"lib/**/*",
"lib.es5/**/*",
"lib.esm/**/*",
"dist/**/*",
"lib/index.d.ts"
"dist/**/*"
],
"browser": {
"./lib.es5/node/index.js": "./lib.es5/browser/index.js",
"./lib.esm/node/index.js": "./lib.esm/browser/index.js",
"./lib/node/index.js": "./lib/browser/index.js"
"type": "module",
"exports": {
".": {
"node": {
"module": "./lib.esm/node/index.js",
"import": {
"types": "./lib.esm/node/index.d.ts",
"default": "./lib.esm/node/index.js"
},
"require": {
"types": "./lib.es5/node/index.js",
"default": "./lib.es5/node/index.js"
},
"default": "./lib.esm/node/index.js"
},
"default": {
"module": "./lib.esm/browser/index.js",
"import": {
"types": "./lib.esm/browser/index.d.ts",
"default": "./lib.esm/browser/index.js"
},
"require": {
"types": "./lib.es5/browser/index.js",
"default": "./lib.es5/browser/index.js"
},
"default": "./lib.esm/browser/index.js"
}
},
"./package.json": "./package.json"
},
"types": "./lib/index.d.ts",
"types": "./lib.esm/browser/index.d.ts",
"main": "./lib.es5/browser/index.js",
"module": "./lib.esm/browser/index.js",
"engines": {
"node": ">=18"
},
Expand Down

0 comments on commit 4e349f5

Please sign in to comment.