-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add module federation support #11241
Conversation
* Revert "Revert "Update postcss packages" (facebook#10216)" This reverts commit 3968923. * Revert "Update postcss packages" (facebook#10216) This reverts commit 580ed5d. * Update postcss and loader * Update [email protected] References: * [hook rename](TypeStrong/fork-ts-checker-webpack-plugin#490) * [include/exclude](TypeStrong/fork-ts-checker-webpack-plugin#450) and [issue options](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin#issues-options) * [release notes 5.0.0](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/releases/tag/v5.0.0) * Update fork-ts-checker-webpack-plugin 6.0.5 * Add [email protected] remove Add [email protected] Remove optimize-css-assets-webpack-plugin and postcss-safe-parser References: * https://webpack.js.org/plugins/css-minimizer-webpack-plugin/ * Add support for Webpack 5 message objects * Update WebpackManifestPlugin to v3.0.0 * Support both "SingleEntryPlugin" and "EntryPlugin" * Support Webpack 5 IgnorePlugin signature Reference: * https://webpack.js.org/plugins/ignore-plugin/#example-of-ignoring-moment-locales * facebook#10006 * Update webpack and dev server * Enable persistent cache * Fix react-error-overlay webpack * Fix dev server config * Remove support for SingleEntryPlugin * update workbox-webpack-plugin * Fix post css config * Comment out WebpackManifestPlugin for now having issues with undefined path * Add fast refresh entries to ModuleScopePlugin * Format files * Remove unused variables in start command * git ignore tsconfig.tsbuildinfo supporting incremental typescript builds * simplify output path review feedback from @kumarlachhani * Use asset modules in react-scripts * Use asset modules in react-error-overlay * eslint-config-react-app typo fix (facebook#10317) This just fixes a shell snippet in the readme file for this plugin * Fix link address (facebook#10907) Replace the Github home link with a link to the repo's main page or a link to the source (https://github.com/CodeByZach/pace/blob/master/pace.js) * Bump immer version for fixing security issue (facebook#10791) Bump immer minor version to fix `Prototype Pollution` Security issue. * test(create-react-app): add integration tests (facebook#10381) * Revert "Use asset modules in react-error-overlay" This reverts commit 952f896. * Disable broken tests for now * Revert source-map bump in react-error-overlay * JSON is using default export * Webpack config: Remove invalid parser configuration * Fix issue with ModuleScope and babel runtime * Fix svgr configuration * Webpack config svg use file-loader instead of url-loader * Update postcss-normalize * Fix asset output name * Update test matrix using node 12+14 postcss normalize only support node >=12 * Fix file output extension * Align assetModuleFilename * pipeline update configuration names * Add back webpack-manifest-plugin * Fix kitchen sink get actual href value .href is prefixed with http://localhost etc. * Update kitchen sink test to webpack 5 asset modules * Let webpack handle global this * Fix eject copy config/webpack/persistentCache folder * Move tsbuildinfo into cache folder * Update dependencies * Update webpack-dev-server to beta.3 * Compilation.modules changed to type Set reference: comment by @slorber facebook#9994 (comment) * Format JsonInclusion.js using prettier * Run prettier on webpack dev server config * Enable e2e behavior tests using node 12+14 * Comment out e2e behavior tests for now * Add experimental support for module federation * Fix missing wds socket path update accordingly to review by @xiaokekeT * Revert "Add experimental support for module federation" This reverts commit 8fdc63b. Co-authored-by: Ian Schmitz <[email protected]> Co-authored-by: jasonwilliams <[email protected]> Co-authored-by: Joseph Atkins-Turkish <[email protected]> Co-authored-by: e-w-h <[email protected]> Co-authored-by: Shamprasad RH <[email protected]> Co-authored-by: James George <[email protected]>
prevent yarn warnings
…ized Would be great with wildcard support in ModuleScopePlugin
Warning: Ubuntu 16.04 LTS environment is deprecated and will be removed on September 20, 2021. Migrate to ubuntu-latest instead. For more details, see actions/runner-images#3287
this should be the default already in webpack 5 - to enable require ensure use https://webpack.js.org/plugins/internal-plugins/#requireensureplugin
On v4.14.1 linux tests failed: Node Sass does not yet support your current environment: Linux 64-bit with Unsupported runtime
This is a breaking change in the webpack 5 update
This reverts commit 0674cd7.
@raix I recreated the module federation PR but some of the checks are still missing. It seems build and lint pipelines work only on push, and integration tests work when the target branch of the PR is |
Co-authored-by: Douglas Zaltron <[email protected]>
@raix are you happy with the current state of the PR? is there anytrhing else I should do? |
@hasanayan overall looks good, Thanks for picking up this task 👍 Ive asked the maintainer group if there were any objections for getting this in - so waiting for responses. Only notes/thoughts I have is that I need to test/qa a bit, not sure if the template plug-in is needed for the initial pr (eg. We could also add the plugin for auto sharing of dependencies etc. Ideally with some sane defaults/without the need for configuration - but could go in later) |
@raix you are welcome. Thanks for working hard on wp5 support and opening way for this. it's an opt-in feature, however, If you decide that the template plugin should go, just let me know. Also, if you need any clarification (possibly on publicPath values I set) I'll be happy to help. |
@hasanayan for now the maintainer group decided to prioritize wp5 update as the 5.0 version, it's a large change to triage issues - module federation would go into a next minor release as it's not breaking anything eg. 5.1 |
I'm having the same issue with #9510 (comment).
Interestingly, I don't have an issue if I turn off |
@shuttleriiiz it’s actually supposed to work even with fast refresh and we are using an almost identical config in development/production. I will look into it in the morning. |
@hasanayan I did some digging and found that there is a bug on see: https://github.com/pmmmwh/react-refresh-webpack-plugin/pull/434/files |
thanks @shuttleriiiz , I opened another PR to fix react-refresh-webpack-plugin version: #11316 |
trying to sync with main branch messed this PR. I'll recreate this this evening |
@hasanayan not sure if you could do |
@hasanayan what's the current status of this PR? |
@hasanayan in testing this, I am seeing webpack errors when trying to process a CSS package that contains a
For example: App.js import `typeface-roboto` typeface-roboto/index.css /* roboto-100normal - latin */
@font-face {
font-family: 'Roboto';
font-style: normal;
font-display: swap;
font-weight: 100;
src:
local('Roboto Thin '),
local('Roboto-Thin'),
url('./files/roboto-latin-100.woff2') format('woff2'), /* Super Modern Browsers */
url('./files/roboto-latin-100.woff') format('woff'); /* Modern Browsers */
}
... This seems related to https://github.com/facebook/create-react-app/pull/11241/files#diff-8e25c4f6f592c1fcfc38f0d43d62cbd68399f44f494c1b60f0cf9ccd7344d697R327-R331 Commenting out that block seems to retain all intended and existing functionality, but I'd love more eyes or context - I don't dive into webpack too often. |
I re-enabled @raix's code to enable module-federation and added the necessary changes to the webpack config. Tested the changes by making the same modifications using craco in apps that both run as standalone or remote apps and it works fine.
With this PR, to enable Module Federation, you'll need a file named .modulefederationrc.js which exports ModuleFederationPlugin parameters as json.
in addition to that, including a mmodule federation file and setting EXTERNAL_TEMPLATE_REMOTES env var to 'true' includes ExternalTemplateRemotesPlugin into the config.
(if you want to help out on that, then checkout this branch - when checking of the cra project run
yarn
then create a provider and consumer app usingyarn create-react-app
and read the MF docs usingdocusaurus/docs
yarn start
:)