Fix for client-node ESM v Commonjs issue. (#132)
Some checks failed
CodeQL Advanced / Analyze (javascript-typescript) (push) Failing after 2s
Run Prettify / Prettier Check (push) Failing after 1s
Run Integration Tests / kubeconfig-method-integration-test (push) Failing after 3s
Run Unit Tests / unit-test (push) Failing after 2s

Signed-off-by: Tatsat Mishra <tamishra@microsoft.com>
This commit is contained in:
Tatsinnit 2025-03-20 04:12:40 +13:00 committed by GitHub
parent 5374e54fdc
commit 959bbfb69a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 3373 additions and 1170 deletions

7
babel.config.js Normal file
View file

@ -0,0 +1,7 @@
// babel.config.js
export default {
presets: [
'@babel/preset-env', // For handling ES modules
'@babel/preset-typescript' // For handling TypeScript
]
}

View file

@ -1,4 +1,4 @@
module.exports = {
export default {
restoreMocks: true,
clearMocks: true,
resetMocks: true,
@ -6,8 +6,16 @@ module.exports = {
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
transform: {
'^.+\\.ts$': 'ts-jest'
'^.+\\.ts$': 'ts-jest', // Use ts-jest for TypeScript files
'^.+\\.js$': 'babel-jest' // Transform TypeScript files
},
transformIgnorePatterns: [
'/node_modules/(?!@kubernetes/client-node)/' // Make sure to transform the Kubernetes client module
],
moduleNameMapper: {
'^.+\\.css$': 'jest-transform-stub' // Handle CSS imports (if any)
},
extensionsToTreatAsEsm: ['.ts', '.tsx'], // Treat TypeScript files as ESM
verbose: true,
coverageThreshold: {
global: {

4505
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -3,6 +3,7 @@
"version": "4.0.0",
"private": true,
"main": "lib/index.js",
"type": "module",
"scripts": {
"prebuild": "npm i @vercel/ncc",
"build": "ncc build src/run.ts -o lib",
@ -22,17 +23,20 @@
"@actions/core": "^1.11.1",
"@actions/exec": "^1.1.1",
"@actions/io": "^1.1.3",
"@kubernetes/client-node": "^0.22.3",
"@kubernetes/client-node": "^1.1.0",
"js-yaml": "^4.1.0"
},
"devDependencies": {
"@babel/preset-env": "^7.26.9",
"@babel/preset-typescript": "^7.26.0",
"@types/jest": "^29.5.14",
"@types/js-yaml": "^4.0.9",
"@types/node": "^22.10.2",
"@vercel/ncc": "^0.38.3",
"babel-jest": "^29.7.0",
"jest": "^29.7.0",
"prettier": "^3.4.2",
"ts-jest": "^29.2.5",
"typescript": "^5.7.2"
"prettier": "^3.5.3",
"ts-jest": "^29.2.6",
"typescript": "^5.8.2"
}
}

View file

@ -1,8 +1,15 @@
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"esModuleInterop": true
"baseUrl": ".",
"module": "ESNext", // or "NodeNext" depending on your setup
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"paths": {
"@actions/core": ["node_modules/@actions/core"],
"@kubernetes/client-node": ["node_modules/@kubernetes/client-node"]
}
},
"exclude": ["node_modules", "tests", "src/**/*.test.ts"]
}