-
Notifications
You must be signed in to change notification settings - Fork 9
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
Update webpack to v5.xx #1258
Update webpack to v5.xx #1258
Conversation
Merge successful
|
|
I've ensured that |
the error does indeed point to a font in the frontend:
|
@kr8n3r I can't keep up with the PRs 😆 this is ready to review! |
conflict in merged lock: npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: webpack@4.46.0
npm ERR! node_modules/webpack
npm ERR! dev webpack@"^4.46.0" from the root project
npm ERR! peer webpack@"4.x.x || 5.x.x" from @webpack-cli/configtest@1.0.3
npm ERR! node_modules/@webpack-cli/configtest
npm ERR! @webpack-cli/configtest@"^1.0.3" from webpack-cli@4.7.0
npm ERR! node_modules/webpack-cli
npm ERR! dev webpack-cli@"^4.7.0" from the root project
npm ERR! 3 more (@webpack-cli/configtest, @webpack-cli/info, @webpack-cli/serve)
npm ERR! 6 more (css-loader, mini-css-extract-plugin, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^5.1.0" from compression-webpack-plugin@7.1.2
npm ERR! node_modules/compression-webpack-plugin
npm ERR! dev compression-webpack-plugin@"^7.1.2" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /home/oatman/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/oatman/.npm/_logs/2021-06-02T15_17_27_165Z-debug.log |
pushed up rewritten commit history to make rebasing easier As mini-css-extract-plugin ties to insert a link tag (via document.) it doesn't really work with SSR. Need to figure out if theres a way be can export |
476e892
to
a7474bb
Compare
Riddle me this: ERROR in ./src/layouts/template.tsx 7:43-73
Module not found: Error: Can't resolve '../../dist/manifest' in '/home/oatman/projects/gds/paas/paas-admin/src/layouts'resolve '../../dist/manifest' in '/home/oatman/projects/gds/paas/paas-admin/src/layouts'
using description file: /home/oatman/projects/gds/paas/paas-admin/package.json (relative path: ./src/layouts)
using description file: /home/oatman/projects/gds/paas/paas-admin/package.json (relative path: ./dist/manifest)
no extension
/home/oatman/projects/gds/paas/paas-admin/dist/manifest doesn't exist
.ts
/home/oatman/projects/gds/paas/paas-admin/dist/manifest.ts doesn't exist
.tsx
/home/oatman/projects/gds/paas/paas-admin/dist/manifest.tsx doesn't exist
.js
/home/oatman/projects/gds/paas/paas-admin/dist/manifest.js doesn't exist
.json
/home/oatman/projects/gds/paas/paas-admin/dist/manifest.json doesn't exist
as directory
/home/oatman/projects/gds/paas/paas-admin/dist/manifest doesn't exist
@ ./src/layouts/index.ts 6:21-42
@ ./src/components/application-events/controllers.tsx 8:18-42
@ ./src/components/application-events/index.ts 4:21-45
@ ./src/components/app/router.ts 7:47-79
@ ./src/components/app/index.ts 10:21-40
@ ./src/main.ts 6:38-65
webpack 5.38.1 compiled with 1 error in 22821 ms AND YET λ cat /home/oatman/projects/gds/paas/paas-admin/dist/manifest.json
{
"main.js": "/main.js",
"assets/govuk.screen.css.map": "/assets/6e483ced48ac3951527egovuk.screen.css.map",
"assets/postgres.png": "/assets/1b9b2da8d94b8c3d4a15.postgres.png",
"assets/influxdb.png": "/assets/edd08553c3a7de815b44.influxdb.png",
"assets/sqs.png": "/assets/93629362d6c0b2dd2120.sqs.png",
"assets/elasticsearch.png": "/assets/19a417093d9756975d56.elasticsearch.png",
"assets/init.js.map": "/assets/init.js.map",
"assets/govuk.screen.css.gz": "/assets/6e483ced48ac3951527egovuk.screen.css.gz",
"assets/autoscaler.png": "/assets/c17f95367648a6936504.autoscaler.png",
"assets/redis.png": "/assets/52a85440d0cb10638fe8.redis.png",
"assets/s3.png": "/assets/77fd1266970b7e8cff57.s3.png",
"assets/cdn.png": "/assets/6a075556a455bd2589e9.cdn.png",
"assets/cloud.png": "/assets/e68566b16e48eaf1308b.cloud.png",
"assets/init.js.gz": "/assets/init.js.gz",
"assets/sankey.js.map": "/assets/sankey.js.map",
"assets/mysql.png": "/assets/a4438110aaccb83f3a53.mysql.png",
"assets/sankey.js.gz": "/assets/sankey.js.gz",
"main.js.map": "/main.js.map"
} |
Progress, faking the manifest until after build pushes the import error into after tests pass: Test Suites: 79 passed, 79 total
Tests: 757 passed, 757 total
Snapshots: 0 total
Time: 15.034 s, estimated 31 s
Ran all test suites.
error: Unable to resolve path to module '../../dist/manifest' (import/no-unresolved) at src/layouts/template.tsx:4:22:
2 | import { renderToStaticMarkup } from 'react-dom/server';
3 |
> 4 | import manifest from '../../dist/manifest';
| ^
5 | import { IViewContext } from '../components/app';
6 | import { Breadcrumbs, IBreadcrumbsItem } from '../components/breadcrumbs';
7 | |
Even with the watcher disabled, the builder cycles building between TS and the manifest.json. I think we have a circular dependency.
|
After trying and faling to disable the webpack watcher and rebuilding processes, I think a solution to this, perhaps, is to disable watching in dev, and wrap the whole webpack build in a different watching process, one that is outside of the webpack dependency world, perhaps something like https://www.npmjs.com/package/npm-watch |
9f5f6da
to
2b3cefe
Compare
I have looked at other ways of sorting this circular dependency rebuilt issue and have ultimately decided to revert back to un-hashed css file name. More details in e7d7943 |
37c77ef
to
0c8eeb5
Compare
I'm up-to-date. Sounds totally reasonable to go back to unhashed filenames, given the trouble we had. |
0d086c5
to
8ac2669
Compare
Bump webpack to v5.x and required plugin versions
- Removed `output.path: path.resolve(__dirname, 'dist')` as that's the default. - Removed `output.filename: '[name].js'` as that's the default. - Replaced `[hash]` with `[contenthash]` - It is not the same, but proven to be more effective - from migration docs - Update entry and devtool configuration I don't think there's a need to have the source maps in production, especially as init.js filesize increases to +80KB Webpack 5 seems not like to generate sourcemaps with the old entry naming. Switching to [Entry Descriptor](https://webpack.js.org/configuration/entry-context/#entry-descriptor) fixes that. - Bump compression-webpack-plugin and set it to keep sourcemaps - Use asset modules for static assets `file-loader` is deprected for v5 and https://webpack.js.org/guides/asset-modules/ is the recomended approach. - Use mini-css-extract-plugin to generate a stylesheet - Remove @intervolga/optimize-cssnano-plugi andreplace with CssMinimizerPlugin
- update css extract plugin config with filename - update css import and reference in the template file Mini-css-extract-plugin generates a file and wan'ts to insert the link to the assets in the browser. This being a server-side rendered app, it cannot do that, so we need to manually link to the file. While webpack can gerate the file with a cache-busting string there is no reliable way to export that and use in the template. We have tried with webpack-manifest plugin, but ran into a circular-dependency contstant rebuild and a test error for an empty file. While ideally we'd have cache-busting, but our server is already set without any cache headers (suspect because of client js), so the broser will request the CSS file everytime, meaning we're not loosing much if anything. Happy to accept this compromise until we can spend more time looking at the whole pipeline.
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.
Let's just get it over with, I cannot stand looking at this card no mo...
Good job everyone.
Same! |
What
Update webpack to latest version along with the config update, plugin updates and mitigation of any deprecations
Co-authored with @0atman and @paroxp
Build comparison with v4
Development
V4
V5
Production
V4:
V5
How to review
Who can review
anyone