Skip to content
This repository was archived by the owner on Apr 13, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Build a separate entry point bundle for React Native.
  • Loading branch information
benjamn committed Nov 17, 2018
commit 209b1424708b53d226b653302f7ad9d671f12b4d
24 changes: 24 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,30 @@ export default [
},
onwarn,
},
// for React Native
{
input: 'lib/index.js',
output: {
// https://facebook.github.io/react-native/docs/platform-specific-code#platform-specific-extensions
file: 'lib/react-apollo.umd.native.js',
format: 'umd',
name: 'react-apollo',
sourcemap: false,
exports: 'named',
},
plugins: [{
resolveId(id, parentId) {
if (id.split('/').pop().split('.').shift() === 'defaultRenderFunction') {
// Don't try to include lib/defaultRenderFunction.* in the bundle.
// The React Native bundler should pick up lib/defaultRenderFunction.native.js
// instead of lib/defaultRenderFunction.js because of this override.
return false;
}
// Return nothing to fall through to default resolution logic.
}
}],
onwarn,
},
// for test-utils
{
input: 'lib/test-utils.js',
Expand Down
5 changes: 2 additions & 3 deletions src/renderToStringWithData.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { ReactElement } from 'react';
import * as ReactDOM from 'react-dom/server';

import defaultRenderFunction from './defaultRenderFunction';
import { default as getDataFromTree } from './getDataFromTree';

export function renderToStringWithData(component: ReactElement<any>): Promise<string> {
return getDataFromTree(component).then(() => ReactDOM.renderToString(component));
return getDataFromTree(component).then(() => defaultRenderFunction(component));
}