Skip to content

Commit

Permalink
Chore add type field to pkgjson (#130)
Browse files Browse the repository at this point in the history
* fix: ts for esm

* chore: bump
  • Loading branch information
zheeeng authored Sep 14, 2022
1 parent 4195a47 commit 1056ea0
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -10,6 +10,7 @@
"excel",
"typescript"
],
"type": "module",
"main": "dist/umd/index.js",
"module": "dist/esm/index.js",
"typings": "dist/types/index.d.ts",
Expand Down Expand Up @@ -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": [
Expand Down
5 changes: 3 additions & 2 deletions src/converters.ts
Original file line number Diff line number Diff line change
@@ -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<string, string>) {
if (
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions src/exportFromJSON.ts
Original file line number Diff line number Diff line change
@@ -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<R = void> {
data: object | string
fileName?: string
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/processors.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down

0 comments on commit 1056ea0

Please sign in to comment.