Skip to content

Commit ff0ba72

Browse files
Romex91Judahmeek
authored andcommitted
backward compatibility: do not introduce 'react-on-rails/server'
1 parent 5f0bdf7 commit ff0ba72

File tree

6 files changed

+9
-8
lines changed

6 files changed

+9
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ yalc.lock
3535

3636
# IDE
3737
.idea/
38+
.vscode/
3839

3940
# TypeScript
4041
*.tsbuildinfo

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Changes since the last non-beta release.
2121
#### Fixed
2222
- Reduced bundle size [PR 1697](https://github.com/shakacode/react_on_rails/pull/1697) by [Romex91](https://github.com/Romex91)
2323
- Migrated from CJS to ESM for more compact modules (~1KB improvement)
24-
- Split exports to 'react-on-rails/server' and 'react-on-rails/client' to avoid shipping React server-rendering to browsers (~14KB improvement).
24+
- Add export option 'react-on-rails/client' to avoid shipping server-rendering code to browsers (~14KB improvement).
2525
- Fix obscure errors by introducing FULL_TEXT_ERRORS [PR 1695](https://github.com/shakacode/react_on_rails/pull/1695) by [Romex91](https://github.com/Romex91).
2626
- Disable `esModuleInterop` to increase interoperability [PR 1699](https://github.com/shakacode/react_on_rails/pull/1699) by [alexeyr-ci](https://github.com/alexeyr-ci).
2727
- Resolved 14.1.1 incompatibility with eslint & made sure that spec/dummy is linted by eslint. [PR 1693](https://github.com/shakacode/react_on_rails/pull/1693) by [judahmeek](https://github.com/judahmeek).

lib/generators/react_on_rails/templates/base/base/app/javascript/packs/server-bundle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import ReactOnRails from 'react-on-rails/server';
1+
import ReactOnRails from 'react-on-rails';
22

33
import HelloWorld from '../bundles/HelloWorld/components/HelloWorldServer';
44

node_package/src/ReactOnRails.server.ts renamed to node_package/src/ReactOnRails.full.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type {
99
import Client from './ReactOnRails.client';
1010

1111
if (typeof window !== 'undefined') {
12-
throw new Error('"react-on-rails" is for server-side rendering only. Import "react-on-rails/client".');
12+
console.warn('Optimization opportunity: "react-on-rails" includes server-rendering code. Browser may not need it. See https://forum.shakacode.com/t/how-to-use-different-versions-of-a-file-for-client-and-server-rendering/1352 (requires sign in)');
1313
}
1414

1515
Client.handleError = (options: ErrorOptions): string | undefined => handleError(options);
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import ReactOnRails from './ReactOnRails.server';
1+
import ReactOnRails from './ReactOnRails.full';
22
import streamServerRenderedReactComponent from './streamServerRenderedReactComponent';
33

44
ReactOnRails.streamServerRenderedReactComponent = streamServerRenderedReactComponent;
55

6-
export * from './ReactOnRails.server';
7-
export { default } from './ReactOnRails.server';
6+
export * from './ReactOnRails.full';
7+
export { default } from './ReactOnRails.full';

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"description": "react-on-rails JavaScript for react_on_rails Ruby gem",
55
"main": "node_package/lib/ReactOnRails.js",
66
"exports": {
7-
"./server": {
7+
".": {
88
"node": "./node_package/lib/ReactOnRails.node.js",
9-
"default": "./node_package/lib/ReactOnRails.server.js"
9+
"default": "./node_package/lib/ReactOnRails.full.js"
1010
},
1111
"./client": "./node_package/lib/ReactOnRails.client.js"
1212
},

0 commit comments

Comments
 (0)