Skip to content

Commit 279d2e1

Browse files
author
Igo Lapa
authored
fix: remove isomorphic-unfetch and use node-fetch instead (#375)
1 parent 99b049f commit 279d2e1

File tree

6 files changed

+502
-583
lines changed

6 files changed

+502
-583
lines changed

jest.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
export default {
22
clearMocks: true,
33
testEnvironment: 'node',
4+
transform: {
5+
'^.+\\.(ts|tsx)$': 'ts-jest',
6+
'^.+\\.(js)$': 'babel-jest',
7+
},
8+
transformIgnorePatterns: [],
49
}

package.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
},
4949
"dependencies": {
5050
"@types/node": "^17.0.1",
51-
"isomorphic-unfetch": "^3.1.0"
51+
"node-fetch": "^3.2.0"
5252
},
5353
"devDependencies": {
5454
"@babel/core": "^7.15.5",
@@ -59,7 +59,7 @@
5959
"@commitlint/cz-commitlint": "^16.0.0",
6060
"@rollup/plugin-commonjs": "^21.0.0",
6161
"@rollup/plugin-multi-entry": "^4.0.0",
62-
"@rollup/plugin-node-resolve": "^13.0.0",
62+
"@rollup/plugin-node-resolve": "^13.1.3",
6363
"@types/jest": "^27.0.1",
6464
"@typescript-eslint/eslint-plugin": "^4.26.1",
6565
"@typescript-eslint/parser": "^4.26.1",
@@ -74,8 +74,8 @@
7474
"lint-staged": "^12.0.1",
7575
"nock": "^13.1.0",
7676
"prettier": "^2.4.1",
77-
"rollup": "^2.51.2",
78-
"rollup-plugin-dts": "^4.0.0",
77+
"rollup": "^2.66.1",
78+
"rollup-plugin-dts": "^4.1.0",
7979
"rollup-plugin-inject-process-env": "^1.3.1",
8080
"rollup-plugin-peer-deps-external": "^2.2.4",
8181
"rollup-plugin-terser": "^7.0.2",
@@ -91,17 +91,17 @@
9191
"engines": {
9292
"node": ">=14.*"
9393
},
94-
"plugins": [
95-
[
96-
"@semantic-release/commit-analyzer"
97-
],
98-
[
99-
"@semantic-release/release-notes-generator"
100-
],
101-
"@semantic-release/npm",
102-
"@semantic-release/github"
103-
],
10494
"release": {
95+
"plugins": [
96+
[
97+
"@semantic-release/commit-analyzer"
98+
],
99+
[
100+
"@semantic-release/release-notes-generator"
101+
],
102+
"@semantic-release/npm",
103+
"@semantic-release/github"
104+
],
105105
"branches": [
106106
"main"
107107
]

rollup.config.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,23 @@ export default [
2020
input: 'src/index.ts',
2121
output: [
2222
{
23+
inlineDynamicImports: true,
2324
file: packageJson.main,
2425
format: 'cjs', // commonJS
2526
sourcemap: true,
2627
},
2728
{
29+
inlineDynamicImports: true,
2830
file: packageJson.module,
2931
format: 'esm', // ES Modules
3032
sourcemap: true,
3133
},
3234
],
3335
plugins: [
3436
peerDepsExternal(),
35-
resolve(),
37+
resolve({
38+
preferBuiltins: true,
39+
}),
3640
commonjs(),
3741
typescript({
3842
clean: true,
@@ -46,12 +50,25 @@ export default [
4650
}),
4751
terser(),
4852
],
49-
external: Object.keys(globals),
53+
external: [
54+
...Object.keys(globals),
55+
'node:stream',
56+
'node:http',
57+
'node:zlib',
58+
'node:buffer',
59+
'node:https',
60+
'node:util',
61+
'node:url',
62+
'node:net',
63+
'node:path',
64+
'node:fs',
65+
],
5066
},
5167
{
5268
input: ['dist/index.d.ts', 'dist/types/index.d.ts'],
5369
output: {
5470
format: 'es',
71+
inlineDynamicImports: true,
5572
file: packageJson.types,
5673
},
5774
plugins: [multi(), dts()],

src/Client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fetch from 'isomorphic-unfetch'
1+
import fetch from 'node-fetch'
22
import { URL, URLSearchParams } from 'url'
33
import { DuffelError, DuffelResponse, SDKOptions } from './types'
44

src/booking/OfferRequests/OfferRequests.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ describe('OfferRequests', () => {
108108

109109
test('should create an offer request and return the offer request id when `return_offers` is false', async () => {
110110
const mockResponseWithoutOffer = { ...mockOfferRequest }
111+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
112+
//@ts-ignore
111113
delete mockResponseWithoutOffer.offers
112114
nock(/(.*)/)
113115
.post(`/air/offer_requests/`)

0 commit comments

Comments
 (0)