-
Notifications
You must be signed in to change notification settings - Fork 131
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
Webpack migration #842
Webpack migration #842
Conversation
16e78c6
to
d0110fd
Compare
The issue with broken production build was fixed. Now there is a another one when the navigation and the user are sometimes not set in the redux store. (they are not set fast enough) |
d0110fd
to
5ab30e7
Compare
The issue with missing identity information are resolved. Now I will start to clean up the mess I did in the JS files and move to other build tasks. |
b6d222d
to
9e53e52
Compare
Codecov Report
@@ Coverage Diff @@
## master #842 +/- ##
==========================================
- Coverage 58.18% 56.69% -1.49%
==========================================
Files 48 49 +1
Lines 959 933 -26
Branches 187 189 +2
==========================================
- Hits 558 529 -29
- Misses 324 325 +1
- Partials 77 79 +2
|
The migration is complete. @karelhala @ryelo Can I ask you to do check this build? You know the platform better than me and it is very likely that I have forgot to check some app or a feature. Looking at the build output, we are doing fairly OK. The main issue is inventory dependencies. It pulls around 1.4mb and the fact that chrome itself has some strangely large dependencies. I am optimistic that we can fix it but we will most likely need to start with FCE. |
@Hyperkid123 Yes! I'll dig through some of this later today |
@Hyperkid123 I tested this with both the landing page and RBAC and I'm getting a bunch of chunk failures. The apps are still rendering, but they leave the nav and masthead unusable. |
@ryelo interesting I am not seeing that. Maybe some cache issue? I will try and reproduce it. |
@ryelo there a bug with the public path. There was missing I was experiencing some strange cache issues while switching to the webpack. Some times it was trying to load assets that no longer existed. I hope I wont be an issue for you. |
be874fc
to
4042e73
Compare
@Hyperkid123 So this one seems better for some pages, but a couple more bugs I'm getting:
Although I also can't get the sourcemaps to load, so it's kind of difficult to see where number 2 is coming from. |
@ryelo I don't see that when I run it locally 🤔 in which app are you seeing that? The skeleton is coming from FCE. It tries to reach totally wrong resource at
EDIT: The undefined call appears in RBAC. I will find what is going on there. |
@ryelo well, the CSS invalid routes is actually not caused by this PR. I am setting that currently on |
f3872b8
to
f59931c
Compare
So the undefined call is caused by using the Suspense/lazy combination. Turning off side effects for production optimizations (is set to true by default) might help with that. EDIT: Side effects did not help |
@ryelo as usual the simplest solution is the best. I've renamed the The issue was that sometimes (completely random) the application has overwritten the chrome chunks inside the JSONP object. These objects are publically accessible on window so if you have multiple instances of webpack on one page, webpack will try to put everything into the same object. This works fine until you start using lazy-loaded chunks. Chrome now has its own namespace called |
@Hyperkid123 That's a wild journey! I'll have some time tomorrow that I can go over it again. Thanks for looking over this stuff! |
c4fb1f6
to
cdcf3a7
Compare
Just dropping this here from our conversation @Hyperkid123 https://github.com/jherr/wp5-intro-video-code so we don't forget about it. Great point using this for inventory @rvsia! |
9c64192
to
9bd8f02
Compare
01c596b
to
c5dc4f9
Compare
@Hyperkid123 I'm getting some errors on build
|
Ah. I guess this was caused by the latest inventory refactoring eh? We will probably need to adjust the externals configuration. |
@ryelo ok I've added new inventory dependencies package names to externals and the build is running (also tried to run it locally and worked with the catalog app). |
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.
All of the externals from config should be reverted to previous module.exports
since that's slightly different from what export default
does. If we want to use imports and exports (without module.exports) we have to figure out how to spread the hot loaded deps.
import React, { Component } from 'react'
won't work if used in export default
mode, but will work with module.exports
since we are exporting default and named exports as well.
Also, looks like running npm run build
won't use newer bundles, might be reasonable to purge build/js
and build/css
when running build or start script.
config/webpack.config.js
Outdated
chunkFilename: '[name].[chunkhash].js', | ||
jsonpFunction: 'wpJsonpChromeInstance' | ||
}, | ||
externals: { |
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.
Externals won't work as these are not externals but rhat pulled from different app. I think that resolve.alias
is more suitable for this
resolve: {
alias: {
PFReactTable: path.resolve(__dirname, './patternfly-table-externals.js'),
'@patternfly/react-table': path.resolve(__dirname, './patternfly-table-externals.js'),
customReact: path.resolve(__dirname, './react-external.js'),
reactRedux: path.resolve(__dirname, './react-redux-external.js'),
'react-router-dom': path.resolve(__dirname, './react-router-dom-externals.js'),
graphql: path.resolve(__dirname, './graphql-externals.js')
}
}
src/js/inventory.js
Outdated
@@ -4,6 +4,6 @@ export default (dependencies) => { | |||
setDependencies(dependencies); | |||
|
|||
return import('./inventoryStyles').then( | |||
() => import('@redhat-cloud-services/frontend-components-inventory') | |||
() => import(/* webpackChunkName: "inventory-styles" */ '@redhat-cloud-services/frontend-components-inventory') |
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.
I'd name this inventory
instead of inventory-styles
. Also might be resonable to name styles as well
return import(/* webpackChunkName: "inventory" */ './inventoryStyles').then(
() => import(/* webpackChunkName: "inventory" */ '@redhat-cloud-services/frontend-components-inventory')
)
src/js/inventoryStyles.js
Outdated
@@ -1,2 +1,7 @@ | |||
/** |
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.
Should be fixed.
@karelhala yeah we would have to use |
d441c58
to
781371f
Compare
c0d9451
to
7ebb35b
Compare
@karelhala so I have fixed the npm scripts. A couple of notes
So the start and watch scripts should be working now. I can't think of anything else we need to do to finish this up. |
fc133ff
to
f4a9e50
Compare
It will remove any potential issues with stale root chunk. That helps enormously when making any changes and using local chrome. The downside is, that you need to serve the HTML locally as well.
Webpack has the same defalt jsonP value for every bundle. If you run multiple instances of webpack on one page these instances are merged and chunks can be replacd which will cause issue when using lazy loading. By renaming chrome webpack instance, we eliminate potential conflicts and we can keep using lazy loading.
f4a9e50
to
179c766
Compare
Replace parcel by webpack and optimize the js built output
cc @karelhala
TO DO
Major development change
I was constantly dealing with cache issues in development. That was solved by adding a chunk hash to the root
chrome.js
file. However, this means that in development we also need to serve the HTML generated from pug templates.I do believe we want to include the hash if the app is using code splitting to avoid any potential issue with state root JS asset. But this change makes the development bit harder. You have to also run some app and you need to manually add the root element to body. However, without that the development was a serious pain because I was constantly dealing with outdated JS assets and the app was sporadically failing when using minimized bundles. @ryelo @karelhala your thoughts?