mirror of
https://github.com/facebook/react.git
synced 2026-02-22 11:51:55 +00:00
This lets the Flight fixture run as "type": "module" or "commonjs". Experimental loaders can be used similar to require.extensions to do the transpilation and replacement of .client.js references.
28 lines
727 B
JavaScript
28 lines
727 B
JavaScript
import {pipeToNodeWritable} from 'react-transport-dom-webpack/server.js';
|
|
import * as React from 'react';
|
|
import App from '../src/App.server.js';
|
|
|
|
import {URL} from 'url';
|
|
|
|
const rootPath = import.meta.url;
|
|
function resolve(relative) {
|
|
return new URL(relative, rootPath).href;
|
|
}
|
|
|
|
export default function(req, res) {
|
|
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
pipeToNodeWritable(<App />, res, {
|
|
// TODO: Read from a map on the disk.
|
|
[resolve('../src/Counter.client.js')]: {
|
|
id: './src/Counter.client.js',
|
|
chunks: ['1'],
|
|
name: 'default',
|
|
},
|
|
[resolve('../src/ShowMore.client.js')]: {
|
|
id: './src/ShowMore.client.js',
|
|
chunks: ['2'],
|
|
name: 'default',
|
|
},
|
|
});
|
|
};
|