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

Use a default export for UMD module #181

Merged

Conversation

jonkoops
Copy link
Contributor

Creates an alias for jwtDecode as the default export for UMD modules. Since users of the UMD module are very unlikely to migrate this will give them maximum compatibility with previous versions.

@jonkoops jonkoops requested a review from a team as a code owner July 31, 2023 20:32
@jonkoops jonkoops mentioned this pull request Jul 31, 2023
3 tasks
@jonkoops jonkoops force-pushed the restore-default-umd branch 2 times, most recently from c51db6c to c2bac35 Compare July 31, 2023 20:40
@jonkoops
Copy link
Contributor Author

Going to add some documentation for this one, converting this to a draft.

@jonkoops jonkoops marked this pull request as draft July 31, 2023 20:45
@jonkoops
Copy link
Contributor Author

So for users using the UMD version (either globals, or AMD) the following migration steps would apply:

Globals

The global jwt_decode function has been renamed to jwtDecode, this matches the casing used internally as well.

Before

<script src="jwt-decode.js"></script>
<script>
    const token = "eyJhsw5c";
    const decoded = jwt_decode(token);
</script>

After

<script src="jwt-decode.js"></script>
<script>
    const token = "eyJhsw5c";
    const decoded = jwtDecode(token);
</script>

AMD

The AMD module name has been renamed from jwt_decode to jwt-decode, this matches the name of the NPM package.

Before

<script src="jwt-decode.js"></script>
<script>
  define(["jwt_decode"], (jwtDecode) => {
    const token = "eyJhsw5c";
    const decoded = jwtDecode(token);
  });
</script>

After

<script src="jwt-decode.js"></script>
<script>
  define(["jwt-decode"], (jwtDecode) => {
    const token = "eyJhsw5c";
    const decoded = jwtDecode(token);
  });
</script>

@frederikprijck do you feel these changes make sense? Alternatively, we can keep things as they were before for maximum backwards compatibility. Can go either way as far as I am concerned.

@jonkoops jonkoops marked this pull request as ready for review July 31, 2023 21:00
@frederikprijck
Copy link
Member

frederikprijck commented Jul 31, 2023

I would stick to what we had for AMD, changing UMD makes sense to me. I feel its unneccesary to have amd users have to make that change when it's working fine today, that wasn't the intention of the new major to begin with.

@jonkoops
Copy link
Contributor Author

Yeah, I have to agree with that. I've reverted this back so that it should be 1-1 backwards compatible with what was before.

I would stick to what we had for AMD, changing UMD makes sense to me.

Not quite sure what you mean here. Just to clarify AMD is a sub-set of UMD, UMD attempts to make AMD and CommonJS interoperable with each other.

What exactly do you mean by "changing UMD makes sense to me"? Are you perhaps referring to the global?

@frederikprijck frederikprijck merged commit d005f60 into auth0:fix/default-exports Jul 31, 2023
1 check passed
@jonkoops jonkoops deleted the restore-default-umd branch July 31, 2023 22:25
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.

2 participants