curl-amd
Version:
curl.js is small, fast, extensible module loader that handles AMD, CommonJS Modules/1.1, CSS, HTML/text, and legacy scripts.
54 lines (43 loc) • 982 B
HTML
<html>
<head>
<title>Packages as object test</title>
<script>
curl = {
paths: {
curl: '../src/curl'
},
packages: {
'commonjs-test': {
path: 'support/commonjs',
main: 'main'
}
}
};
</script>
<script src="../src/curl.js" type="text/javascript"></script>
<script type="text/javascript">
curl(
[
// test modules:
'commonjs-test/exports',
'commonjs-test'
]
).then(
function (exports, main) {
(exports.testMessage == 'it works' ? success : failure)('package.path should redirect to correct path');
(main.id == 'commonjs-test/main' ? success : failure)('package.main should redirect to correct path');
}
);
function write (msg) {
curl(['domReady!'], function () {
document.body.appendChild(document.createElement('div')).innerHTML = msg;
})
}
function failure (msg, expected) { write('FAILED: ' + msg); }
function success (msg) { write('SUCCESS: ' + msg); }
</script>
</head>
<body>
</body>
</html>