An universal Asynchronous Module Definition (AMD) Loader developed primarily to load VSCode's sources.
OTHER License
An universal Asynchronous Module Definition (AMD) Loader developed primarily to load VSCode's sources.
require
.<script type="text/javascript" src="loader.js"></script>
<script>
require.config({
// ...
});
require(['an/amd/module'], function(value) {
// code is loaded here
});
</script>
var loader = require('loader');
loader.config({
// ...
});
loader(['an/amd/module'], function(value) {
// code is loaded here
});
baseUrl
- The prefix that will be aplied to all modules when they are resolved to a locationpaths
- Redirect rules for modules. The redirect rules will affect the module ids themselvesconfig
- Per-module configurationcatchError
- Catch errors when invoking the module factoriesrecordStats
- Record statisticsurlArgs
- The suffix that will be aplied to all modules when they are resolved to a locationonError
- Callback that will be called when errors are encounteredignoreDuplicateModules
- The loader will issue warnings when duplicate modules are encountered. This list will inhibit those warnings if duplicate modules are expected.isBuild
- Flag to indicate if current execution is as part of a build.cspNonce
- Allows setting a Content Security Policy nonce value on script tags created by the loader.nodeRequire
- The main entry point node's requirenodeInstrumenter
- An optional transformation applied to the source before it is loaded in node's vmrequire.config({
recordStats: true
});
// ...
console.log(require.getRecorder().getEvents());
var loader = require('loader');
loader.config({
isBuild: true
});
// ...
console.log(loader.getBuildInfo());
To run the tests:
npm run test
npm run simpleserver
http://localhost:9999/tests/run-tests.htm
The project uses as a submodule the AMD compliance tests. The goal is to support as many tests without adding eval()
or an equivalent. It is also not a goal to support loading CommonJS code:
git submodule init
git submodule update
npm install
npm run watch1
and npm run watch2
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.