-
Notifications
You must be signed in to change notification settings - Fork 20
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
Provide hooks to allow customizing ESBuild config #231
Provide hooks to allow customizing ESBuild config #231
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA. If applicable, I have secured permission from my employer. |
recheck |
@crgwbr : nice! I'll check in a bit, was just working on the project today. |
@crgwbr : this is something I've wanted for a while. At the risk of over engineering it, here are some thoughts: 1. Hooks location / single fileIs it better to have a single 2. Other customizationsFor example, one hook I need imminently, is the ability to customize the Right now, if you wanted to add a server-side rendered Redux store, it's impossible. As the providers are fixed. 3. Discouraging mutationWe already require immer, so should we just pipe the config through immer at this point? 4. Remove the ts-node dependencyI used ts-node for ages, but one of the core reasons I built reactivated was to get rid of the dependency. But like you, I am fanatical about every single file being in typescript and type checked. Since we already use esbuild, it should be trivial for python to detect if this file exists and include it. Bit of a chicken-egg problem but I think it can be thought out. 5. Remove warningSince the defaults should "just work", I don't think a warning is warranted unless something goes wrong in the inclusion. Sample fileSo ultimately, maybe something like this (the // reactivated.conf.tsx
import React from "react";
import {config} from "@reactivated";
export const {rendererBuildConfig, clientBuildConfig, renderPage} = config({
clientBuildConfig: (options) => {
return options;
},
rendererBuildConfig: (options) => {
return options;
},
renderPage: (contents) => {
return <CustomProvider>{contents}</CustomProvider>;
},
}); Let me know what you think. It's a lot, so I'm happy to help POC some of this. |
0b7419e
to
8ff3986
Compare
@silviogutierrez Thanks for the review! I've pushed up some updates that address your notes. |
@crgwbr : whoa this solves the chicken/egg problem in a way I hadn't thought of. Actually just putting it in the package! Brilliant. I'll play around with this and comment soon. We're coupling to npm hard on this (vs pnpm and yarn), but I'm fine with that. |
@crgwbr : there's some mypy issues and integration issues when building the full package, so I'll have to take a look. However, I've published snapshot When I have some time I'll carefully review what's failing. mypy is easy to fix, but the integration (project that actually consumes this without the config override) will need a closer look. Thanks again! |
Hey @silviogutierrez, just following up on this. Is there anything I can do to help get this ready for merge? |
7c00377
to
f7ed4a6
Compare
@silviogutierrez I rebased this against main and fixed the merge conflicts. Please let me know what I can do to help get this merged. |
@crgwbr : I'm going to revisit this and let you know. I'm running into the need to modify the |
Working on this now, but in the meantime, check out the patch approach that I've used successfully (and others too): |
@crgwbr : I have a branch that should do the trick. Check out PR #312. You can test it with Create a file in import {Options} from "reactivated/dist/conf";
export default {
build: {
client: (options) => {},
renderer: (options) => {},
},
render: async (content) => {
return content;
},
} satisfies Options; options is a writable draft that you can modify as you see fit. And run Let me know if you run into any issues! |
Thanks, @silviogutierrez! I'm attempting to upgrade a project to test this change, however the Considering I've been using reactivated 0.28 with requests 2.31.0 and haven't seen any issues, I think it should be safe to unpin this version now. Though, you may need to add a new constraint for |
@crgwbr : happy to mess around with the pinning. Can you open a separate PR with these changes and I'll just go ahead and merge them? Not super familiar with the pinning syntax. |
Fantastic. Merged. Closing this PR in favor of the other. |
This change provides hooks to allow users of the library to customize the projects ESBuild configuration.
For example, assume that a reactivated-based site wanted to use CSS modules. Even though reactivated itself doesn't support this, once this is merged, a site could add config tweak files like this, correlating to packages/reactivated/src/build.client.tsx and packages/reactivated/src/build.renderer.tsx, respectively.