Simple CommonJS require()
definition.
Include on top of your file and register modules with require.register(name, fn)
require(name)
— loads registered module and returns itsexports
.require.register(name, fn)
— registers new module.fn
callback receivesexports, require, module
.require.list()
— lists all registered modules.
<script src="require.js"></script>
<script>
require.register("module", (exports, require, module) => {
// Expose `count` externally.
exports.count = 42;
});
console.log(require("module").count);
</script>
The MIT License (MIT)
Copyright (c) 2020 Paul Miller https://paulmillr.com/