commonjs-require

WebJar for commonjs-require

Лицензия

Лицензия

MIT
Категории

Категории

JavaScript Языки программирования
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

commonjs-require
Последняя версия

Последняя версия

1.4.6
Дата

Дата

Тип

Тип

jar
Описание

Описание

commonjs-require
WebJar for commonjs-require
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/efacilitation/commonjs-require

Скачать commonjs-require

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/commonjs-require/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>commonjs-require</artifactId>
    <version>1.4.6</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/commonjs-require/
implementation 'org.webjars.npm:commonjs-require:1.4.6'
// https://jarcasting.com/artifacts/org.webjars.npm/commonjs-require/
implementation ("org.webjars.npm:commonjs-require:1.4.6")
'org.webjars.npm:commonjs-require:jar:1.4.6'
<dependency org="org.webjars.npm" name="commonjs-require" rev="1.4.6">
  <artifact name="commonjs-require" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='commonjs-require', version='1.4.6')
)
libraryDependencies += "org.webjars.npm" % "commonjs-require" % "1.4.6"
[org.webjars.npm/commonjs-require "1.4.6"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

CommonJS Require

browser-side CommonJS require() function.

Usage

Add commonjs-require.js as script src to your site.

Example

<script src="commonjs-require.js"></script>
<script>
require.register("module", function(exports, require, module){
  /* Some Module content */
  module.exports = "content"
})
alert(require('module'))
</script>

This will alert content

Automated wrapping into require.register

Why not browserify?

Browserify requires (scnr) that you use some magic AST/require.resolve mechanism to built your CommonJS package/files for the browser. This is really complex - especially if you have to bundle different files for different sections of your website, use dynamic requires or have circular dependencies.

API

  • require(name) — loads registered module and returns its exports.
  • require.register(name, fn) — registers new module. fn should have signature exports, require, module.
  • require.list() — lists all registered modules.

Node Module support

commonjs-require emulates the actual loading mechanism from Node.js in that it delegates all require() calls to Module._load() (Module is exposed via the "module" module). This improves support for modules which rely on the Node module system implementation (for example Mockery).

Module API

  • Module._load(request, parent) - does the actual module loading and instantiation
  • Module._cache - is the cache of loaded modules, can be cleared by assigning an empty object
  • Module._resolveFilename - determines the actual module id (e.g. adds "index" if its missing)

License

MIT

org.webjars.npm

efa GmbH

Electronic Facilitation

Версии библиотеки

Версия
1.4.6