-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
feat: Webpack 5 Experimental Support #10885
feat: Webpack 5 Experimental Support #10885
Conversation
packages/next/build/index.ts
Outdated
console.log() | ||
|
||
result = formatWebpackMessages(result) | ||
console.log('There were errors!') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs to be fixed
@@ -34,14 +34,13 @@ import ChunkNamesPlugin from './webpack/plugins/chunk-names-plugin' | |||
import { CssMinimizerPlugin } from './webpack/plugins/css-minimizer-plugin' | |||
import { importAutoDllPlugin } from './webpack/plugins/dll-import' | |||
import { DropClientPage } from './webpack/plugins/next-drop-client-page-plugin' | |||
import NextEsmPlugin from './webpack/plugins/next-esm-plugin' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
broken in WP5, will address later
) | ||
if (!webpack5Experiential) { | ||
// Not needed with webpack 5 | ||
const AutoDllPlugin = importAutoDllPlugin({ distDir }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WP5 has its own cache, and its faast
fc21eb9
to
fab520b
Compare
Enabling module federation & suspense SSR
Enabling module federation & suspense SSR
* disable hmr in dev move * feat: Upgrade Next.js to Webpack 5 Enabling module federation & suspense SSR * fix: dirty patch for missing router context * fix: dirty patch for missing router context * fix: dirty patch for missing router context * fix: dirty patch for missing router context * fix: use dirty patch on server
* v9.3.2-beta.0 * v9.3.2-beta.1 * v9.3.2-beta.2 * v9.3.2-beta.3 * fix: * docs: update readme
fab520b
to
ee0680c
Compare
e6120c3
to
7fba66b
Compare
@@ -120,7 +120,13 @@ export default singletonRouter as SingletonRouter | |||
export { default as withRouter } from './with-router' | |||
|
|||
export function useRouter() { | |||
return React.useContext(RouterContext) | |||
if (process.browser) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need some help on this one, HMR or SSG seems to lose context
@@ -442,6 +442,8 @@ export async function renderToHTML( | |||
const router = new ServerRouter(pathname, query, asPath, { | |||
isFallback: isFallback, | |||
}) | |||
global.router = router |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another hack, losing context during HMR or SSG
* v9.3.2-beta.0 * v9.3.2-beta.1 * v9.3.2-beta.2 * v9.3.2-beta.3 * fix: * docs: update readme
7fba66b
to
f8bd32e
Compare
Against master, 1700 tests pass. Most failures are around HMR or SSG - I resolved many of these with workarounds. The remaining tests are mostly related to format messages @timneutkens Willing and ready to work with your team on this upgrade. From my perspective, its pretty far along. Canary introduces some changes which I'm not sure how to address, like externals for webpack-dev-server which no longer exist in v4 rc While in there, it would be great if we can support the ability to use ModuleFederation - this does not need to be part of next.js core, but it would be nice to try it out and see if there are any adjustments that would enable its use. I'm willing to open an additional PR for this aspect as well, perhaps at a later stage |
This is a WIP PR to add Webpack 5 support to next.js
There are some outstanding areas that will need work. But it's functional.
on-demand-entries-handler
needs to be rewritten and provide WP4 & WP5 compatibilityformatMessages
needs to be updated to parse output messages again, most of it is commented out right nowEsmPlugin
- Needs a dependency factory because MiltiEntryPlugin was removedon-demand-entries-handler
- a workaround I'm using isuncachedRequire
Module not found: Error: Can't resolve 'pnpapi' in '/next.js/node_modules/enhanced-resolve/lib'"
When doing a seerverless buildhot-reloader
This pull request is also needed.
vercel/next-plugins#620
I am publishing all this code to npm under module-federation org https://github.com/module-federation