@yaprakaya
Yaprak Ayazoglu
Frontend developer
@yaprakaya
@yaprakaya
@yaprakaya
A bit of history...
@yaprakaya
@yaprakaya
@yaprakaya
@yaprakaya
@yaprakaya
@yaprakaya
@yaprakaya
@yaprakaya
@yaprakaya
@yaprakaya
// define with module ID, dep. array and factory function
define('myModule', ['dep1', 'dep2'],
function (dep1, dep2) {
//Define the module value by returning a value.
return function () {};
});
@yaprakaya
// ***** lib.js *****
module.exports = function(n) { console.log(n); }
// ***** main.js *****
var myLib = require('./lib');
console.log(myLib(5)); // 5
@yaprakaya
// ***** lib1.js *****
export default function() {
console.log(4);
};
// ***** someClass.js *****
export default class {
…
};
// ***** main.js *****
var myLib = require('./lib');
console.log(myLib(5)); // 5
// ***** main.js *****
import func from ‘./lib1’;
func();
import someClass = require(‘./someClass’);
let myClass = someClass();
@yaprakaya
<script type="module">
import {addTextToBody} from './utils.mjs';
addTextToBody('Modules are cool. <3');
</script>
// utils.mjs
export function addTextToBody(text) {
const div = document.createElement('div');
div.textContent = text;
document.body.appendChild(div);
}
@yaprakaya
@yaprakaya
@yaprakaya
@yaprakaya
1000 files to 50 increases speed by an average of ~66%
@yaprakaya
1000 files to 50 increases speed by an average of ~28%
@yaprakaya
1000 files to 50 increases speed by an average of ~27%
@yaprakaya
@yaprakaya
@yaprakaya