-
Notifications
You must be signed in to change notification settings - Fork 562
Description
Describe the bug
When using the library and bundling it with esbuild (in this case for use within AWS lambda) an error is thrown.
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module './src/cat'\nRequire stack:\n- /var/task/index.js\n- /var/runtime/index.mjs",
"trace": [
"Runtime.ImportModuleError: Error: Cannot find module './src/cat'",
"Require stack:",
"- /var/task/index.js",
"- /var/runtime/index.mjs",
" at _loadUserApp (file:///var/runtime/index.mjs:1000:17)",
" at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1035:21)",
" at async start (file:///var/runtime/index.mjs:1200:23)",
" at async file:///var/runtime/index.mjs:1206:1"
]
}This is being caused not by this library, but the direct dependency shelljs.
The reason why I'm reporting this here is, that this is not seen as a bug there
- Explicitly require the commands to help JS bundlers find all the code shelljs/shelljs#962
- error with bundled (esbuild) code: cannot find module ./src/cat.js shelljs/shelljs#1047
As shelljs only seems to be used in very few places in this library, I'm wondering if it would be an option to remove the dependency and implement the few places it uses in a different way.
** Client Version **
0.18.0
** Server Version **
e.g. 1.24.0
To Reproduce
Steps to reproduce the behavior:
- Bundle any project that depends on
@kubernetes/client-nodewithesbuild(or other bundlers)
Expected behavior
No error is thrown and the library can be used.
** Example Code**
import * as k8s from '@kubernetes/client-node';
const kc = new k8s.KubeConfig();
kc.loadFromDefault();Environment (please complete the following information):
- OS: macOs 12.6
- NodeJS Version: 18
- Cloud runtime: Lambda
Additional context
If you use AWS CDK NodejsFunction you can use the following bundling settings as a workaround
bundling: {
forceDockerBundling: true,
minify: false,
keepNames: true,
nodeModules: ['shelljs'],
}