Skip to content

Commit 5157a69

Browse files
author
Aamod Pisat
committed
bug fix: sdk not working in isomorphic app
1 parent d3225c0 commit 5157a69

File tree

9 files changed

+24
-32
lines changed

9 files changed

+24
-32
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
22
"name": "contentstack",
3-
"version": "3.1.1",
3+
"version": "3.1.2",
44
"description": "The Built.io Contentstack Javascript SDK",
55
"homepage": "https://www.built.io/products/contentstack/overview",
66
"author": {
77
"name": "Built.io Contentstack",
88
"url": "https://www.built.io/"
99
},
1010
"main": "dist/node/contentstack.js",
11+
"browser": "dist/web/contentstack.js",
1112
"_id": "contentstack@3.1.1",
1213
"scripts": {
1314
"test": "node test.js",
@@ -71,7 +72,9 @@
7172
},
7273
"dependencies": {
7374
"babel-runtime": "^6.23.0",
75+
"es6-promise": "^4.1.1",
7476
"fs": "0.0.1-security",
77+
"isomorphic-fetch": "^2.2.1",
7578
"localStorage": "1.0.3",
7679
"nodemailer": "4.0.1",
7780
"path": "^0.12.7",

src/runtime/node/http.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
import * as http from 'xmlhttprequest';
1+
// import * as http from 'xmlhttprequest';
22

3-
var HTTPRequest = http.XMLHttpRequest;
3+
// var HTTPRequest = http.XMLHttpRequest;
4+
5+
// export default HTTPRequest;
46

5-
export default HTTPRequest;
7+
var es6 = require('es6-promise').polyfill();
8+
fetch = require('isomorphic-fetch');
9+
10+
export default fetch;

src/runtime/node/when.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/runtime/react-native/http.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export default XMLHttpRequest;
1+
export default fetch;
22

src/runtime/react-native/when.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/runtime/web/http.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
export default XMLHttpRequest;
2-
1+
export default fetch;

src/runtime/web/when.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

webpack/webpack.node.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ var commonConfig = require('./webpack.common.js');
55
module.exports = function (options) {
66
return webpackMerge(commonConfig(),{
77
output: {
8-
library: "Contentstack",
9-
libraryTarget:"commonjs2",
10-
path: path.join(__dirname, "../dist/node"),
11-
filename: "contentstack.js"
8+
library: "Contentstack",
9+
libraryTarget:"commonjs2",
10+
path: path.join(__dirname, "../dist/node"),
11+
filename: "contentstack.js"
1212
},
1313
target: "node",
1414
resolve: {
1515
alias:{
16-
runtime: path.resolve( __dirname, '../src/runtime/node')
17-
},
16+
runtime: path.resolve( __dirname, '../src/runtime/node')
17+
},
1818
modules: [
19-
'../src',
20-
'../src/runtimes/node',
21-
'node_modules',
19+
'../src',
20+
'../src/runtimes/node',
21+
'node_modules',
2222
]
2323
}
2424
});

webpack/webpack.web.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ module.exports = function (options) {
1919
'../src/runtimes/web',
2020
'node_modules'
2121
]
22-
},
23-
node: {
24-
fs: "empty",
25-
child_process: 'empty'
26-
},
22+
}
2723
});
2824
}
2925

0 commit comments

Comments
 (0)