Skip to content

Instantly share code, notes, and snippets.

@Olegas
Forked from ipoddubny/amd.js
Created July 9, 2015 10:42
Show Gist options
  • Save Olegas/26d059a9b16514828b3a to your computer and use it in GitHub Desktop.
Save Olegas/26d059a9b16514828b3a to your computer and use it in GitHub Desktop.
define(['cjs'], function (cjs) {
console.log('amd module loaded');
console.log('cjs exported:', cjs);
return 'AMD';
});
define([], function () {
console.log('This module has been loaded asynchronously');
return 'ASYNC';
});
console.log('cjs module loaded');
module.exports = 'CJS';
var amd = require('amd');
console.log('this is main.js');
console.log('amd module exported:', amd);
setTimeout(function () {
// NOT A WEBPACK LOADER!
require(['myCustomRJSPlugin!async'], function (async) {
console.log('async module returned:', async);
});
}, 5000);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Webpack demo</title>
</head>
<body>
<h1>Webpack demo</h1>
<script src="bundle.js"></script>
</body>
</html>
module.exports = {
entry: 'main.js',
output: {
filename: 'bundle.js'
},
resolve: {
root: [
__dirname
],
extensions: ['', '.js']
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment