-
Notifications
You must be signed in to change notification settings - Fork 102
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
refactor(fec): Fixes, improvements and moar options #2007
base: master
Are you sure you want to change the base?
Conversation
} | ||
|
||
return { | ||
...console, |
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.
... it works, but I'm a bit unsure if that's right.
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.
Its fine.
} | ||
|
||
return { | ||
...console, |
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.
Its fine.
routes: internalProxyRoutes, | ||
appUrl, | ||
...(fecConfig.appUrl ? { appUrl: createAppUrl(fecConfig.appUrl) } : {}), |
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.
If the app URL is not setup, the dev proxy won't really work. We should throw error rather than using fallback.
@@ -13,6 +14,10 @@ const createIncludes = (eager = false): { [module: string]: WebpackSharedConfig | |||
'@redhat-cloud-services/chrome': { singleton: true }, | |||
axios: {}, | |||
lodash: {}, | |||
// TODO I would propose to remove this from the shared deps |
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.
Yes, we should remove anything that is not a singleton. And generate the shared dependencies form that package.json.
With the exception to PF as we are generating the shared modules individually.
We should also avoid sharing anything without a version requirement.
process.exit(); | ||
if (!skipProxyCheck && hasCurlInstalled()) { | ||
if (!checkLocalAppHost(appName, appUrl, appPort)) { | ||
process.exit(); |
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 add an exit code. We read it in other processes sometimes.
packages/config-utils/src/proxy.ts
Outdated
} | ||
|
||
if (customProxy) { | ||
proxy.push(...customProxy); | ||
} | ||
|
||
let standaloneConfig: ReturnType<typeof getConfig>; | ||
// TODO do we need this "standalone" mode still? | ||
// We should at least extract this into it's own module |
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.
Some are using it, but I am not a fan of it. I don't think we can remove it just yet.
However, it was never maintained by us. At minimum I would deprecate the option and a log a warning.
@@ -267,6 +282,7 @@ export const createConfig = ({ | |||
disableDotRule: true, | |||
}, | |||
devMiddleware: { | |||
// TODO Figure out if this helps in any way or if it is required for something |
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.
Used to be able to modify the build files in dev env.
@@ -287,14 +303,12 @@ export const createConfig = ({ | |||
proxyVerbose, | |||
target, | |||
registry, | |||
onBeforeSetupMiddleware: ({ chromePath }) => { |
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.
This has to stay. Apps do not have their own HTML templates.
@@ -11,12 +12,19 @@ const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin' | |||
const { glob } = require('glob'); | |||
const path = require('path'); | |||
|
|||
const chromeIndexHtmlUrl = (env = 'dev-stable') => { |
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.
Can't use this. We will be removing the build repositories. Old build pipeline is coming to an end. We will be suing the container images as the source of truth for local chrome.
|
||
export interface FECConfiguration | ||
extends Partial<Omit<CreateConfigOptions, 'appUrl' | 'appName' | 'env' | 'rootFolder'>>, | ||
Partial<Omit<CreatePluginsOptions, 'rootFolder' | 'appName'>> { | ||
appName: never; | ||
appUrl: string | string[] | (string | RegExp)[]; | ||
appUrl?: string | string[] | (string | RegExp)[]; |
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.
This is mandatory.
configurations.isProd = configurations.isProd || process.env.NODE_ENV === 'production'; | ||
const isProd = configurations.isProd; | ||
const { insights } = require(`${configurations.rootFolder}/package.json`); | ||
|
||
// TODO We should deprecated building based upon git branches |
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.
Yes. Remove only once all apps are on the current build pipeline.
e3139e7
to
b0e6e45
Compare
This PR adds a (few) fix(es) and improvements to the
fec
command:npm run start
commands for the config packagesJust for convenience. I got tired of manually building all the time.
The
—port
flag was not fully working I thought that thePORT
var was recognised by fec/webpack, but I realised it is something we have implemented in the apps’ fec config.This is to make it more convenient to start an app adhoc with routes for another app, without having to use a ENV var. The code to build the routes has also been slightly refactored and now also allows to setup routes for
/api
as well via an--api
optionThese are flags for options that we have often configured in
fec.config.js
via ENV vars to allow them to be variable then callingfec
. For example, in many apps we use aPROXY=true
env variable to toggleuseProxy
int the fec config.This is to try and make the
onBeforeSetupMiddleware
obsolete, or at least reduce its responsibilities to make migrating tosetupMiddleware
easier or even unnecessary. It's also a cleaner implementation using the HTMLWebpackPlugin. At least a tiny bit. The cloning of the repo is removed as well. We really only need the index.html file, but if we realise we need more we can easily restore this.Where I touched code I replaced the
console.log
calls withfecLogger
. Even webpack now logs viafecLogger
. For consistency.It has been very useful at times when debugging issues to inspect the fec config and webpack config. This new option will make it more convenient without having to hack in some console.logs somewhere, and will show the full "fec" config passed in and the full resulting webpack config.