lrsjng / modulejs Goto Github PK
View Code? Open in Web Editor NEWLightweight JavaScript module system.
Home Page: https://larsjung.de/modulejs/
Lightweight JavaScript module system.
Home Page: https://larsjung.de/modulejs/
Hi,
Could you, provide the changelog of the last versions. I'm asking it because, just looking at commits sometimes is hard to get know about the news, bugfixes and maybe break changes.
Thank you and great work! (:
In bower.io search the package is not listed
can you make a typescript definition file?
Babel remapping ES6 "this" to undefined.
// ...
(function (root, factory) {
// istanbul ignore else
if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object') {
module.exports = factory();
} else {
root.modulejs = factory(); // throw: Uncaught TypeError: Cannot set property 'modulejs' of undefined
}
})(undefined, function () { // <-------------------------
// eslint-disable-line no-invalid-this
var OBJ_PROTO = Object.prototype;
// ...
In order to be used in production, this library should declare it's browser support.
I see that dist uses Array.isArray
which means no browser older than:
is supported.
Is there anyway to destroy a defined module in modulejs.state()?
Hi Lars!
Thanks for modulejs! I am a happy user.
Recently though, I have come accross a problem in my test environment. I have a module, which is a "shared state" between other modules.
(Ugly, I know... It is my implementation of something like "event bus" and so far I did not come with a good idea how to publish events on bus and listen to them without sharing the bus object)
Well, it turns out I would like to inject a mock of the bus so that I have more control over what is happening, most specifically I want to make a bus, which is normally asynchronous, synchronous.
I know I can provide a different implementation of the dependency in third argument of .require method, but that does only override it in the module under the test. If that module happens to use another module, which in turns uses the module I want to override, it won't be overriden and I end up with two different instances of what should be one.
Maybe it is better to describe it using a little diagram:
A --> B (module A depends on B)
A --> C
B --> C
If I now use
modulejs.require('A', {
'C' : D
});
I will end up with:
A(B,D)
B(C)
while I want
A(B,D)
B(D)
I could of course require also module B this way:
modulejs.require ('B', {
'C' : D
});
But that makes it overly complicated as I am exposing dependencies of dependencies of the module under the test. That seems to be very fragile.
So, I was wondering whether you though of any way, how to (temporarily) be able to override a module definition that would spread across ALL modules?
Or, is there a better way to overcome that?
It would be nice if moduleJS would offer a "modulejs.run" method which will run a code when all required libraries are available, ie:
modulejs.run(['jquery', 'graphics/fx'], function() {
// run this after loading of jquery and graphics/fx
})
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.