Kim-Jun-Un
Kim-Jun-Un

Reputation: 83

Compile error with a lot of errors from webpack

I am receiving error, compiling graphql doesn't work because of the graphql-js dependency.

Version: webpack 4.43.0
Time: 69237ms
Built at: 01/12/2021 3:01:04 PM
 35 assets
Entrypoint main = assets/vendors~896.bundle.js assets/page.js

ERROR in ./node_modules/graphql/index.mjs 12:0-65:205
Can't reexport the named export 'BREAK' from non EcmaScript module (only default export is available)
 @ ./node_modules/graphql-tag/lib/index.js
 @ ./node_modules/apollo-boost/lib/bundle.esm.js
 @ ./src/apollo/client.ts
 @ ./src/App.tsx
 @ ./src/client.js

ERROR in ./node_modules/graphql/index.mjs 20:0-87:42
Can't reexport the named export 'SAMPLE' from non EcmaScript module (only default export is available)
 @ ./node_modules/graphql-tag/lib/index.js
 @ ./node_modules/apollo-boost/lib/bundle.esm.js
 @ ./src/apollo/client.ts
 @ ./src/App.tsx
 @ ./src/client.js

ERROR in ./node_modules/graphql/index.mjs 99:0-80:50
Can't reexport the named export 'SAMPLE' from non EcmaScript module (only default export is available)
 @ ./node_modules/graphql-tag/lib/index.js
 @ ./src/apollo/client.ts
 @ ./src/App.tsx
 @ ./src/client.js

ERROR: Can't reexport the named export 'BREAK' from non EcmaScript module (only default export is available)

and a million more of these.
ps. let me know if you need more details

Upvotes: 4

Views: 4391

Answers (2)

user13641108
user13641108

Reputation:

I had this same issue yesterday and followed this answer from github and I add '.mjs' to my configureWebpack extensions. and to the rules. Just make sure to appear before .js'. So basically you will have as follow :

const config = {
 configureWebpack: {
   resolve: { // .mjs comes before .js 
     extensions: ['*', '.mjs', '.js', '.json', '.gql', '.graphql']
   },
   module: {
     rules: [ 
       {
         test: /\.mjs$/,
         include: /node_modules/,
         type: 'javascript/auto'
       },
       // all the other rules
     ]
   }
 }
}

module.exports = config

Upvotes: 0

keinsell
keinsell

Reputation: 518

Try to use require(“module”) or if that's the way you doing it, you sould try import("module"). Maybe this will help.

Upvotes: 0

Related Questions