Skip to content

Commit a71d66f

Browse files
committed
fix: removed esm Module for Node.js v22.12.0+ Compatibility
1 parent e498d47 commit a71d66f

File tree

4 files changed

+9
-36
lines changed

4 files changed

+9
-36
lines changed

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ jobs:
3232
needs: build
3333
steps:
3434
- name: Checkout
35-
uses: actions/checkout@v3.5.3
35+
uses: actions/checkout@v4
3636
with:
3737
fetch-depth: 0
3838
- name: Setup Node.js
39-
uses: actions/setup-node@v3.7.0
39+
uses: actions/setup-node@v4
4040
with:
41-
node-version: "18.x"
41+
node-version: "22.x"
4242
- name: Installing dependencies
4343
run: npm install
4444
- name: Download dist

package-lock.json

Lines changed: 2 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@contentstack/cli-launch",
3-
"version": "1.5.0",
3+
"version": "1.5.1",
44
"description": "Launch related operations",
55
"author": "Contentstack CLI",
66
"bin": {
@@ -32,7 +32,6 @@
3232
"chalk": "^4.1.2",
3333
"cross-fetch": "^3.1.8",
3434
"dotenv": "^16.4.7",
35-
"esm": "^3.2.25",
3635
"express": "^4.21.1",
3736
"form-data": "^4.0.0",
3837
"graphql": "^16.9.0",
@@ -45,7 +44,6 @@
4544
"@oclif/test": "^4.1.3",
4645
"@types/adm-zip": "^0.5.7",
4746
"@types/chai": "^4.3.20",
48-
"@types/esm": "^3.2.2",
4947
"@types/ini": "^1.3.34",
5048
"@types/lodash": "^4.17.13",
5149
"@types/mocha": "^10.0.10",

src/util/cloud-function/cloud-functions.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import dotenv from 'dotenv';
2-
import esm from 'esm';
32
import express, {
43
Request,
54
Response,
@@ -70,13 +69,11 @@ export class CloudFunctions {
7069
cloudFunctionResources: CloudFunctionResource[],
7170
app: Express
7271
): Promise<void> {
73-
const loadAsESM = esm(module);
74-
7572
await Promise.all(
7673
cloudFunctionResources.map(async (cloudFunctionResource) => {
77-
const handler = loadAsESM(
74+
const handler = await import(
7875
`${cloudFunctionResource.cloudFunctionFilePath}`
79-
).default;
76+
);
8077
app.use(express.json());
8178
app.use(express.urlencoded({ extended: true }));
8279

@@ -182,12 +179,11 @@ export class CloudFunctions {
182179

183180
private async checkDefaultExport(filepath: string): Promise<boolean> {
184181
const exportType = "function";
185-
const loadAsESM = esm(module);
186182
const fullPath = normalize(path.resolve(process.cwd(), filepath)).replace(
187183
/^(\.\.(\/|\\|$))+/,
188184
""
189185
);
190-
const handler = await loadAsESM(fullPath);
186+
const handler = await import(fullPath);
191187

192188
return typeof handler.default === exportType;
193189
}

0 commit comments

Comments
 (0)