I'm trying to make kafkajs external dependency (move out from webpack bundle) with this config:
externals: {
kafkajs: 'kafkajs',
redis: 'redis'
}
Dependencies:
dependencies: {
...
"kafkajs": "^1.12.0",
...
}
But I'm getting error "Cannot find module":
{
"error": "Initialization has failed due to: Error: Cannot find module 'kafkajs'\n at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)\n at Function.Module._load (internal/modules/cjs/loader.js:507:25)\n at Module.require (internal/modules/cjs/loader.js:637:17)\n at require (internal/modules/cjs/helpers.js:22:18)\n at Object.<anonymous>"
}
I tried clearing the cache, saving the dependency again and with different externals configuration:
externals: [
"kafkajs",
{
Kafka: {
commonjs: ["kafkajs", "Kafka"],
}
]
Thanks ahead for any guidance