-
Notifications
You must be signed in to change notification settings - Fork 9
Refactor codebase to be a monorepo project #40
Conversation
This CR is the first step to finish: #40 |
Issue 1We may want to convert this to a yarn workspace to avoid the dependency issue. Typically module resolution would not go up a directory unless it was not found in the closest node_modules. So either it was not listed which seems unlikely, or it was not passing |
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.
Issue 2
I wonder if you would be able to just call localhost:5000 directly, I also did not see any of the proxy work you mentioned within the react app.
Another option we could do is containerize this and set it up with a proxy that makes it look as though it is all one project. This is how our EB internal setup works.
package.json
Outdated
"lint": "", | ||
"client": "cd web-app && PORT=5000 yarn start", | ||
"server": "DEBUG=ferreiro:* nodemon --exec babel-node ./bin/www", | ||
"dev": "concurrently --kill-others-on-fail \"yarn server\" \"yarn build\" \"yarn client\" \"yarn watch\"", |
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.
do you need to gulp build
& gulp watch
in the same command. My first though would be that watch
is running build
continuously.
web-app/src/App.js
Outdated
componentDidMount = () => { | ||
// This code should call: http://localhost:3000/api/status | ||
// and return {"response":"Everything is working correctly"} | ||
fetch('/api/status') |
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.
Why could you not just call over to localhost:5000? did you get a cors error?
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.
Yeap! I got a cors error.
Access to fetch at 'http://localhost:3000/api/status' from origin 'http://localhost:5000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Also, I think the problem of using directly dev endpoints is that we'll need to change that once deployed (or implement some logic like: if DEVELOPMENT => localhost:3000, otherwise "ferreiro.me/". I think that's the purpose of the proxy, but not working)
@kwelch OK! I'm updating this to use => https://yarnpkg.com/lang/en/docs/workspaces/#toc-how-to-use-it |
In the lasts commits I've refactored the logic to be monorepo!!!! Question: Do we want to have in the repo the |
Yay! Found in the last bunch of commits how to create a local package, and add it as a dependency to another package.
Voila! Now, in order to use the local copy of the package I run |
@kwelch Hey! Excited about this new revision. I think we're really close to launch to prod! After some tweaks and updates, the webpage is up!!! https://ferreiro-monorepo.herokuapp.com/ Main changes:
Some other changes in order to make heroku works:
Also, I needed to move |
package.json
Outdated
"buildAssets": "yarn workspace @ferreiro/server build-assets", | ||
"dev": "yarn install && yarn buildAssets && concurrently --kill-others-on-fail \"yarn devServer\"", | ||
"start": "yarn server", | ||
"heroku-postbuild": "npm run buildAssets" |
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.
running yarn in a bunch of places then npm seems odd.
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.
Done! Good catch :)
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 looks simple and great. We could possible remove the design-system since it is not necessary, but all in all this works well.
We could get around this but it would involve compiling the server before deploying. This is probably not necessary extra piece. Adding babel as a dep is not that bad. |
Merging this now! Thanks @kwelch for following up on this. I leave the design system since is gonna be part of the next steps, so we can have that as the starting point. |
* Monorepo! client and server * Updated package.json, removed unused dependencies (using npm-check). * Fixed Heroku scripts from package.json * Renamed packages to ferreiro-server and ferreiro-web * Updating package.json to use new packages/* routes * Created design system package * Moved dependencies to dev and removed unused using npm-check CR: #40
fixes #41 |
Moving here the issues that I posted before in the description, since they are not relevant there anymore. But I wanna keep the story of this task. Known issuesIssue 1: When
|
In this PR I'm creating a react app for the project, and in order to be able to have independent
client
andserver
I'm updating the project to use a mono-repo approachIn order to connect react app with the server I already have in place I'm following this tutorial which uses the same stack as this app (heroku, node...).