diff --git a/package.json b/package.json index b6a2015..23bbf57 100644 --- a/package.json +++ b/package.json @@ -2,15 +2,20 @@ "name": "onspring-api-sdk", "version": "1.0.0", "description": "A javascript SDK for interacting with version 2 of the Onspring API.", - "main": "dist/index.js", + "main": "dist/cjs/index.js", "types": "dist/index.d.ts", + "exports": { + "import": "./dist/esm/index.js", + "require": "./dist/cjs/index.js", + "default": "./dist/cjs/index.js" + }, "scripts": { "clean": "rimraf dist", "lint": "eslint --ignore-path .eslintignore --ext .js,.ts .", "lint-fix": "eslint --fix --ignore-path .eslintignore --ext .js,.ts . --max-warnings=0", "format-staged": "pretty-quick --staged", "format": "pretty-quick", - "build": "npm run lint-fix && npm run tests && npm run format && npm run clean && tsc", + "build": "npm run lint-fix && npm run tests && npm run format && npm run clean && tsc --project tsconfig.cjs.json & tsc --project tsconfig.esm.json", "tests": "mocha -R progress -r ts-node/register ./tests/**/*.spec.ts", "test": "mocha -r ts-node/register", "test-coverage": "nyc npm run tests", diff --git a/src/models/SaveFileRequest.ts b/src/models/SaveFileRequest.ts index 4bbe9c8..ffad5bf 100644 --- a/src/models/SaveFileRequest.ts +++ b/src/models/SaveFileRequest.ts @@ -1,5 +1,5 @@ import { type Readable } from 'stream'; -import FormData = require('form-data'); +import FormData from 'form-data'; /** * @class SaveFileRequest - Represents a request to save a file. diff --git a/tsconfig.json b/tsconfig.json index 0a6e46c..d344dd5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,12 +1,19 @@ { "compilerOptions": { "strictNullChecks": true, - "module": "commonjs", "moduleResolution": "node", - "target": "es2015", "declaration": true, - "outDir": "./dist", + "declarationDir": "./dist/types", "esModuleInterop": true }, - "include": ["src/**/*"] + "include": ["src/**/*"], + "ts-node": { + "compilerOptions": { + "module": "commonjs", + "target": "es2015" + }, + "moduleTypes": { + "*.ts": "cjs" + } + } }