Skip to content

Commit b776722

Browse files
committed
fix: use default exports for humps
The humps library provides uses default exports to export it's functionality. This becomes a problem for ESM bundling as tsup just includes the following line in the bundle: import { camelizeKeys, decamelize, decamelizeKeys } from 'humps'; Running in ESM mode causes failures because named exports are not present in the humps module.
1 parent a6679b1 commit b776722

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/sdk/v4/_fetcher.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import { camelizeKeys, decamelize, decamelizeKeys } from 'humps';
1+
import humps from 'humps';
22
import { FetchFn } from '../../types';
33
import { BaseApiOptions } from '../../types/BaseApiOptions';
44
import { removeBeginningSlash } from '../../utils/misc';
55

66
export const API_BASE_URL = 'https://api.quran.com/api/v4/';
77

8+
const { camelizeKeys, decamelize, decamelizeKeys } = humps;
9+
810
export const makeUrl = (url: string, params?: Record<string, unknown>) => {
911
const baseUrl = `${API_BASE_URL}${removeBeginningSlash(url)}`;
1012
if (!params) return baseUrl;

src/sdk/v4/verses.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ import {
1111
VerseKey,
1212
WordField,
1313
} from '../../types';
14-
import { decamelize } from 'humps';
14+
import humps from 'humps';
1515
import Utils from '../utils';
1616
import { fetcher, mergeApiOptions } from './_fetcher';
1717
import { BaseApiOptions } from '../../types/BaseApiOptions';
1818

19+
const { decamelize } = humps;
20+
1921
type GetVerseOptions = Partial<
2022
BaseApiOptions & {
2123
reciter: string | number;

0 commit comments

Comments
 (0)