Giter Club home page Giter Club logo

Comments (7)

masone avatar masone commented on June 13, 2024 1

Importing next-auth/client results in a

Error: only one instance of babel-polyfill is allowed

for us. I assume it's because we handle polyfilling ourselves in our custom webpack config already. Any advice on how I can proceed?

from next-auth.

iaincollins avatar iaincollins commented on June 13, 2024

Hello! Thanks for raising a ticket, I was going to raise one about this myself. I regard the bloat as a problem as well and want to address it in a future version.

Some options:

  • We don't need all of babel-polyfill, and we can (and should) cherry pick the features we actually need. If we could get this down to ~5-10KB I am probably not going to lose sleep over that, but I agree ~100KB is excessive. This is likely the first step as it's probably the quickest and easiest thing to do.

  • We could maybe distribute two versions of the client (and leave the default without IE support). If we did this, we would need to make sure that tree shaking works, so that only the version you are using actually gets bundled to the clients (and not both, which would just make things worse).

  • As you suggest we could try pushing the dependancy to those using next-auth, with instructions on what to do to include babel-polyfill. I agree this is preferable in principle, however I am not sure how we would do this as IIRC to work I think it needs to be included when the module is built.

from next-auth.

curran avatar curran commented on June 13, 2024

Regarding injecting the polyfills at the app level, I believe the order of execution depends on the order of imports, so if the app code imports babel-polyfill before it imports next-auth, the mutated polyfill globals should be there in the environment by the time any of the next-auth code runs. See related Rollup discussion rollup/rollup#1459

I also sort of like the idea of distributing two versions of the client. Maybe it could just be another entry point to the library, looking something like this:

import { NextAuth } from 'next-auth/client/withPolyfills'

from next-auth.

curran avatar curran commented on June 13, 2024

AFIAK if an app imports babel-polyfill before importing next-auth, the polyfills will work correctly. This could be the recommended approach for apps that need IE support and depend on next-auth. They do not need to be inside the Rollup bundle for next-auth.

With this approach it would be safe to remove the polyfills from next-auth completely.

Any thoughts?

from next-auth.

iaincollins avatar iaincollins commented on June 13, 2024

Just bumping to say I still plan to investigate this issue. I was just addressing some pressing issues and PRs which had been open for a while, but am going to try addressing this now.

from next-auth.

hipstersmoothie avatar hipstersmoothie commented on June 13, 2024

I am also getting the error @masone is getting. I'm not doing anything special but my app wont build unless is remove next-auth/client.

Here is the repo

https://github.com/hipstersmoothie/kikbak.tv/

EDIT:

It seems if I import import { NextAuth } from 'next-auth/client'; once it works, but if I import it in twice (in two files) I get Error: only one instance of babel-polyfill is allowed

from next-auth.

LoriKarikari avatar LoriKarikari commented on June 13, 2024

v2 is out now and v1 isn't supported anymore.

from next-auth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.