Skip to content

Conversation

michenly
Copy link

@michenly michenly commented Oct 20, 2021

get the same plugin from react-server-dom-webpack to be compatible with webpack 5

  • write it in TypeScript so I can make use of typing to find webpack internal interface
  • build-old is the old assets the webpack 4 version of plugin produce
  • to build, run npm run bundler:dev
  • all the changes in plugins/react-server-dom-webpack-plugin.ts
  • eventually upstream plugins/react-server-dom-webpack-plugin.js

@michenly
Copy link
Author

michenly commented Oct 20, 2021

The problem I am running into for getting webpack 4 -> webpack 5

  • additional assets is not being created (compilation.chunkGroups only shows main so this is consistent)
  • AsyncDependenciesBlock was originally created with dep.require for request param. Changed it to use dep.request but it also has undefined attached to the end. Temp just hack it out.
  • compilation.chunkGraph.getChunkModulesIterable(chunk) will list our 5 modules without module.resource or module.id. However, 5 is exactly the number of additional assets the webpack 4 version create...so...there is something there...
  • a manual Async chunk would get created in addChunkInGroup, b/t compilation.hooks.beforeChunks && compilation.hooks.afterChunks hooks
  • at the end of complication.hooks.buildModule, module.blocks.length = 8, in compilation.hooks.succeedModule, module.blocks.length = 0, something happened in b/t

@michenly
Copy link
Author

michenly commented Oct 21, 2021

Found the issue. compliation.hooks.buildModule cannot be use to modify dependencies & blocks in webpack 5. Need to use hooks.parser instead webpack/webpack#13361

@michenly
Copy link
Author

michenly commented Nov 8, 2021

This plug in is now working in webpack 5 with 1 small hack

  • request has undefined at the end: I have a hack for it so far, but need to solve it at the root level

@michenly michenly changed the title Plugin optimization RSC webpack 5 plugin Nov 8, 2021
@michenly
Copy link
Author

Proper PR had been open facebook/react#22739 and I will open a new PR to update the demo to use the new plugin when it is ready.

@michenly michenly closed this Nov 10, 2021
@michenly michenly deleted the plugin-optimization branch November 10, 2021 22:34
@michenly michenly restored the plugin-optimization branch November 10, 2021 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants