Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

brunch/commonjs-require-definition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 its exports.
  • require.register(name, fn) — registers new module. fn callback receives exports, 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/

About

Common.js require definition.

Resources

License

Stars

Watchers

Forks

Packages

No packages published