nestjs / graphql

GraphQL (TypeScript) module for Nest framework (node.js) 🍷
https://docs.nestjs.com/graphql/quick-start
MIT License
1.45k stars 392 forks source link

Webpack and @nestjs/graphql fails to build #78

Closed danil-z closed 5 years ago

danil-z commented 5 years ago

I'm submitting a...


[ ] Regression 
[ x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Webpack and @nestjs/graphql fails to build. Getting errors during Webpack execution:

WARNING in ./node_modules/@nestjs/common/utils/load-package.util.js 8:15-35
Critical dependency: the request of a dependency is an expression
 @ ./node_modules/@nestjs/core/nest-factory.js
 @ ./node_modules/@nestjs/core/index.js
 @ ./src/main.ts
 @ multi webpack/hot/poll?1000 ./src/main.ts

WARNING in ./node_modules/optional/optional.js 6:11-26
Critical dependency: the request of a dependency is an expression
 @ ./node_modules/@nestjs/core/nest-application.js
 @ ./node_modules/@nestjs/core/index.js
 @ ./src/main.ts
 @ multi webpack/hot/poll?1000 ./src/main.ts

WARNING in ./node_modules/merge-graphql-schemas/dist/index.esm.js 3781:21-31
Critical dependency: the request of a dependency is an expression
 @ ./node_modules/@nestjs/graphql/dist/graphql-types.loader.js
 @ ./node_modules/@nestjs/graphql/dist/index.js
 @ ./node_modules/@nestjs/graphql/index.js
 @ ./src/app.module.ts
 @ ./src/main.ts
 @ multi webpack/hot/poll?1000 ./src/main.ts

WARNING in ./node_modules/express/lib/view.js 81:13-25
Critical dependency: the request of a dependency is an expression
 @ ./node_modules/express/lib/application.js
 @ ./node_modules/express/lib/express.js
 @ ./node_modules/express/index.js
 @ ./node_modules/@nestjs/core/adapters/express-adapter.js
 @ ./node_modules/@nestjs/core/nest-factory.js
 @ ./node_modules/@nestjs/core/index.js
 @ ./src/main.ts
 @ multi webpack/hot/poll?1000 ./src/main.ts

WARNING in ./node_modules/apollo-server-core/node_modules/ws/lib/buffer-util.js
Module not found: Error: Can't resolve 'bufferutil' in '/Users/danil/Developer/12-graphql-apollo/node_modules/apollo-server-core/node_modules/ws/lib'
 @ ./node_modules/apollo-server-core/node_modules/ws/lib/buffer-util.js
 @ ./node_modules/apollo-server-core/node_modules/ws/lib/sender.js
 @ ./node_modules/apollo-server-core/node_modules/ws/index.js
 @ ./node_modules/apollo-server-core/node_modules/subscriptions-transport-ws/dist/server.js
 @ ./node_modules/apollo-server-core/node_modules/subscriptions-transport-ws/dist/index.js
 @ ./node_modules/apollo-server-core/dist/ApolloServer.js
 @ ./node_modules/apollo-server-core/dist/index.js
 @ ./node_modules/apollo-server-express/dist/index.js
 @ ./node_modules/@nestjs/graphql/dist/graphql.module.js
 @ ./node_modules/@nestjs/graphql/dist/index.js
 @ ./node_modules/@nestjs/graphql/index.js
 @ ./src/app.module.ts
 @ ./src/main.ts
 @ multi webpack/hot/poll?1000 ./src/main.ts

WARNING in ./node_modules/apollo-server-core/node_modules/ws/lib/validation.js
Module not found: Error: Can't resolve 'utf-8-validate' in '/Users/danil/Developer/12-graphql-apollo/node_modules/apollo-server-core/node_modules/ws/lib'
 @ ./node_modules/apollo-server-core/node_modules/ws/lib/validation.js
 @ ./node_modules/apollo-server-core/node_modules/ws/lib/sender.js
 @ ./node_modules/apollo-server-core/node_modules/ws/index.js
 @ ./node_modules/apollo-server-core/node_modules/subscriptions-transport-ws/dist/server.js
 @ ./node_modules/apollo-server-core/node_modules/subscriptions-transport-ws/dist/index.js
 @ ./node_modules/apollo-server-core/dist/ApolloServer.js
 @ ./node_modules/apollo-server-core/dist/index.js
 @ ./node_modules/apollo-server-express/dist/index.js
 @ ./node_modules/@nestjs/graphql/dist/graphql.module.js
 @ ./node_modules/@nestjs/graphql/dist/index.js
 @ ./node_modules/@nestjs/graphql/index.js
 @ ./src/app.module.ts
 @ ./src/main.ts
 @ multi webpack/hot/poll?1000 ./src/main.ts

ERROR in ./node_modules/node-fetch/lib/index.mjs 496:11-22
Can't import the named export 'PassThrough' from non EcmaScript module (only default export is available)
 @ ./node_modules/apollo-server-env/dist/polyfills/fetch.js
 @ ./node_modules/apollo-server-env/dist/index.js
 @ ./node_modules/apollo-server-core/dist/index.js
 @ ./node_modules/apollo-server-express/dist/index.js
 @ ./node_modules/@nestjs/graphql/dist/graphql.module.js
 @ ./node_modules/@nestjs/graphql/dist/index.js
 @ ./node_modules/@nestjs/graphql/index.js
 @ ./src/app.module.ts
 @ ./src/main.ts
 @ multi webpack/hot/poll?1000 ./src/main.ts

ERROR in ./node_modules/node-fetch/lib/index.mjs 497:11-22
Can't import the named export 'PassThrough' from non EcmaScript module (only default export is available)
 @ ./node_modules/apollo-server-env/dist/polyfills/fetch.js
 @ ./node_modules/apollo-server-env/dist/index.js
 @ ./node_modules/apollo-server-core/dist/index.js
 @ ./node_modules/apollo-server-express/dist/index.js
 @ ./node_modules/@nestjs/graphql/dist/graphql.module.js
 @ ./node_modules/@nestjs/graphql/dist/index.js
 @ ./node_modules/@nestjs/graphql/index.js
 @ ./src/app.module.ts
 @ ./src/main.ts
 @ multi webpack/hot/poll?1000 ./src/main.ts

ERROR in ./node_modules/node-fetch/lib/index.mjs 1413:27-38
Can't import the named export 'PassThrough' from non EcmaScript module (only default export is available)
 @ ./node_modules/apollo-server-env/dist/polyfills/fetch.js
 @ ./node_modules/apollo-server-env/dist/index.js
 @ ./node_modules/apollo-server-core/dist/index.js
 @ ./node_modules/apollo-server-express/dist/index.js
 @ ./node_modules/@nestjs/graphql/dist/graphql.module.js
 @ ./node_modules/@nestjs/graphql/dist/index.js
 @ ./node_modules/@nestjs/graphql/index.js
 @ ./src/app.module.ts
 @ ./src/main.ts
 @ multi webpack/hot/poll?1000 ./src/main.ts

ERROR in ./node_modules/node-fetch/lib/index.mjs 1460:29-40
Can't import the named export 'PassThrough' from non EcmaScript module (only default export is available)
 @ ./node_modules/apollo-server-env/dist/polyfills/fetch.js
 @ ./node_modules/apollo-server-env/dist/index.js
 @ ./node_modules/apollo-server-core/dist/index.js
 @ ./node_modules/apollo-server-express/dist/index.js
 @ ./node_modules/@nestjs/graphql/dist/graphql.module.js
 @ ./node_modules/@nestjs/graphql/dist/index.js
 @ ./node_modules/@nestjs/graphql/index.js
 @ ./src/app.module.ts
 @ ./src/main.ts
 @ multi webpack/hot/poll?1000 ./src/main.ts

ERROR in ./node_modules/node-fetch/lib/index.mjs 1049:34-46
Can't import the named export 'STATUS_CODES' from non EcmaScript module (only default export is available)
 @ ./node_modules/apollo-server-env/dist/polyfills/fetch.js
 @ ./node_modules/apollo-server-env/dist/index.js
 @ ./node_modules/apollo-server-core/dist/index.js
 @ ./node_modules/apollo-server-express/dist/index.js
 @ ./node_modules/@nestjs/graphql/dist/graphql.module.js
 @ ./node_modules/@nestjs/graphql/dist/index.js
 @ ./node_modules/@nestjs/graphql/index.js
 @ ./src/app.module.ts
 @ ./src/main.ts
 @ multi webpack/hot/poll?1000 ./src/main.ts

ERROR in ./node_modules/node-fetch/lib/index.mjs 1194:9-15
Can't import the named export 'format' from non EcmaScript module (only default export is available)
 @ ./node_modules/apollo-server-env/dist/polyfills/fetch.js
 @ ./node_modules/apollo-server-env/dist/index.js
 @ ./node_modules/apollo-server-core/dist/index.js
 @ ./node_modules/apollo-server-express/dist/index.js
 @ ./node_modules/@nestjs/graphql/dist/graphql.module.js
 @ ./node_modules/@nestjs/graphql/dist/index.js
 @ ./node_modules/@nestjs/graphql/index.js
 @ ./src/app.module.ts
 @ ./src/main.ts
 @ multi webpack/hot/poll?1000 ./src/main.ts

ERROR in ./node_modules/node-fetch/lib/index.mjs 1142:16-21
Can't import the named export 'parse' from non EcmaScript module (only default export is available)
 @ ./node_modules/apollo-server-env/dist/polyfills/fetch.js
 @ ./node_modules/apollo-server-env/dist/index.js
 @ ./node_modules/apollo-server-core/dist/index.js
 @ ./node_modules/apollo-server-express/dist/index.js
 @ ./node_modules/@nestjs/graphql/dist/graphql.module.js
 @ ./node_modules/@nestjs/graphql/dist/index.js
 @ ./node_modules/@nestjs/graphql/index.js
 @ ./src/app.module.ts
 @ ./src/main.ts
 @ multi webpack/hot/poll?1000 ./src/main.ts

ERROR in ./node_modules/node-fetch/lib/index.mjs 1145:16-21
Can't import the named export 'parse' from non EcmaScript module (only default export is available)
 @ ./node_modules/apollo-server-env/dist/polyfills/fetch.js
 @ ./node_modules/apollo-server-env/dist/index.js
 @ ./node_modules/apollo-server-core/dist/index.js
 @ ./node_modules/apollo-server-express/dist/index.js
 @ ./node_modules/@nestjs/graphql/dist/graphql.module.js
 @ ./node_modules/@nestjs/graphql/dist/index.js
 @ ./node_modules/@nestjs/graphql/index.js
 @ ./src/app.module.ts
 @ ./src/main.ts
 @ multi webpack/hot/poll?1000 ./src/main.ts

ERROR in ./node_modules/node-fetch/lib/index.mjs 1149:15-20
Can't import the named export 'parse' from non EcmaScript module (only default export is available)
 @ ./node_modules/apollo-server-env/dist/polyfills/fetch.js
 @ ./node_modules/apollo-server-env/dist/index.js
 @ ./node_modules/apollo-server-core/dist/index.js
 @ ./node_modules/apollo-server-express/dist/index.js
 @ ./node_modules/@nestjs/graphql/dist/graphql.module.js
 @ ./node_modules/@nestjs/graphql/dist/index.js
 @ ./node_modules/@nestjs/graphql/index.js
 @ ./src/app.module.ts
 @ ./src/main.ts
 @ multi webpack/hot/poll?1000 ./src/main.ts

ERROR in ./node_modules/node-fetch/lib/index.mjs 1352:51-58
Can't import the named export 'resolve' from non EcmaScript module (only default export is available)
 @ ./node_modules/apollo-server-env/dist/polyfills/fetch.js
 @ ./node_modules/apollo-server-env/dist/index.js
 @ ./node_modules/apollo-server-core/dist/index.js
 @ ./node_modules/apollo-server-express/dist/index.js
 @ ./node_modules/@nestjs/graphql/dist/graphql.module.js
 @ ./node_modules/@nestjs/graphql/dist/index.js
 @ ./node_modules/@nestjs/graphql/index.js
 @ ./src/app.module.ts
 @ ./src/main.ts
 @ multi webpack/hot/poll?1000 ./src/main.ts
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! nest-typescript-starter@1.0.0 build:dev: `rimraf dist && webpack --config webpack.dev.js`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the nest-typescript-starter@1.0.0 build:dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/danil/.npm/_logs/2018-09-27T01_49_13_286Z-debug.log

Expected behavior

Should be able to build using Webpack.

Minimal reproduction of the problem with instructions

I took 12-graphql-apollo sample and added Webpack config

https://github.com/danil-z/webpack-nest-apollo

What is the motivation / use case for changing the behavior?

use Webpack to package bundle with all libs and use with naked node in production

Environment


Nest version: 5.3.6


For Tooling issues:
- Node version: 10 
- Platform: Mac 

Others:

Connum commented 5 years ago

@danil-z: I'm also encountering the Critical dependency: the request of a dependency is an expression error - have you found a way around this meanwhile?

danil-z commented 5 years ago

I stopped using webpack ;)

kamilmysliwiec commented 5 years ago

As far as I see, the reason is the webpack configuration. So far we don't support bundling node_modules together with an application due to this issue https://github.com/nestjs/nest/issues/1386

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.