Skip to content

Commit

Permalink
feat: Add proper native ESM support
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Depending on your build and runtime configuration, this change might break your path resolution.
  • Loading branch information
jhnns committed Sep 13, 2021
1 parent e5485a6 commit 2846a94
Show file tree
Hide file tree
Showing 16 changed files with 225 additions and 42 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
preset: "ts-jest",
setupFiles: ["dotenv/config"],
collectCoverage: true,
resolver: "ts-jest-resolver",
globals: {
"ts-jest": {
diagnostics: false,
Expand Down
177 changes: 177 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"types": "./dist/esm/index.d.ts",
"exports": {
"require": "./dist/cjs/index.js",
"node": "./dist/cjs/index.mjs",
"default": "./dist/esm/index.js"
},
"sideEffects": false,
Expand All @@ -16,6 +17,7 @@
"build:tsc": "run-p build:tsc:*",
"build:tsc:cjs": "tsc -p ./tsconfig.cjs.json",
"build:tsc:esm": "tsc -p ./tsconfig.esm.json",
"build:copy": "copyfiles -f ./src/index.mjs ./dist/cjs/",
"test": "run-p test:unit test:integration",
"test:unit": "jest --env node tests/unit/**",
"test:integration": "jest tests/integration/**",
Expand Down Expand Up @@ -50,6 +52,7 @@
"@types/qs": "^6.9.6",
"@typescript-eslint/eslint-plugin": "^4.24.0",
"@typescript-eslint/parser": "^4.24.0",
"copyfiles": "^2.4.1",
"dotenv": "^9.0.2",
"eslint": "^7.26.0",
"eslint-config-peerigon": "^30.1.0",
Expand All @@ -62,6 +65,7 @@
"prettier": "^2.3.0",
"rimraf": "^3.0.2",
"ts-jest": "^26.5.6",
"ts-jest-resolver": "^1.1.0",
"typescript": "^4.2.4"
},
"files": [
Expand Down
2 changes: 2 additions & 0 deletions src/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line import/no-unresolved
export * from "./index.js";
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export * from "./internals/utilities/mappings";
export type { Config } from "./internals/utilities/api";
export * from "./internals/clockodo";
export * from "./internals/enums";
export * from "./internals/interfaces";
export * from "./internals/returnTypes";
export * from "./internals/utilities/mappings.js";
export type { Config } from "./internals/utilities/api.js";
export * from "./internals/clockodo.js";
export * from "./internals/enums.js";
export * from "./internals/interfaces.js";
export * from "./internals/returnTypes.js";
10 changes: 5 additions & 5 deletions src/internals/clockodo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import snakecaseKeys from "snakecase-keys";
import { Api, Config } from "./utilities/api";
import * as REQUIRED from "./utilities/requiredParams";
import { Api, Config } from "./utilities/api.js";
import * as REQUIRED from "./utilities/requiredParams.js";
import {
AbsenceReturnType,
AbsencesReturnType,
Expand Down Expand Up @@ -33,8 +33,8 @@ import {
LumpsumServicesReturnType,
SearchTextsReturnType,
LumpsumServiceReturnType,
} from "./returnTypes";
import { ClockingTimeEntryBillability, TimeEntryBillability } from "./enums";
} from "./returnTypes.js";
import { ClockingTimeEntryBillability, TimeEntryBillability } from "./enums.js";
import {
Absence,
Customer,
Expand All @@ -47,7 +47,7 @@ import {
TargethoursRow,
TimeEntry,
User,
} from "./interfaces";
} from "./interfaces.js";

type Params<
RequiredParams extends Record<string, unknown> = Record<string, unknown>
Expand Down
2 changes: 1 addition & 1 deletion src/internals/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
EntryType,
LumpsumEntryBillability,
TimeEntryBillability,
} from "./enums";
} from "./enums.js";

export type Customer = {
id: number;
Expand Down
2 changes: 1 addition & 1 deletion src/internals/returnTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
UserReport,
TargethoursRow,
LumpsumService,
} from "./interfaces";
} from "./interfaces.js";

export type AbsenceReturnType = Promise<{ absence: Absence }>;
export type AbsencesReturnType = Promise<{ absences: Array<Absence> }>;
Expand Down
4 changes: 2 additions & 2 deletions src/internals/utilities/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios, { AxiosRequestConfig } from "axios";
import qs from "qs";
import { axiosClient } from "./symbols";
import { mapQueryParams, mapRequestBody, mapResponseBody } from "./mappings";
import { axiosClient } from "./symbols.js";
import { mapQueryParams, mapRequestBody, mapResponseBody } from "./mappings.js";

const DEFAULT_BASE_URL = "https://my.clockodo.com/api";

Expand Down
Loading

0 comments on commit 2846a94

Please sign in to comment.