From 1aa9035552bbcb34b95e092d0f082cc6d94465ab Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Thu, 3 Sep 2020 20:47:29 +0200 Subject: [PATCH] feat: added support for ESM (ECMAScript modules) BREAKING CHANGE: due to added ESM module support Node.js version with ESM implementation bugs are no longer supported, this only affects early v13.x versions. The resulting Node.js semver range is `>=10.13.0 < 13 || >=13.7.0` --- .github/workflows/test.yml | 2 +- lib/index.mjs | 9 +++++++++ package.json | 12 ++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 lib/index.mjs diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 81adfeb76f..cd3356c480 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -48,7 +48,7 @@ jobs: - 11 - 12.0.0 - 12 - - 13.0.0 + - 13.7.0 - 13 - 14.0.0 - 14 diff --git a/lib/index.mjs b/lib/index.mjs new file mode 100644 index 0000000000..0dd40d1003 --- /dev/null +++ b/lib/index.mjs @@ -0,0 +1,9 @@ +import mod from './index.js' + +export default mod +export const JWE = mod.JWE +export const JWK = mod.JWK +export const JWKS = mod.JWKS +export const JWS = mod.JWS +export const JWT = mod.JWT +export const errors = mod.errors diff --git a/package.json b/package.json index 1f61657bfc..4921b732e1 100644 --- a/package.json +++ b/package.json @@ -45,18 +45,22 @@ "funding": "https://github.com/sponsors/panva", "license": "MIT", "author": "Filip Skokan ", + "exports": { + "import": "./lib/index.mjs", + "require": "./lib/index.js" + }, + "main": "lib/index.js", + "types": "types/index.d.ts", "files": [ "lib/**/*.js", "LICENSE_THIRD_PARTY", "types/index.d.ts" ], - "main": "lib/index.js", - "types": "types/index.d.ts", "scripts": { "coverage": "c8 ava", "lint": "standard", - "lint-ts": "npx typescript@~3.6.0 --build types", "lint-fix": "standard --fix", + "lint-ts": "npx typescript@~3.6.0 --build types", "test": "ava", "watch": "ava --watch" }, @@ -90,7 +94,7 @@ "standard": "^14.3.1" }, "engines": { - "node": ">=10.13.0" + "node": ">=10.13.0 < 13 || >=13.7.0" }, "standard": { "parser": "babel-eslint"