#Graphql-request causes Rollup to fail when building extension

8 messages · Page 1 of 1 (latest)

quick zinc
#

I added graphql and graphql-request to my extension and wanted to use them to interface with an external graphql API.
Unfortunately when using the request and gql functions from graphql-request the extension stopped compiling and I started getting this error:

[RollupError] Unexpected token (Note that you need plugins to import files that are not JavaScript)

/home/banze/projects/data-cms/node_modules/.pnpm/[email protected]/node_modules/graphql/jsutils/instanceOf.mjs:12:35
10:   /* c8 ignore next 6 */
11:   // FIXME: https://github.com/graphql/graphql-js/issues/2317
12:   globalThis.process && globalThis.process.env.NODE_ENV === 'production'
                                       ^
13:     ? function instanceOf(value, constructor) {
14:         return value instanceof constructor;
RollupError: Unexpected token (Note that you need plugins to import files that are not JavaScript)
    at error (file:///home/banze/projects/data-cms/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:2125:30)
    at Module.error (file:///home/banze/projects/data-cms/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:13452:16)
    at Module.tryParse (file:///home/banze/projects/data-cms/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:14173:25)
    at Module.setSource (file:///home/banze/projects/data-cms/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:13775:39)
    at ModuleLoader.addModuleSource (file:///home/banze/projects/data-cms/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:23771:20)

weak templeBOT
#

Thanks for posting! This is a community powered server, so you may or may not get an answer based on available help and expertise. To increase your chances of somebody being able to help you, please help us help you making sure you:

  • Adding an explanation of exactly what you're trying to achieve.
  • Adding any and all related code or previous attempts.
  • Describing the exact issue or error you are facing.
  • Posting any screenshots if applicable.
  • Reading through https://stackoverflow.com/help/how-to-ask.

When you're done with this thread, please close it. Thanks! ✨

(If you have a support agreement and need help, please contact the core team via email.)

twin locust
#

[RollupError] Unexpected token (Note that you need plugins to import files that are not JavaScript)
Any clue what graphql-request is trying to import that is not javascript? usually something like *.json/*.css/etc

quick zinc
twin locust
#

interesting that should just be javascript

#

does it help if you add "type": "module" in your package.json?

quick zinc
#

It is already set to "type": "module" :/

quick zinc