Skip to content

Commit

Permalink
fix CJS and ESM support
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikprijck committed Jul 22, 2023
1 parent b77ee9e commit 3a3dce8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "jwt-decode",
"version": "3.1.2",
"description": "Decode JWT tokens, mostly useful for browser applications.",
"main": "dist/jwt-decode.cjs.js",
"module": "dist/jwt-decode.esm.js",
"main": "dist/cjs/jwt-decode.js",
"module": "dist/esm/jwt-decode.js",
"types": "dist/typings/index.d.ts",
"keywords": [
"jwt",
Expand All @@ -18,6 +18,7 @@
"scripts": {
"dev": "rollup -m -c",
"build": "rimraf dist && rollup -m -c --environment NODE_ENV:production",
"postbuild": "echo '{\"type\": \"commonjs\"}'> dist/cjs/package.json",
"test": "npm run test:node && npm run test:browser",
"test:node": "jest --coverage",
"test:browser": "jest --coverage --testEnvironment=jsdom"
Expand Down Expand Up @@ -55,10 +56,11 @@
"engines": {
"node": ">=16"
},
"type": "module",
"exports": {
".": {
"require": "./dist/jwt-decode.cjs.js",
"import": "./dist/jwt-decode.esm.js",
"require": "./dist/cjs/jwt-decode.js",
"import": "./dist/esm/jwt-decode.js",
"types": "./dist/typings/index.d.ts"
}
}
Expand Down
4 changes: 2 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default [{
input: "lib/index.cjs.ts",
output: [{
name: EXPORT_NAME,
file: "dist/jwt-decode.cjs.js",
file: "dist/cjs/jwt-decode.js",
format: "cjs",
exports: "auto",
}, ],
Expand All @@ -65,7 +65,7 @@ export default [{
input: "lib/index.ts",
output: [{
name: EXPORT_NAME,
file: "dist/jwt-decode.esm.js",
file: "dist/esm/jwt-decode.js",
format: "esm",
}, ],
plugins: [!isProduction &&
Expand Down

0 comments on commit 3a3dce8

Please sign in to comment.