mirror of
https://github.com/facebook/react.git
synced 2026-02-27 03:07:57 +00:00
* Expand fixture Use .server convention. /server/index.js should really change too so it can be compiled but for now we treat it as bootstrapping code outside the compiled code. Move App.server. It's part of the application code rather than the infra. Add hybrid component used in both server/client and an extra component shared by multiple entry points. * Use require.extensions to replace .client imports The simplest server doesn't need AOT compilation. Instead we can just configure require.extensions. This is probably not the best idea to use in prod but is enough to show the set up.
23 lines
619 B
JavaScript
23 lines
619 B
JavaScript
'use strict';
|
|
|
|
import {pipeToNodeWritable} from 'react-transport-dom-webpack/server';
|
|
import * as React from 'react';
|
|
import App from '../src/App.server';
|
|
|
|
module.exports = function(req, res) {
|
|
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
pipeToNodeWritable(<App />, res, {
|
|
// TODO: Read from a map on the disk.
|
|
[require.resolve('../src/Counter.client.js')]: {
|
|
id: './src/Counter.client.js',
|
|
chunks: ['1'],
|
|
name: 'default',
|
|
},
|
|
[require.resolve('../src/ShowMore.client.js')]: {
|
|
id: './src/ShowMore.client.js',
|
|
chunks: ['2'],
|
|
name: 'default',
|
|
},
|
|
});
|
|
};
|