Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare beta version #151

Merged
merged 35 commits into from
Jul 28, 2023
Merged

Prepare beta version #151

merged 35 commits into from
Jul 28, 2023

Conversation

frederikprijck
Copy link
Member

@frederikprijck frederikprijck commented Jul 22, 2023

Description

Prepares the repository for a new beta with the following changes:

  • No longer include a polyfil for atob, as this is supported in all major browsers (and node environments > 14).
  • Compile to ES2017, so dropping support for anything that does not support ES2017 (which should be very limited)
  • Use Node's atob when running on node.
  • Migrate to using Jest for tests to align with other SDKs
  • Migrate to using TypeScript to align with other SDKs and simplify build set up.
  • Run tests against Browser and Node environments
  • Drop support for Node 14, add support for Node 20.
  • Add support for package.json's exports field, for better CJS/ESM support
  • Reorganize build artifacts for better CJS/ESM support (cjs and esm needs to be their own directory with a cjs specific package.json file)
  • Drop manual UMD bundle creation in index.standalone.ts, but rely on rollup instead.
  • Infer JwtPayload and JwtHeader default types from the header argument by using overloads.

Additionally, this PR ensures the file size is decreased:

  • ESM from 1.4K to 1.1K (before gzip)
  • CJS from 1.4K to 1.1K (before gzip)
  • UMD from 4.1K to 2.6K (before gzip)

Even though some users might experience breaking changes, mostly because of the exports field, the majority should be able to update without making any changes, assuming the SDK is used in environments with support for atob.

References

This beta is mostly created as a result of #145 , as it makes sense to drop the polyfil but we feel like we do not want to do this in a non-major given the extensive usage of this SDK.

Testing

  • This change adds test coverage for new/changed/fixed functionality

Checklist

  • I have added documentation for new/changed functionality in this PR or in auth0.com/docs
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used, if not the default branch

@frederikprijck frederikprijck marked this pull request as ready for review July 26, 2023 07:35
@frederikprijck frederikprijck requested a review from a team as a code owner July 26, 2023 07:35
lib/index.ts Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
test/tests.ts Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
tsconfig.json Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
package.json Show resolved Hide resolved
@frederikprijck
Copy link
Member Author

Thanks to both of you reviewing! I think I addressed all comments, either by making the required changes or by adding a reply.

Copy link
Contributor

@jonkoops jonkoops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, future improvements can always be added later.

@frederikprijck
Copy link
Member Author

frederikprijck commented Jul 26, 2023

I am going to leave this one open for a little bit, just to give anyone else from #130 to give feedback.

Thanks for the feedback here @jonkoops and @Widcket as well, really appreciate it.

I did update the description after both of you approved to mention the decrease in bundle size, which isn't unimportant to call out 🔥 🚀 .

package.json Show resolved Hide resolved
@jonkoops
Copy link
Contributor

jonkoops commented Jul 27, 2023

Side-note, we just landed jwt-decode in Keycloak (your friendly neighborhood competitor). Happy we can collaborate on the shared code we all build on! 🦾

README.md Outdated Show resolved Hide resolved
@frederikprijck
Copy link
Member Author

force pushed to ensure this branch is up to date with master again so we can properly copy all commits to beta and keep then.

@frederikprijck frederikprijck merged commit 065c17a into beta Jul 28, 2023
1 check passed
@frederikprijck frederikprijck deleted the prepare/beta branch July 28, 2023 09:43
@jonkoops
Copy link
Contributor

@frederikprijck I've been reading up a bit on publishing packages in multiple module formats with TypeScript (the TypeScript handbook has a great guide for this). I think we'll have to compile types for each module format, and also slightly adjust the exports field for it.

I'm taking a deep dive on this today, so I will hopefully have something more concrete for that soon. But in the mean time I would advice we wait with publishing a new stable, just in case it might cause issues for users.

@frederikprijck
Copy link
Member Author

Thanks for the feedback. There are no plans to release a new stable, we will cut a beta and gather feedback. So we can always see and adjust 👍

@frederikprijck
Copy link
Member Author

frederikprijck commented Jul 28, 2023

@jonkoops I generated the types for both ESM and CJS locally, and they look identical (we have very basic types). So I think we might be good the way we have things configured atm.

We might be better of changing it, to be sure for the future. But for now, it looks like it works as is.

@jonkoops
Copy link
Contributor

jonkoops commented Jul 28, 2023

Ok, I will still take another look to be sure. These things unfortunately have many edge cases in my experience.

@cristobal
Copy link
Contributor

I installed the 4.0.0-beta.0 locally, however it seems not to have packaged all the files when creating the release
@frederikprijck ☝🏽 👇🏽
Screenshot 2023-07-29 at 12 13 59

See link here

Could you make another release to try out?

@frederikprijck
Copy link
Member Author

Thanks, our automated release setup wasnt properly ported to this repo (this is the first release we tried with jwt-decode using that, I should have followed up)

Fixed in #167, will create a follow up release

@frederikprijck
Copy link
Member Author

frederikprijck commented Jul 29, 2023

Cut a new release, it looks like it's okay now: https://www.npmjs.com/package/jwt-decode/v/4.0.0-beta.1?activeTab=code

Can you try again @cristobal ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants