kevinbeaty / any-promise

NOTE: You probably want native promises now
MIT License
179 stars 17 forks source link

Getting this error every time I run Koa Server #31

Open paramsinghvc opened 5 years ago

paramsinghvc commented 5 years ago
WARNING in /app/node_modules/any-promise/register.js 24:14-37
[1] Critical dependency: the request of a dependency is an expression
[1]  @ /app/node_modules/any-promise/index.js
[1]  @ /app/node_modules/koa-compose/index.js
[1]  @ /app/node_modules/koa-convert/index.js
[1]  @ /app/node_modules/koa/lib/application.js
[1]  @ ./server/index.ts
svltmccc commented 4 years ago

@paramsinghvc it happened because register.js has dynamic import on 24 line:

var lib = require(implementation)

It means webpack can't resolve the require statically and imports entire package

You can read this part of webpack docs: https://webpack.js.org/guides/dependency-management/#require-with-expression

It can be solved using ContextReplacementPlugin, for example you can add "fake" config in your webpack to suppress this warning

plugins: [
    new ContextReplacementPlugin(/any-promise/)
]