Dnn.React.Common Bundle Size is Very Large #4013
-
I was doing some research on building persona bar modules using the I am curious if anyone has looked into updating the webpack configuration to group the different components into separate files, or even npm packages. This would allow developers to utilize only what they need. Currently I have a react app that looks like this import * as React from 'react';
import { PersonaBarPage, PersonaBarPageHeader, Button } from "@dnnsoftware/dnn-react-common";
import './App.css';
class App extends React.Component {
render() {
return (
<div className="andrewhoefling-react-app">
<PersonaBarPage isOpen={true}>
<PersonaBarPageHeader title="Hello World - React App">
<Button type="primary" size="large" title="Yes">
My Custom Button
</Button>
</PersonaBarPageHeader>
<div>
This is where the general body content will go
</div>
</PersonaBarPage>
</div>
);
}
}
export default App; Note the 1 import line for everything Dnn React import { PersonaBarPage, PersonaBarPageHeader, Button } from "@dnnsoftware/dnn-react-common"; I think it would be very useful if we could group this into 2 unique import statements import { PersonaBarPage, PersonaBarPageHeader } from "@dnnsoftware/dnn-react-common/personabar";
import Button from "@dnnsoftware/dnn-react-common/button"; This would remove all other dependencies and only pull in the minimum required. An added bonus of this is any module that uses the Question
|
Beta Was this translation helpful? Give feedback.
Replies: 11 comments 3 replies
-
FWIW recent discussions are that really React.Common should not be used outside of the actual PersonaBar/Internal to DNN Platform. @david-poindexter or @valadas Correct me if I misstated that |
Beta Was this translation helpful? Give feedback.
-
@ahoefling I understand exactly what you are saying. Let me give this a bit of thought. I would also like for @valadas and @mtrutledge to chime in on this as well. I am just not sure if it is important enough to have to rewrite the build process to split these apart for a handful of custom PB extensions. Also, all existing PB extensions use the bundle, so everything would have to be re-written just to support this splitting. Plus, I am not sure if the performance gain will be enough since they are already all being used by the collection of PB extensions. See where I am coming from? |
Beta Was this translation helpful? Give feedback.
-
When we first started converting this splitting the bundles caused all sorts of issues to crop up. So we reverted back and just bundled it all into one. Over time the build process has changed a bit and no longer uses the React Common libraries from NPM. It was determined that only the Persona Bar should use the React Components. There are still some Persona Bar Extensions out there, but they are few. I don't believe the performance gain of splitting the files, in this case, is worth the effort, since the download only occurs when using the Persona Bar. Also, this download should only occur once, and the browser should then be able to fetch the cached version. |
Beta Was this translation helpful? Give feedback.
-
Yeah, in my opinion we should not recommend using it by 3rd parties. For one it is not great, for 2 we may have to do breaking changes in it very often and it would be a maintenance hell because the actual version loaded may not be the one that you reference. |
Beta Was this translation helpful? Give feedback.
-
@ALL: Having worked on (and with) this here are my thoughts. The bundle was made back in the day to centralize stuff for the PersonaBar. In the process they also made the React Common library available as an npm package so as to help 3rd party development. As we found out this wasn't without a few serious catches. For starters it was near impossible to develop the entire chain locally without going through some serious hacking to have the RC stuff compile and load for the various extensions. Secondly we discovered "hidden" integrations with other PB code (WebAPI endpoints, services framework, etc). It could have been much easier to spot this had the code been written in Typescript, but unfortunately it's not and so we are sometimes chasing rabbits throughout this maze of code. This means it is difficult to properly use outside of a PB extension (e.g. in a regular module). Finally we realized the headache of maintaining different projects with version numbers (npm vs our own Github releases). So we did two things:
DNN has always had to make hard decisions about what to provide to developers and what to leave to them. The more we provide the easier it is to develop for DNN, but the more work we have maintaining code. If we ever offer components to developers, we should have those in a technology that is more future proof (minimally type safe I'd say), which is what some are working on. The export bundle is there for the entirety of the PB. IMO we should leave it as it is and not aim to have each PB extension have its own version of various controls. Instead, if you're developing a PB extension and you use some of the RC components, you should keep an eye on that project. But for all other development scenarios it should IMHO not be encouraged to be used. |
Beta Was this translation helpful? Give feedback.
-
Thank you everyone for the insightful responses, there is a lot to consider in what I proposed here. If I am understanding the consensus from here is the
I've tried building a PersonaBar module without this library and I find the UX/UI is very disconnected from the rest of the Persona Bar modules. It is very easy to spot when a PersonaBar module was built using the
I took a look at the I don't have a solution on this, but it may be useful for us to try and document some recommended techniques for building Persona Bar Modules. Publishing a simple list of what is okay for a persona bar module
|
Beta Was this translation helpful? Give feedback.
-
So I am working on a new set of Dnn WebComponents, common stuff like buttons, inputs, search-box, tabs, and so on... The goals with this work are:
If this peaks your curiousity ping me up for a demo or take a look at https://github.com/eraware/dnn-elements where I am developing them until we get to 10 |
Beta Was this translation helpful? Give feedback.
-
This is really great and a wonderful effort to use stencil for native web components ❤ What can developers use today? What can be done to provide the right guidance? Should the npm package be deprecated and marked with a notice that it shouldn't be used? Should we no longer update it? I don't think we should ever take it down as developers are using it right now. The fact is regardless what is decided in this discussion or in one of the slack groups people will still use the npm package for persona bar modules |
Beta Was this translation helpful? Give feedback.
-
Yeah, I think it would be a good thing to indicate that we don't recommend using it as we cannot respect our deprecation policy on it and it should be considered an internal Dnn package. I do have 2 modules using it and the client can't upgrade Dnn because of them. Adjusting those modules to the new package would require publishing new npm packages and then a lot of undocumented work to adjust them. I won't go that path and will just remove the dependency on it at some point.
Well a lot of bad things can be said about the Persona Bar, but one good thing it that it is really neutral on development. You just need html/css/javascript and then it is up to the developer. So Angular, React, Stencil, Typescript, plain old Javascript, you name it. Some of the modules in there just use html and knockout. Now for consistent look, well in 10 we will have those Webcomponents, I also plan to wrap some of those into the common bundle and the old UX/UI pattern so even old modules could benefit from that consistent look. |
Beta Was this translation helpful? Give feedback.
-
I'm looking to change the way the PersonalBar looks (just change the way it looks - I don't like it always shows, I just want it to show a very small one and only show full on mouseover). |
Beta Was this translation helpful? Give feedback.
-
It is not a simple task, but if any effort is made to have it not always show (kinda docked), then it's important that the way to undock it is not only by hover. I played a bit on trying to make it a drawer but ran out of time to make it usable and kinda had to switch gears into more important issues. |
Beta Was this translation helpful? Give feedback.
So I am working on a new set of Dnn WebComponents, common stuff like buttons, inputs, search-box, tabs, and so on... The goals with this work are:
2 they will be super simple to use, something like