-
Notifications
You must be signed in to change notification settings - Fork 293
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
Support route chunking #128
Comments
Hey, @declanelcocks I've already tried to do that, but I couldn't get it working mostly because of the way we are importing components ( I would love to see your solution though. Even if we decide to not add that to the boilerplate, it'll be very helpful for other people as a reference. About PRs, don't worry, I just ask to target the base branch of the feature you want to add (in this case, master). |
@diegohaz Ah yeah, that was the big road block I ran into as well. Everything was working, but it was still just creating 1 chunk because every component/container was being exported from the |
Particularly I don't have problems with it, the gain is enormous, but there's another issue: #113. We'll probably need an alternative for those who prefer to don't use I plan to add a |
Ah yeah, I took at the differences here that you linked in that issue. Those changes look good; it would be slightly more annoying to create your own components but if you used the Are you planning to merge in those changes any time soon or are you looking for an alternative I can make a PR for what I've done so far, but keeping the existing |
That would be fine for the tooling issue, but will not solve the problem with chunking since we would be still importing all components. Feel free to make the PR. Also, thank you for the feedback. |
Yeah, but I think the biggest pain point with the structure you posted is that you have to remember to add the export to that folder's index file. I only suggested something like plop because you can let plop take care of remember these things. |
I think we should look at the concept of the React Fractal Structure. Basically each chunk would have its own I think importing from w/in the chunk would go something like |
I believe the current structure was an intentional choice to avoid the
oft-frustrating decision-making required in maintaining that type of global
segregation. It is, perhaps, a more manageable structure over time, but I
personally like the fuzzy nature of dropping components into a giant
component heap and knowing where I can access them without paths.
Also, you can add subgroups to the folders (eg. Atom/login) and access it
as components/login/loginButton (this might require some new recursive
directory code in components index.js).
…On Tue, Mar 21, 2017, 9:50 AM Tom Jenkins ***@***.***> wrote:
I think we should look at the concept of the React Fractal Structure
<https://github.com/davezuko/react-redux-starter-kit/wiki/Fractal-Project-Structure>.
Basically each chunk would have its own components, containers, store,
etc. This way each chunk/route would be self contained. Any "global"
components would go in the root component.
I think importing from w/in the chunk would go something like import
MyComp fromroute//components`.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#128 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AKTSfxvCAW90Du28B5CGGJ56ACPhxQ8sks5rn9W0gaJpZM4MJnlG>
.
|
Oh I completely understand that @ajhool, its a big 👍 from me for that too. However the fractal structure above just makes a giant component heap for each chunk independently (theoretically - I haven't tried it) with a giant heap for the site wide components. The path comes into play only at the chunks (ie routes if using fractal structure) (I've noticed I'm using route & chunk interchangeably... under fractal structure, the route definition defines the chunk so the route is the chunk.) |
@zentuit Wouldn't you potentially end up with a longer initial load? Since the site wide chunk could end up including a lot of unnecessary components? In |
I do not understand everything but I think this guy found a solution he explain here: |
@rolele The problem I was referring to was not really the same as this. What I was trying to achieve was to be able to do |
Do you mean that to be able to perform code splitting we have to include the component using the path |
@rolele Yep exactly, if you use just 1 component and check your chunks you'll see that it includes every component |
https://github.com/ctrlplusb/react-async-component Really simple to implement in Arc |
Is there any solution to this issue? Should I give up route based code splitting in ARc? Using directory structures like routes/[route-name]/components/atom/Something.js will solve the issue, but it is too complex |
Yeah i'm about to switch all my code to using directory structures import x from ../../components/atoms/x |
Is it in your plans to support chunks for individual routes? For example, when you land on
/
, you only load what you need for/
.I took your repo and added this in for my own project so if you'd like me to help make a PR for this I'm happy to do that. I'm not 100% sure that my implementation is the best or most efficient as I tried to copy the implementation from other projects and my own research, so I would be happy for you to help review and improve it. And of course, I'm not as familiar as you are with the internals of this project, especially the server-side rendering.
In short, I changed all of the routes to use
getComponent
to allow webpack to create a chunk for each route, that's only loaded when you visit that route. I also had to change the way the client/server renders the app.Also, I'm not sure on how you like PRs to be structured for this repo, since you have several trees for each progressive feature.
The text was updated successfully, but these errors were encountered: