crazy-taxi
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -5,2 +5,3 @@ const webpack = require('webpack') | ||
const fs = require('fs') | ||
const shortid = require('shortid') | ||
@@ -14,3 +15,3 @@ const render = require('mithril-node-render') | ||
const _bundled_mithril = fs.readFileSync(require.resolve('mithril/mithril.min.js'),'utf8') | ||
const _bundled_framework = fs.readFileSync(require.resolve('mithril/mithril.min.js'),'utf8') | ||
@@ -55,2 +56,3 @@ | ||
const _bundle_id = shortid.generate() | ||
@@ -64,7 +66,7 @@ const fs = new MemoryFS() | ||
filename: 'bundle.js', | ||
library: _target_file_path, | ||
library: _bundle_id, | ||
libraryTarget: 'umd' | ||
}, | ||
externals: { | ||
"crazy-taxi": "m" | ||
"crazy-taxi": 'm' | ||
}, | ||
@@ -82,25 +84,25 @@ module: { | ||
// console.log(stats.toString({ | ||
// chunks: false, | ||
// colors: true | ||
// })) | ||
// console.log(_caller_dir_path) | ||
_bundled_files = fs.readFileSync(path.resolve(_caller_dir_path, 'bundle.js'), 'utf8') | ||
// console.log(_bundled_files.slice(0,30)) | ||
}) | ||
return (params) => { | ||
return (params, config) => { | ||
if(false) | ||
params = params || {} | ||
config = config || {} | ||
const render_id = shortid.generate() | ||
let output_string = ` | ||
<div id="${_target_file_path}"> | ||
${render(hyperscript(_compiled_files, params))} | ||
<div id="${render_id}"> | ||
${render(hyperscript(_compiled_files, params))} | ||
</div> | ||
<script> | ||
${_bundled_mithril} | ||
${config.exclude_framework ? '' : _bundled_framework} | ||
${_bundled_files} | ||
window['${_target_file_path}-init'] = ${JSON.stringify(params)} | ||
m.mount(document.getElementById('${_target_file_path}'), {view: function () { return m(window['${_target_file_path}'], window['${_target_file_path}-init'])}}) | ||
window['${render_id}-data'] = ${JSON.stringify(params)} | ||
m.mount(document.getElementById('${render_id}'), {view: function () { return m(window['${_bundle_id}'], window['${render_id}-data'])}}) | ||
</script> | ||
@@ -107,0 +109,0 @@ ` |
@@ -12,2 +12,3 @@ "use strict" | ||
c.buildQueryString = require("mithril/querystring/build") | ||
c.version = "bleeding-edge" | ||
@@ -17,2 +18,10 @@ | ||
// Polyfill | ||
c.request = require('mithril/stream') | ||
c.jsonp = require('mithril/stream') | ||
module.exports = c |
{ | ||
"name": "crazy-taxi", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "A wrapper around mithril that utilizes mithril-node-render and webpack to render mithril templates server side along with their bundle so that tehy function seamlessly on the client.", | ||
@@ -29,4 +29,6 @@ "main": "index.js", | ||
"mithril-node-render": "github:stephanhoyer/mithril-node-render#rewrite", | ||
"node-uuid": "^1.4.7", | ||
"shortid": "^2.2.6", | ||
"webpack": "^1.13.3" | ||
} | ||
} |
3801
82
6
+ Addednode-uuid@^1.4.7
+ Addedshortid@^2.2.6
+ Addednanoid@3.3.8(transitive)
+ Addednode-uuid@1.4.8(transitive)
+ Addedshortid@2.2.17(transitive)