Skip to content

Commit ad4f263

Browse files
committed
chore(node): enable ESM
1 parent 5b2ca28 commit ad4f263

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

sdk-template-overrides/typescript-axios/configuration.mustache

+10-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33
{{>licenseInfo}}
44

55
{{! Edited by OpenAI, line 6 }}
6-
const packageJson = require("../package.json");
6+
import FormData from "form-data";
7+
import filedirname from "filedirname";
8+
import fs from "fs";
9+
import path from "path";
10+
11+
const [, dirname] = filedirname();
12+
const filePath = path.join(dirname, '../package.json');
13+
const contents = fs.readFileSync(filePath, { encoding: 'utf8' });
14+
const packageJson = JSON.parse(contents);
715

816
export interface ConfigurationParameters {
917
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
@@ -100,7 +108,7 @@ export class Configuration {
100108
this.baseOptions.headers['OpenAI-Organization'] = this.organization;
101109
}
102110
if (!this.formDataCtor) {
103-
this.formDataCtor = require("form-data");
111+
this.formDataCtor = FormData;
104112
}
105113
}
106114

0 commit comments

Comments
 (0)