This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const { createMacro } = require("babel-plugin-macros"); | |
const objectToAST = require("babel-plugin-preval/src/object-to-ast"); // https://github.com/kentcdodds/babel-plugin-preval/blob/b6eeba02ee93d425cc673ffc23dc62375d0416e5/src/object-to-ast.js | |
export default fn => | |
createMacro(({ references, state, babel }) => { | |
references.default.forEach(referencePath => { | |
if (referencePath.parentPath.type === "CallExpression") { | |
const __filename = state.file.opts.filename; | |
const __dirname = path.dirname(__filename); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (process.env.LOG_ONLY) { | |
var chalk = require('chalk'); | |
var MOVE_LEFT = new Buffer('1b5b3130303044', 'hex').toString(); | |
var CLEAR_LINE = new Buffer('1b5b304b', 'hex').toString(); | |
var hiddenCount = 0; | |
Object.keys(console).forEach(methodName => { | |
var method = console[methodName]; | |
if (method != console.Console) { | |
console[methodName] = function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pend(getPromises, Child) { | |
return class extends Component { | |
constructor(props) { | |
super(props); | |
let promises = getPromises(props); | |
this.state = { pending: promises }; | |
Object.entries(promises).forEach(([name, promise]) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html | |
head | |
title -- My Site - ${input.title} | |
include(input.scripts) | |
if(!input.scripts) | |
script src='/jquery.js' | |
body | |
include(input.content) | |
include(input.foot) | |
if(!input.foot) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-----------compare renderToString---------- | |
rax: 3656.802ms | |
rax: 3642.747ms | |
rax: 3654.034ms | |
rax: 3678.500ms | |
rax: 3507.327ms | |
rax: 3563.097ms | |
rax: 3820.896ms | |
rax: 3482.334ms | |
rax: 3492.528ms |
Marko is a high performance UI library from eBay. Marko began life as a templating language, so let's begin there.
Most templating languages are pretty simplistic, they understand their own constructs, but don't understand the HTML structure itself. Marko is different. Marko fully understands the HTML language, in fact, the first version of Marko was built on top of an off-the-shelf HTML parser. We've since developed our own parser that extends the language by adding typed attributes, argument expressions and even a concise syntax. It's quite beautiful.
<h2>Hello ${data.name}!</h2>
Often you'll find that you need utility methods or other functionality that might make sense as an external module that you could :tada: open source 🎉, but the process can be painful:
- create a directory outside the project
- initialize a git repo
NewerOlder