tsndr / cloudflare-worker-jwt

A lightweight JWT implementation with ZERO dependencies for Cloudflare Workers.
MIT License
649 stars 51 forks source link

Changes to NodeJS ESM Syntax #47

Closed richajak closed 10 months ago

richajak commented 10 months ago

Hi Toby,

The latest release v2.2.9 has issue with NodeJS release v21.1. The issue did not exist with release v2.2.5


/home/xxx/node_modules/@tsndr/cloudflare-worker-jwt/index.js:94 export async function verify(token, secret, options = { algorithm: 'HS256', skipValidation: false, throwError: false }) { ^^^^^^

SyntaxError: Unexpected token 'export'


I tried to do some digging, it looks like NodeJS has recently made some changes in their ESM Syntax Current Workaround to solve this problem: $ node --experimental-detect-module app.js

Here is the release note of NodeJS by @targos @GeoffreyBooth https://github.com/nodejs/node/releases/tag/v21.1.0

Thanks Richard

0x80 commented 10 months ago

Shouldn't the package file contain an "exports" field?

See https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

tsndr commented 10 months ago

I've added @0x80's recommendation, can you (@richajak) please try again with v2.2.10? 🙂

richajak commented 10 months ago

Thanks, it works