Skip to content

Instantly share code, notes, and snippets.

Gábor Soós blacksonic

Block or report user

Report or block blacksonic

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@blacksonic
blacksonic / dynamic.mjs
Created Jun 15, 2019
The complete ES module upgrade guide - part 8
View dynamic.mjs
// index.js
function main() {
import('./module')
.then(({ sum }) => {
console.log(sum(1, 2));
});
}
main();
// module.js
@blacksonic
blacksonic / dynamic.cjs
Created Jun 15, 2019
The complete ES module upgrade guide - part 7
View dynamic.cjs
// index.js
function main() {
const { sum } = require('./module');
console.log(sum(1, 2));
}
main();
// module.js
module.exports.sum = (a, b) => a + b;
@blacksonic
blacksonic / binding.mjs
Created Jun 15, 2019
The complete ES module upgrade guide - part 6
View binding.mjs
// index.js
import { counter, increment } from './module';
console.log(counter);
increment();
console.log(counter);
// module.js
export let counter = 0;
export const increment = () => {
@blacksonic
blacksonic / binding.cjs
Created Jun 15, 2019
The complete ES module upgrade guide - part 5
View binding.cjs
// index.js
const { counter, increment } = require('./module');
console.log(counter);
increment();
console.log(counter);
// module.js
module.exports.counter = 0;
module.exports.increment = () => {
@blacksonic
blacksonic / execution-order.mjs
Created Jun 15, 2019
The complete ES module upgrade guide - part 4
View execution-order.mjs
// index.js
console.log('loading module');
import './module.js';
console.log('module loaded');
// module.js
console.log('hello from module');
// hello from module
// loading module
@blacksonic
blacksonic / execution-order.cjs
Created Jun 15, 2019
The complete ES module upgrade guide - part 3
View execution-order.cjs
// index.js
console.log('loading module');
require('./module.js');
console.log('module loaded');
// module.js
console.log('hello from module');
// loading module
// hello from module
@blacksonic
blacksonic / named-exports.mjs
Last active Jun 13, 2019
The complete ES module upgrade guide - part 2
View named-exports.mjs
// NAMED EXPORT
// index.mjs
import { sum } from './module';
console.log(sum(1, 2));
// module.mjs
export const sum = (a, b) => a + b;
// DEFAULT EXPORT
@blacksonic
blacksonic / named-exports.cjs
Last active Jun 13, 2019
The complete ES module upgrade guide - part 1
View named-exports.cjs
// NAMED EXPORT
// index.js
const { sum } = require('./module');
console.log(sum(1, 2));
// module.js
module.exports.sum = (a, b) => a + b;
// DEFAULT EXPORT
@blacksonic
blacksonic / package.json
Created Apr 3, 2018
All the new things: setting up Webpack 4 with Babel 7 - part 6
View package.json
{
"scripts": {
"start": "webpack-dev-server --mode=development",
"test": "karma start --single-run",
"build": "webpack --mode=production"
}
}
@blacksonic
blacksonic / karma.conf.js
Last active Apr 3, 2018
All the new things: setting up Webpack 4 with Babel 7 - part 5
View karma.conf.js
module.exports = (config) => {
config.set({
frameworks: ['jasmine'],
files: [
{ pattern: 'src/test.js' }
],
preprocessors: {
'src/test.js': ['webpack']
You can’t perform that action at this time.