Skip to content

Commit a35d175

Browse files
gaearonkoto
authored andcommitted
[Flight] Make PG and FS server-only (facebook#20424)
* Make react-fs server-only * Make react-pg server-only
1 parent 4d3dd61 commit a35d175

18 files changed

+66
-43
lines changed

packages/react-fs/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* @flow
88
*/
99

10-
'use strict';
11-
12-
export * from './index.node';
10+
throw new Error(
11+
'React FS cannot be used outside a react-server environment. ' +
12+
'You must configure Node.js using the `--conditions react-server` flag.',
13+
);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
if (process.env.NODE_ENV === 'production') {
4-
module.exports = require('./cjs/react-fs.browser.production.min.js');
4+
module.exports = require('./cjs/react-fs.browser.production.min.server.js');
55
} else {
6-
module.exports = require('./cjs/react-fs.browser.development.js');
6+
module.exports = require('./cjs/react-fs.browser.development.server.js');
77
}

packages/react-fs/npm/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
'use strict';
22

3-
module.exports = require('./index.node');
3+
throw new Error(
4+
'React FS cannot be used outside a react-server environment. ' +
5+
'You must configure Node.js using the `--conditions react-server` flag.'
6+
);

packages/react-fs/npm/index.node.js

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
'use strict';
2+
3+
if (process.env.NODE_ENV === 'production') {
4+
module.exports = require('./cjs/react-fs.node.production.min.server.js');
5+
} else {
6+
module.exports = require('./cjs/react-fs.node.development.server.js');
7+
}

packages/react-fs/package.json

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,23 @@
1313
"README.md",
1414
"build-info.json",
1515
"index.js",
16-
"index.node.js",
17-
"index.browser.js",
16+
"index.node.server.js",
17+
"index.browser.server.js",
1818
"cjs/"
1919
],
20+
"exports": {
21+
".": {
22+
"react-server": {
23+
"node": "./index.node.server.js",
24+
"browser": "./index.browser.server.js"
25+
},
26+
"default": "./index.js"
27+
},
28+
"./index.node.server": "./index.node.server.js",
29+
"./index.browser.server": "./index.browser.server.js",
30+
"./package.json": "./package.json"
31+
},
2032
"peerDependencies": {
2133
"react": "^17.0.0"
22-
},
23-
"browser": {
24-
"./index.js": "./index.browser.js"
2534
}
2635
}

packages/react-pg/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* @flow
88
*/
99

10-
'use strict';
11-
12-
export * from './index.node';
10+
throw new Error(
11+
'React PG cannot be used outside a react-server environment. ' +
12+
'You must configure Node.js using the `--conditions react-server` flag.',
13+
);

0 commit comments

Comments
 (0)