Comments (10)
@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.
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.
@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.
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.
https://github.com/substack/wreq
from modules-webmake.
@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.
@medikoo one second is really fast, so it's not even worth optimizing it...
from modules-webmake.
@sokra it's still noticeable, I would like to have it instant :)
from modules-webmake.
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.
Nice! If in a meantime anyone asks for this feature I'll send him link to this post :)
from modules-webmake.
Related Issues (20)
- Text and HTML extensions? HOT 4
- Lazy-loading modules? HOT 1
- Bower package? HOT 5
- Support input from stdin HOT 2
- Parse error for scripts with a shebang HOT 3
- cant find module although module is their HOT 1
- Local modules and stdin causes webmake to hang HOT 2
- Requires local installation HOT 1
- Ability to validate or transform each included file HOT 3
- Errors in extensions are not returned to webmake HOT 3
- Extension for EJS HOT 2
- Can't set global export name programmatically ('name' option) HOT 2
- Extensions don't work for js files HOT 7
- Wrong transformation for empty module for special case HOT 1
- Cannot bundle module 'promise' HOT 3
- Nonexistence of node_modules makes wrong paths HOT 3
- It is possible to perform tree shaking for bundled module? HOT 1
- deprecated library during installing HOT 2
- Comparison ... may cause unexpected type coercion HOT 4
- How to use the fs node module with this? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from modules-webmake.