Skip to content
Closed
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
move run to beforeCompile hook and use the current contextModuleFactory
  • Loading branch information
michenly committed Nov 8, 2021
commit b0dc0319f1053d8acbdb9ce117f52a85e86b96fd
16 changes: 4 additions & 12 deletions plugins/react-server-dom-webpack-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,14 @@ export default class ReactFlightWebpackPlugin {

let clientFileNameFound = false;

function run (_params, callback) {
// First we need to find all client files on the file system. We do this early so
// that we have them synchronously available later when we need them. This might
// not be needed anymore since we no longer need to compile the module itself in
// a special way. So it's probably better to do this lazily and in parallel with
// other compilation.
compiler.hooks.beforeCompile.tapAsync(PLUGIN_NAME, ({contextModuleFactory}, callback) => {
const contextResolver = compiler.resolverFactory.get('context', {});

_this.resolveAllClientFiles(
compiler.context,
contextResolver,
compiler.inputFileSystem,
compiler.createContextModuleFactory(),
contextModuleFactory,
function(err, resolvedClientRefs) {
if (err) {
callback(err);
Expand All @@ -130,11 +125,8 @@ export default class ReactFlightWebpackPlugin {
callback();
}
);
};

compiler.hooks.run.tapAsync(PLUGIN_NAME, run);

compiler.hooks.watchRun.tapAsync(PLUGIN_NAME, run);
});


compiler.hooks.thisCompilation.tap(PLUGIN_NAME, function(compilation: Compilation, {normalModuleFactory}) {
compilation.dependencyFactories.set(
Expand Down