From d3fc8d9afa30ac9b1cb07ff7f48ed8f229b90879 Mon Sep 17 00:00:00 2001 From: frederikprijck Date: Mon, 14 Aug 2023 17:11:56 +0200 Subject: [PATCH 1/2] Drop UMD bundle --- README.md | 22 ++++++---------------- lib/index.umd.ts | 1 - rollup.config.ts | 13 +------------ 3 files changed, 7 insertions(+), 29 deletions(-) delete mode 100644 lib/index.umd.ts diff --git a/README.md b/README.md index 6ea672a..bbf1180 100644 --- a/README.md +++ b/README.md @@ -92,26 +92,16 @@ const { jwtDecode } = require('jwt-decode'); #### Include with a script tag -Copy the file `jwt-decode.js` from the root of the `build/` folder to your project somewhere, then include it like so: +Copy the file `jwt-decode.js` from the root of the `build/esm` folder to your project somewhere, then include it using `type="module"` on the corresponding script tag. +Once this script has loaded, the exported `jwtDecode` function will be available: ```html - -``` - -Once this script has loaded, the `jwt_decode` function will be exposed as a global: - -```javascript -const token = "eyJhsw5c"; -const decoded = jwt_decode(token); -``` - -Alternatively, if you are using the [Asynchronous Module Definition (AMD) API](https://github.com/amdjs/amdjs-api/blob/master/AMD.md), you can load the same function as follows: - -```javascript -define(["jwt_decode"], (jwtDecode) => { + ``` ## Feedback diff --git a/lib/index.umd.ts b/lib/index.umd.ts deleted file mode 100644 index 989b2da..0000000 --- a/lib/index.umd.ts +++ /dev/null @@ -1 +0,0 @@ -export { jwtDecode as default } from "./index.js"; diff --git a/rollup.config.ts b/rollup.config.ts index b45b0bb..cf953c4 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -14,18 +14,7 @@ const plugins = [ const input = "lib/index.ts"; -export default defineConfig([{ - input: "lib/index.umd.ts", - output: { - name: "jwt_decode", - file: "build/jwt-decode.js", - format: "umd", - sourcemap: true, - }, - plugins: [ - tsPlugin, - ] - }, +export default defineConfig([ { input, output: { From e039cf9f8a7a13675c892e02c3331e7853f8056a Mon Sep 17 00:00:00 2001 From: frederikprijck Date: Mon, 14 Aug 2023 17:13:32 +0200 Subject: [PATCH 2/2] update readme --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bbf1180..dc4ce06 100644 --- a/README.md +++ b/README.md @@ -92,13 +92,12 @@ const { jwtDecode } = require('jwt-decode'); #### Include with a script tag -Copy the file `jwt-decode.js` from the root of the `build/esm` folder to your project somewhere, then include it using `type="module"` on the corresponding script tag. -Once this script has loaded, the exported `jwtDecode` function will be available: +Copy the file `jwt-decode.js` from the root of the `build/esm` folder to your project somewhere, then import `jwtDecode` from it inside a script tag that's marked with `type="module"`: ```html