nuxt-auth-utils icon indicating copy to clipboard operation
nuxt-auth-utils copied to clipboard

Prefer Single Exports Over `oauth`

Open harlan-zw opened this issue 1 year ago • 1 comments

Currently, users will set up their endpoints by accessing one of the oauth.*.

export const oauth = {
  githubEventHandler,
  spotifyEventHandler,
  googleEventHandler,
  twitchEventHandler,
  auth0EventHandler,
  microsoftEventHandler,
  discordEventHandler,
  battledotnetEventHandler,
  keycloakEventHandler,
  linkedinEventHandler,
  cognitoEventHandler
};

This works and the auto-completion is nice but I think it can be improved:

  • treeshaking afaik won't work as all providers are within the same const, meaning we will bundle all providers (which will grow)
  • oauth seems likely for collisions in global import namespace

Exporting each provider as its own function should fix tree shaking and namespace problems, i.e authGoogleEventHandler where autocompletion should be good.

harlan-zw avatar Feb 07 '24 05:02 harlan-zw

Agree with you, I though about it as well at first and forgot about treeshaking.

Will be a breaking chance then, adding it for next major version.

atinux avatar Feb 17 '24 15:02 atinux