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

browser-ponyfill not fixed #56

Closed
jeanengelbrecht02 opened this issue Oct 3, 2023 · 8 comments
Closed

browser-ponyfill not fixed #56

jeanengelbrecht02 opened this issue Oct 3, 2023 · 8 comments

Comments

@jeanengelbrecht02
Copy link

#54 (comment)

The requested module '/_nuxt/node_modules/.pnpm/[email protected]/node_modules/cross-fetch/dist/browser-ponyfill.js?v=7c73fe01' does not provide an export named 'default

@franzwilding
Copy link

franzwilding commented Oct 4, 2023

I habe the same problem here. I think graphql-request is still importing cross-fetch, even if this module has dropped the dependency since 7.0.1.

I also tried to override fetch via config options, however I think also this is broken at the moment, as no options get passed to the graphql-request client:

export default defineNuxtConfig({
    modules: ['nuxt-graphql-request'],
    graphql: {
        useFetchPolyfill: true,
        clients: {
            default: {
                endpoint: 'XXX',
                options: {
                    responseMiddleware: responseMiddleware,
                    fetch: fetch,
                },
            }
        }

    },
    runtimeConfig: {
        public: {
            graphql: {
                clients: {
                    default: {
                        endpoint: 'XXX',
                        options: {
                            responseMiddleware: responseMiddleware,
                            fetch: fetch,
                        },
                    },
                },
            },
        },
    },
});

When I dump #build/graphql.options.mjs or nuxtApp.$config.public.graphql:

{
  clients: {
    default: { endpoint: 'XXX', options: {} }
  }
}

@lustremedia
Copy link

I think it is not fixed in 7.0.1 and these tickets are related ... #55

@lustremedia
Copy link

@Gomah can I assist you in fixing the issue?

@Gomah
Copy link
Owner

Gomah commented Oct 11, 2023

Unfortunately, that's inheriting from the graphql-request package, try to transpile nuxt-graphql-request in your nuxt.config.ts:

 build: {
    transpile: ['nuxt-graphql-request'],
  },

@lustremedia
Copy link

What does transpile do?
Does this also apply when running in dev?
Does qraphql-request need to fix this? Or is there a bug request already?

@Gomah
Copy link
Owner

Gomah commented Oct 20, 2023

What does transpile do?

It transpiles the declared dependencies using Babel instead.

Does qraphql-request need to fix this? Or is there a bug request already?

graphql-request uses cross-fetch under the hood but it's more of an ESM/CJS conflict. Related issue: lquixada/cross-fetch#120

@Gomah Gomah closed this as completed Oct 20, 2023
@jovrtn
Copy link

jovrtn commented Nov 10, 2023

Still getting this error in 7.0.4 with Nuxt 3.8.1. I was able to find a workaround by adding this to nuxt.config.ts:

alias: {
  "cross-fetch": "cross-fetch/dist/browser-ponyfill.js",
},

I do not have anything in my my build transpile array.

@nicolashmln
Copy link

@jovrtn same thing with nuxt 3.8.4, your fix working for me

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

No branches or pull requests

6 participants