-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Code Splitting #7
Comments
Code splitting is indeed most missing major feature and I plan to add it with next big update. |
Isn't |
var c = require("c"); // really big library, which is only needed in this rar case Maybe this is the problem, you should not include a big library if you don't really need it. I'm fine with having a little more startup time and then a more fluent interface. I would like to have an option in the opposite direction, so that module code can be preexecuted to be ready when it is required, but that's probably not worth the effort. This does not mean that I don't like the idea of sending code later to the client, I see usecases for that. But it's not to reduce startup time. It would be nice to be able to rollout new features without a whole app refresh. |
@medikoo @Phoscur yes Consider a big webapp with several features. The features are in subpages, but because you do not want a whole page reload you have all features in one codebase. This feature is optional because you don't need to use |
Why wouldn't you want all features in one codebase? Creating some shims for node specific functions like process.nextTick is not a bad idea, we can probably steal those from somewhere else anyways. |
@sokra I would definitely not mess with |
I reimplemented webmake from scratch to reduces some limitations of it and add code splitting. It do need some additional love but the most things are working really good. See https://github.com/sokra/modules-webpack for some docs Here is a list of differences to the original webmake: Module and file names are replaced with a unique id per file It is allowed to require outside to current package scope Browser replacements Code splitting with |
@sokra thanks for input. Your approach is very interesting, but you introduced big limitation with that. You didn't take into account specific cases when modules are not required directly. In projects I currently work with this is the way templates are loaded, indirectly by template engine, I wouldn't be able to use your solution there. Other goal, when working on webmake, was not to change source code of modules, it's not that major concern as one above, but still it's certainly better for development and debugging to keep module names and paths intact. If you decide to continue development of your fork please change it's name, as you pointed it's very different solution. Thanks! |
@medikoo thanks for your feedback The limitation, you pointed out, is a problem, but i think a "back door" can be added with some config options. Do you have a example of a use case? Can you post it? The changes in the source code are really small so i don't think that this is a big problem. The point of posting it here is a aspect of code splitting which may can used in your webmake (also without the other changes). It's the same approach as in the inital post, but with I'll rename it if you want so. It was orginally intended as proof of concept for this issue. |
@sokra I'm not sure if any back door is available in your solution. Code can only be scanned statically, but all requires should work programmatically, so e.g. you should provide some sort of back door, so following could work: var indirect = require;
indirect(pathGeneratedByFn()); When you do all paths resolution on server side, and for client you don't provide any mechanism to do real path resolution then it's no place for back door. For example here https://github.com/medikoo/domjs/blob/master/lib/domjs.js#L92 I call require indirectly. |
Hmm... this really does not seem to work. This stays a limitation. What do think about the code splitting? |
To have code splitting, in first place we need to add possibility of creating different bundles that share same modules, form that point you can upload such bundles on demand in many different ways. By example, code of additional bundle that we may need to load, will probably look like: require.push({
// extra modules
})
("invoke/one/of/the/added/modules"); // optional Where I'm still not sure do any load on demand functionality should be included in |
I've moved it to https://github.com/webpack/webpack Hope that is ok... |
That's ok, thanks |
A few moths ago, I worked much on webpack and it's working really good. Here is a example web app: http://webpack.github.com/example-app/ |
I don't need this issue anymore. Should I close it or do you want it to stay open? |
I plan to add this feature, with Webmake v0.4, so I'll keep it open until it's done. |
@medikoo Over 3 years later... is there anything done here? |
@JHGitty nothing yet, but you may expect something 1st quarter next year. |
So that's how it all started! |
Like seriously! this is how Webpack was born 😄 @sokra |
wow! |
Genesis 😃 |
火钳刘明 |
Happy to see the history in a thread. |
hello webpack |
GWT has a cool feature named Code Splitting which loads parts of the code on demand. This is also appliable for webmake.
Here my idea:
webmake core would provide the magic
process.nextTick
function to the compiled code.process.nextTick
do this in the compiled code:Here is a quick hint on the compiled files:
This feature may makes the compile process a big complexer.
It may be useful for:
The text was updated successfully, but these errors were encountered: