JSFiddle - React, Tailwind, and code Playground

by cjblomqvist

HTML

<div id="result"></div><div id="hello">Hello World</div>
<br/>
<br/>
<h4>Generated with cli.js and works on OSX (below files were used, based upon the example provided in the README.</h4>
<h4>Line run: node cli.js entry.js -o testx.js</h4>
<h2>entry.js</h2>
<p><code>var foo = require('./foo');<br/>
<br/>
window.onload = function () {<br/>
    document.getElementById('result').innerHTML = foo(100);<br/>
    };</code></p>
<h2>foo.js</h2>
<p><code>var bar = require('./bar');<br/>
<br/>
module.exports = function (x) {<br/>
    return x * bar.coeff(x) + (x * 3 - 2)<br/>
    };</code></p>
<h2>bar.js</h2>
<p><code>exports.coeff = function (x) {
    return Math.log(x) / Math.log(2) + 1;
    };</code></p>

JavaScript

var require = function (file, cwd) {
    var resolved = require.resolve(file, cwd || '/');
    var mod = require.modules[resolved];
    if (!mod) throw new Error(
        'Failed to resolve module ' + file + ', tried ' + resolved
    );
    var res = mod._cached ? mod._cached : mod();
    return res;
}

require.paths = [];
require.modules = {};
require.extensions = [".js",".coffee"];

require._core = {
    'assert': true,
    'events': true,
    'fs': true,
    'path': true,
    'vm': true
};

require.resolve = (function () {
    return function (x, cwd) {
        if (!cwd) cwd = '/';
        
        if (require._core[x]) return x;
        var path = require.modules.path();
        cwd = path.resolve('/', cwd);
        var y = cwd || '/';
        
        if (x.match(/^(?:\.\.?\/|\/)/)) {
            var m = loadAsFileSync(path.resolve(y, x))
                || loadAsDirectorySync(path.resolve(y, x));
            if (m) return m;
        }
        
        var n = loadNodeModulesSync(x, y);
        if (n) return n;
        
        throw new Error("Cannot find module '" + x + "'");
        
        function loadAsFileSync (x) {
            if (require.modules[x]) {
                return x;
            }
            
            for (var i = 0; i < require.extensions.length; i++) {
                var ext = require.extensions[i];
                if (require.modules[x + ext]) return x + ext;
            }
        }
        
        function loadAsDirectorySync (x) {
            x = x.replace(/\/+$/, '');
            var pkgfile = x + '/package.json';
            if (require.modules[pkgfile]) {
                var pkg = require.modules[pkgfile]();
                var b = pkg.browserify;
                if (typeof b === 'object' && b.main) {
                    var m = loadAsFileSync(path.resolve(x, b.main));
                    if (m) return m;
                }
                else if (typeof b === 'string') {
                    var m =...