commonjs-require-definition
v0.6.3
Published
Simple common.js `require()` definition.
Downloads
22,256
Maintainers
Readme
CommonJS require definition
Simple CommonJS require()
definition.
Usage
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>
License
The MIT License (MIT)
Copyright (c) 2020 Paul Miller https://paulmillr.com/