diff --git a/package.json b/package.json index 25af486..f7fd8f0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "export-from-json", - "version": "1.6.0", + "version": "1.7.0", "description": "Export to txt, json, csv, xls, xml format file from valid JavaScript JSON object.", "keywords": [ "json", @@ -10,6 +10,7 @@ "excel", "typescript" ], + "type": "module", "main": "dist/umd/index.js", "module": "dist/esm/index.js", "typings": "dist/types/index.d.ts", @@ -59,8 +60,17 @@ "typescript": "^4.6.2" }, "jest": { + "extensionsToTreatAsEsm": [".ts"], + "moduleNameMapper": { + "^(\\.{1,2}/.*)\\.js$": "$1" + }, "transform": { - "^.+\\.ts$": "ts-jest" + "^.+\\.ts$": [ + "ts-jest", + { + "useESM": true + } + ] }, "testRegex": "/__tests__/.+\\.spec.ts$", "moduleFileExtensions": [ diff --git a/src/converters.ts b/src/converters.ts index 0013f61..7f257ef 100644 --- a/src/converters.ts +++ b/src/converters.ts @@ -1,4 +1,4 @@ -import { isArray, getEntries, normalizeXMLName, indent, stripHTML, assert, getKeys } from './utils' +import { isArray, getEntries, normalizeXMLName, indent, stripHTML, assert, getKeys } from './utils.js' export function _createFieldsMapper (fields?: string[] | Record) { if ( @@ -106,7 +106,8 @@ export function _createTableEntries ( // Rule: Fields that contain commas must begin and end with double quotes. // Addition Rule: Fields that contain double quotes must begin and end with double quotes. -// Rule: Fields that contain line breaks must begin and end with double quotes (not all programs support values with line breaks). +// Rule: Fields that contain line breaks must begin and end with double quotes +// (not all programs support values with line breaks). // Rule: All other fields do not require double quotes. // Rule: Double quotes within values are represented by two contiguous double quotes. function encloser (value: string) { diff --git a/src/exportFromJSON.ts b/src/exportFromJSON.ts index e896d30..32bdb83 100644 --- a/src/exportFromJSON.ts +++ b/src/exportFromJSON.ts @@ -1,7 +1,7 @@ -import { assert, isArray, normalizeFileName } from './utils' -import { downloadFile } from './processors' -import { _prepareData, _createJSONData, createCSVData, createXLSData, createXMLData, _createFieldsMapper } from './converters' -import { exportTypes, ExportType } from './types' +import { assert, isArray, normalizeFileName } from './utils.js' +import { downloadFile } from './processors.js' +import { _prepareData, _createJSONData, createCSVData, createXLSData, createXMLData, _createFieldsMapper } from './converters.js' +import { exportTypes, ExportType } from './types.js' export interface IOption { data: object | string fileName?: string diff --git a/src/index.ts b/src/index.ts index 8edf6cf..de741cf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ -import exportFromJSON from './exportFromJSON' -import type { ExportType } from './types' +import exportFromJSON from './exportFromJSON.js' +import type { ExportType } from './types.js' export type { ExportType } export default exportFromJSON diff --git a/src/processors.ts b/src/processors.ts index 8347470..02174e6 100644 --- a/src/processors.ts +++ b/src/processors.ts @@ -1,4 +1,4 @@ -import type { ExportType } from './types' +import type { ExportType } from './types.js' export function generateDataURI (content: string, type: ExportType, byBlob: boolean): string { switch (type) {