diff --git a/fixtures/flight/server/App.server.js b/fixtures/flight/server/App.server.js deleted file mode 100644 index 72858c944779b..0000000000000 --- a/fixtures/flight/server/App.server.js +++ /dev/null @@ -1,16 +0,0 @@ -import * as React from 'react'; - -// TODO: A transform should read this from webpack plugin output. -const CounterClient = { - $$typeof: Symbol.for('react.module.reference'), - name: './src/Counter.client.js', -}; - -export default function App() { - return ( -
-

Hello, world

- -
- ); -} diff --git a/fixtures/flight/server/handler.js b/fixtures/flight/server/handler.server.js similarity index 62% rename from fixtures/flight/server/handler.js rename to fixtures/flight/server/handler.server.js index 9a0c6004150d8..f3b899d498d79 100644 --- a/fixtures/flight/server/handler.js +++ b/fixtures/flight/server/handler.server.js @@ -2,14 +2,19 @@ import {pipeToNodeWritable} from 'react-transport-dom-webpack/server'; import * as React from 'react'; -import App from './App.server'; +import App from '../src/App.server'; module.exports = function(req, res) { res.setHeader('Access-Control-Allow-Origin', '*'); pipeToNodeWritable(, res, { // TODO: Read from a map on the disk. - './src/Counter.client.js': { + [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', }, diff --git a/fixtures/flight/server/index.js b/fixtures/flight/server/index.js index 016fe9f15dbad..06c245b4120af 100644 --- a/fixtures/flight/server/index.js +++ b/fixtures/flight/server/index.js @@ -1,5 +1,12 @@ 'use strict'; +require.extensions['.client.js'] = function(module, path) { + module.exports = { + $$typeof: Symbol.for('react.module.reference'), + name: path, + }; +}; + const babelRegister = require('@babel/register'); babelRegister({ @@ -18,7 +25,7 @@ app.get('/', function(req, res) { delete require.cache[key]; } } - require('./handler')(req, res); + require('./handler.server')(req, res); }); app.listen(3001, () => { diff --git a/fixtures/flight/src/App.server.js b/fixtures/flight/src/App.server.js new file mode 100644 index 0000000000000..bf3b20fa32a75 --- /dev/null +++ b/fixtures/flight/src/App.server.js @@ -0,0 +1,19 @@ +import * as React from 'react'; + +import Container from './Container'; + +import Counter from './Counter.client'; + +import ShowMore from './ShowMore.client'; + +export default function App() { + return ( + +

Hello, world

+ + +

Lorem ipsum

+
+
+ ); +} diff --git a/fixtures/flight/src/Container.js b/fixtures/flight/src/Container.js new file mode 100644 index 0000000000000..49875403c8c74 --- /dev/null +++ b/fixtures/flight/src/Container.js @@ -0,0 +1,5 @@ +import * as React from 'react'; + +export default function Container({children}) { + return
{children}
; +} diff --git a/fixtures/flight/src/Counter.client.js b/fixtures/flight/src/Counter.client.js index 8274f6134b5a7..892af50df69ad 100644 --- a/fixtures/flight/src/Counter.client.js +++ b/fixtures/flight/src/Counter.client.js @@ -1,6 +1,12 @@ import * as React from 'react'; +import Container from './Container'; + export default function Counter() { const [count, setCount] = React.useState(0); - return ; + return ( + + + + ); } diff --git a/fixtures/flight/src/ShowMore.client.js b/fixtures/flight/src/ShowMore.client.js new file mode 100644 index 0000000000000..d8ff151725e86 --- /dev/null +++ b/fixtures/flight/src/ShowMore.client.js @@ -0,0 +1,11 @@ +import * as React from 'react'; + +import Container from './Container'; + +export default function ShowMore({children}) { + const [show, setShow] = React.useState(false); + if (!show) { + return ; + } + return {children}; +} diff --git a/fixtures/flight/src/index.js b/fixtures/flight/src/index.js index 100164f5a4614..ce9595dbe5482 100644 --- a/fixtures/flight/src/index.js +++ b/fixtures/flight/src/index.js @@ -1,4 +1,5 @@ -import React, {Suspense} from 'react'; +import * as React from 'react'; +import {Suspense} from 'react'; import ReactDOM from 'react-dom'; import ReactTransportDOMClient from 'react-transport-dom-webpack';