-
Notifications
You must be signed in to change notification settings - Fork 287
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
Simplify customization #454
Conversation
Since babel-node isn't used in production, this will avoid prod-only errors (plus faster)
Primary benefit here is that the .yarnrc file no longer causes issues with installing out of Docker
Updates snapshots so that style changes will also be caught in the diffs
And better organize and document app config
Dual layer would mean that unused core components would still get bundled. Better to have a single file and expect conflicts in it.
We already have isomorphic fetch
@@ -1,22 +1,19 @@ | |||
NODE_ENV=development | |||
INTERNAL_GRAPHQL_URL=http://reaction.api.reaction.localhost:3000/graphql-alpha | |||
CANONICAL_URL=http://localhost:4000 |
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.
Updated CANONICAL_URL
and removed the unused KEYCLOAK_*
ones. The rest is just alphabetized but unchanged.
@@ -8,7 +8,8 @@ require("isomorphic-fetch"); | |||
const url = "http://localhost:4000"; | |||
|
|||
describe("NextJS Loading", () => { | |||
it("SSR Loads with an HTML Body", () => fetch(url) | |||
// Skipping this test because it works locally but not on CI. Created issue to solve this soon. |
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.
Created issue: #456
@samkelleher If you have a few minutes, I'd like your feedback on whether these changes help to resolve some of your pain points. There will be additional PRs coming for better separation of pages/data/routing from page presentation and better isolation of all things Stripe for removal. As you mentioned elsewhere, it's not possible to fully separate customized code from code that likely won't be customized, but the aim of this PR is to at least be a little smarter about that separation to avoid conflicts and confusion when possible. |
I like the improvements @aldeed, did you use my fork for reference as have made many of the same changes. That said I evolved the babel-node usage rather than remove it so we can write the same node features (namely ES6 modules) in all files (so webpack, server, and browser scripts). But overall a great good housekeeping and consolidation PR. |
Note for anyone looking at this: I did need to prune my docker volumes ( |
@samkelleher Yes, I reviewed and borrowed some of your changes from the fork. Thanks! We decided to veer from your approach on You may be aware, but you could also enable module support in pure |
I updated the description with better instructions on which specific volumes to remove. |
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.
Everything worked correctly in dev
and production
mode.
Started without env
variables, and the variables were added and things ran smoothly.
This is true in general, but in practice there are things you can do to work around it. Such as including a loader like in their example in the node docs: NODE_OPTIONS='--experimental-modules --loader ./custom-loader.mjs' node x.js (I bring this up in case it's something we or others wish to do at some point). |
I did actually try the In my technical experimentation however, it did not like destructured imports, which are used extensively |
Resolves #438
Resolves #409
Impact: breaking
Type: feature
Various changes based on audits and feedback about difficulties running, building, and customizing.
Changes
.yarnrc
to.reaction/yarnrc-docker.template
and updated the Dockerfile to copy it in. This matches how it's done in component-library and fixes the fact that the yarn config prevents yarn from working outside of Docker./config
to/src/custom
next.config.js
into/src
.node
rather thanbabel-node
.babel-node
was unnecessary and slower.@reactioncommerce/components-context
jest-styled-components
for tests. This updated all of the snapshots so that styles are also snapshotted.setupTests.js
from/src
to/tests/
envalid
and update everything that usesprocess.env
so that is uses config that is run through envalid for validation and transformation first.reactionTheme.js
andcomponentTheme.js
to/src/custom
/src/lib/theme/components.js
to/src/custom/componentsContext.js
defineRoutes
function in/src/custom/routes.js
logger
object a bitappConfig
from MobXUIStore
pagination
functions fromhelpers
toutils
and get rid ofhelpers
folderserverRuntimeConfig
andpublicRuntimeConfig
_error
pageserver.js
to a newserverAuth.js
PORT
env variable, which defaults to 4000 if not set, rather than being hard-coded to 4000.request
NPM package and usefetch
instead in the two places whererequest
was used. This removes a large dependency that was unnecessary sincefetch
is already available.Breaking changes
Because some of the build steps and file locations, and the way env variables are handled, have changed, this may break custom scripts or tools. In general the defaults here should be much simpler now.
After pulling this in for local development, remove all volumes that begin with
reaction-next-starterkit
(docker volume rm reaction-next-starterkit_empty_node_modules reaction-next-starterkit_node_modules reaction-next-starterkit_web-yarn
) and rebuild the image the first time you run the project (docker-compose up -d --build
). Also verify that your.env
file has all of the necessary variables based on.env.example
If you have server code that was relying on the fact that
babel-node
was transpiling it, you'll need to update it to syntax that is compatible with Node 10.Testing
docker-compose up -d --build
)