Skip to content

Commit 4af6e05

Browse files
committed
Bugfix: fixed fetch issue in Node LTS versions.
1 parent 9975000 commit 4af6e05

File tree

5 files changed

+173
-23
lines changed

5 files changed

+173
-23
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.0.1] - 2022-08-14
9+
10+
### Fixed
11+
12+
- Fetch API issues in Node.js LTS versions.
13+
814
## [1.0.0] - 2022-07-31
915

1016
### Added

package-lock.json

Lines changed: 104 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
"author": "DipScope authors and contributors",
33
"dependencies": {
44
"@dipscope/entity-store": "^1.0.0",
5+
"cross-fetch": "^3.1.5",
56
"lodash": "^4.17.21"
67
},
78
"description": "Json api entity provider for entity store.",
89
"devDependencies": {
910
"@types/jasmine": "^3.6.3",
1011
"@types/lodash": "^4.14.182",
12+
"@types/node": "^18.7.3",
1113
"@typescript-eslint/eslint-plugin": "^4.14.2",
1214
"@typescript-eslint/parser": "^4.14.2",
1315
"circular-dependency-plugin": "^5.2.2",
@@ -33,6 +35,7 @@
3335
],
3436
"license": "Apache-2.0",
3537
"main": "index.js",
38+
"browser": "index.browser.js",
3639
"name": "@dipscope/json-api-entity-provider",
3740
"repository": {
3841
"type": "git",

src/json-api-connection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import fetch, { Headers, Request } from 'cross-fetch';
12
import isString from 'lodash/isString';
23
import { ConflictJsonApiError } from './errors/conflict-json-api-error';
34
import { ForbiddenJsonApiError } from './errors/forbidden-json-api-error';

webpack.config.js

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
const Path = require('path');
22
const CircularDependencyPlugin = require('circular-dependency-plugin');
33

4-
module.exports = {
4+
module.exports = [{
55
mode: 'production',
66
devtool: false,
7+
target: 'node',
78
entry: {
89
index: './src/index.ts'
910
},
@@ -56,4 +57,60 @@ module.exports = {
5657
resolve: {
5758
extensions: ['.tsx', '.ts', '.js']
5859
}
59-
};
60+
}, {
61+
mode: 'production',
62+
devtool: false,
63+
target: 'web',
64+
entry: {
65+
index: './src/index.ts'
66+
},
67+
output: {
68+
path: Path.resolve(__dirname, 'dist'),
69+
filename: '[name].browser.js',
70+
library: 'JsonApiEntityProvider',
71+
libraryTarget: 'umd',
72+
globalObject: 'this',
73+
umdNamedDefine: true
74+
},
75+
externals: {
76+
'@dipscope/type-manager': {
77+
root: 'TypeManager',
78+
amd: '@dipscope/type-manager',
79+
commonjs2: '@dipscope/type-manager',
80+
commonjs: '@dipscope/type-manager'
81+
},
82+
'@dipscope/entity-store': {
83+
root: 'EntityStore',
84+
amd: '@dipscope/entity-store',
85+
commonjs2: '@dipscope/entity-store',
86+
commonjs: '@dipscope/entity-store'
87+
}
88+
},
89+
plugins: [
90+
new CircularDependencyPlugin({
91+
exclude: /node_modules/,
92+
include: /src/,
93+
failOnError: true,
94+
allowAsyncCycles: false,
95+
cwd: process.cwd()
96+
})
97+
],
98+
module: {
99+
rules: [{
100+
test: /\.tsx?$/,
101+
use: [{
102+
loader: 'ts-loader',
103+
options: {
104+
configFile: 'tsconfig.webpack.json'
105+
}
106+
}],
107+
exclude: /node_modules/,
108+
include: [
109+
Path.resolve(__dirname, 'src')
110+
],
111+
}]
112+
},
113+
resolve: {
114+
extensions: ['.tsx', '.ts', '.js']
115+
}
116+
}];

0 commit comments

Comments
 (0)