Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions fixtures/flight/config/webpackDevServer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ module.exports = function(proxy, allowedHost) {
watchOptions: {
ignored: ignoredFiles(paths.appSrc),
},
writeToDisk: filePath => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow

return /react-client-manifest\.json$/.test(filePath);
},
https: getHttpsConfig(),
host,
overlay: false,
Expand Down
2 changes: 1 addition & 1 deletion fixtures/flight/server/handler.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = function(req, res) {
import('../src/App.server.js').then(m => {
const dist = process.env.NODE_ENV === 'development' ? 'dist' : 'build';
readFile(
resolve(__dirname, `../${dist}/react-transport-manifest.json`),
resolve(__dirname, `../${dist}/react-client-manifest.json`),
'utf8',
(err, data) => {
if (err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
* @flow
*/

import {mkdirSync, writeFileSync} from 'fs';
import {dirname, resolve, join} from 'path';
import {join} from 'path';
import {pathToFileURL} from 'url';

import asyncLib from 'neo-async';
Expand Down Expand Up @@ -48,13 +47,16 @@ type Options = {
isServer: boolean,
clientReferences?: ClientReferencePath | $ReadOnlyArray<ClientReferencePath>,
chunkName?: string,
manifestFilename?: string,
};

const PLUGIN_NAME = 'React Transport Plugin';

export default class ReactFlightWebpackPlugin {
clientReferences: $ReadOnlyArray<ClientReferencePath>;
chunkName: string;
manifestFilename: string;

constructor(options: Options) {
if (!options || typeof options.isServer !== 'boolean') {
throw new Error(
Expand Down Expand Up @@ -88,6 +90,8 @@ export default class ReactFlightWebpackPlugin {
} else {
this.chunkName = 'client[index]';
}
this.manifestFilename =
options.manifestFilename || 'react-client-manifest.json';
}

apply(compiler: any) {
Expand Down Expand Up @@ -189,13 +193,14 @@ export default class ReactFlightWebpackPlugin {
});
});
const output = JSON.stringify(json, null, 2);
const filename = resolve(
compiler.options.output.path,
'react-transport-manifest.json',
);
mkdirSync(dirname(filename), {recursive: true});
// TODO: Use webpack's emit API and read from the devserver.
writeFileSync(filename, output);
compilation.assets[this.manifestFilename] = {
source() {
return output;
},
size() {
return output.length;
},
};
});
}

Expand Down