Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SSR between targets #4

Merged
merged 1 commit into from
Apr 2, 2018
Merged

Add support for SSR between targets #4

merged 1 commit into from
Apr 2, 2018

Conversation

homer0
Copy link
Owner

@homer0 homer0 commented Apr 2, 2018

What does this PR do?

The full description of this PR is on the changes made to the README.md:

Let's say you have a backend target with your Node server code, and a frontend target with your React code, and you want to require your frontend code on the backend in order to use ReactDOM.renderToString(...):

For your backend target you'll have to define its framework property to react, so the plugin can include the JSX loader, and then add an extra option to enable SSR from backend to frontend:

module.exports = {
  targets: {
    backend: {
      type: 'node',
      framework: 'react',
      frameworkOptions: {
        ssr: ['frontend'],
      },
    },
  },
};

This new setting (frameworkOptions.ssr) is where you tell the plugin that the targets on that list should also have their JSX parsed for you to use on Node.

Done, now you can require/import files from your frontend target on the backend target and everything will work.

How should it be tested manually?

yarn test
# or
npm test

@coveralls
Copy link

Pull Request Test Coverage Report for Build 16

  • 7 of 7 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 14: 0.0%
Covered Lines: 65
Relevant Lines: 65

💛 - Coveralls

@homer0 homer0 merged commit 2ad8e08 into next Apr 2, 2018
@homer0 homer0 deleted the homer0_ssr branch April 2, 2018 17:25
@homer0 homer0 added the on:next label Apr 2, 2018
@homer0 homer0 mentioned this pull request Apr 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants