Giter VIP home page Giter VIP logo

Comments (10)

medikoo avatar medikoo commented on June 7, 2024

@sokra CommonJS modules are by specification loaded synchronously so you can't load them on demand on client-side without freezing interface.

What is exactly the overhead you're mentioning? A need for rerunning script after every change, or compilation time?
First issue you may resolve by binding webmake directly to the server (if it's Node.js server) - I work that way, or you may write short script so webmake is runs after each file change (by watching changes on file)

By end of march big update will land which will have that features built into webmake, additionally webmake will have option to work in background so once read, modules will be cached and compilation would be automatic and instant.

I will close it now, as I think loading files remotely on client side is not an option. However let me know have you figured out convient way to work with webmake without overhead.

from modules-webmake.

sokra avatar sokra commented on June 7, 2024

here is a proof of concept...
https://github.com/sokra/module-webmake-dev

the files are requested with sync ajax so it freezes the browser, but it is only for developing so i think this is acceptable.
if you have the server on the same machine the requests should be really fast.

from modules-webmake.

medikoo avatar medikoo commented on June 7, 2024

@sokra even if we accept freezing on client-side, there are two big issues with that approach:

  • Try to load 100 modules that way (I currently work with application that is build from over 200 modules). Page load would be really slow. I really prefer to have it built into one file on server-side and develop on fast and responsive website.
  • It will only work reliably for same package modules and also with limits (you can't import module outside of your public folder). Have you tried to resolve cross package dependencies that way? webmake resembles same resolution as node.js does. Resolution involves searching various paths before we coin right one and again other packages may be and are likely to be outside of public folder.

I think it's not worth to go that way, it raises more issues that it helps, and compilation on server-side can be configured so it's no overhead at all - this is on which we should focus.

from modules-webmake.

sokra avatar sokra commented on June 7, 2024

ok ok... it was just a idea ;)

Just a question: how long does it take to compile your 200 modules for development?
I want to start a node.js project soon which may shares some stuff with the client js.

a --watch mode would be nice :)
(it may caches deps from unchanges files)

from modules-webmake.

sokra avatar sokra commented on June 7, 2024

https://github.com/substack/wreq

from modules-webmake.

medikoo avatar medikoo commented on June 7, 2024

@sokra it's about 1 second (on 2yo macbook pro), it's not that bad, but 'watch' mode would still be very helpful.

It looks that wreq is what you were asking for, with that difference that it uses asynchronous requests :) Still though it has same limitations, can be used only for plain and simple cases. It's fine as separate project but building such feature into webmake doesn't make much sense :)

from modules-webmake.

sokra avatar sokra commented on June 7, 2024

@medikoo one second is really fast, so it's not even worth optimizing it...

from modules-webmake.

medikoo avatar medikoo commented on June 7, 2024

@sokra it's still noticeable, I would like to have it instant :)

from modules-webmake.

sokra avatar sokra commented on June 7, 2024

I wrote a simple grunt custom task for webmake. grunt has a watch mode so you can use it :)

task.registerBasicTask('webmake', 'Webmake js files.', function( data, name ) {
    var done = this.async();
    log.writeln("Webmake " + data + "...");
    require("webmake")(data, function(err, source) {
        if(err) {
            log.error(err);
            done(false);
        } else {
            file.write(name, source);
            log.writeln("File " + data + " created.");
            done();
        }
        log.writeln();
    });
});

config like:

webmake: {
    "output.js": "/path/to/program-module.js"
}

from modules-webmake.

medikoo avatar medikoo commented on June 7, 2024

Nice! If in a meantime anyone asks for this feature I'll send him link to this post :)

from modules-webmake.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.