Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/milankinen/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneZ committed Jan 21, 2017
2 parents fb7ea01 + fb71b9c commit 0d1f53c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,5 @@ MIT

## Contributing

Please create a [Github issue](issues) if problems occur. Pull request are also welcome
Please create a [Github issue](/../../issues) if problems occur. Pull request are also welcome
and they can be created to the `development` branch.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "livereactload",
"version": "3.1.0",
"version": "3.1.1",
"description": "Live code editing with Browserify and React",
"author": "Matti Lankinen <[email protected]> (https://github.com/milankinen)",
"license": "MIT",
Expand Down
14 changes: 2 additions & 12 deletions src/browserify-plugin/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function LiveReactloadPlugin(b, opts = {}) {
if (entry) {
entries.push(file)
}
mappings[file] = [sourceWithoutMaps, deps, {id: file, hash: md5(sourceWithoutMaps), browserifyId: id, sourcemap: adjustedSourcemap}]
mappings[file] = [sourceWithoutMaps, deps, {id: file, hash: hash, browserifyId: id, sourcemap: adjustedSourcemap}]
next(null, row)
},
function flush(next) {
Expand Down Expand Up @@ -153,8 +153,7 @@ function LiveReactloadPlugin(b, opts = {}) {
clientOpts
]
let bundleSrc =
`(${loader.toString()})(${args.map(a => JSON.stringify(a, null, 2)).join(", ")});
${__livereactload_loadAsModule.toString()};`
`(${loader.toString()})(${args.map(a => JSON.stringify(a, null, 2)).join(", ")});`
if (standalone) {
bundleSrc = umd(standalone, `return ${bundleSrc}`)
}
Expand All @@ -173,13 +172,4 @@ function LiveReactloadPlugin(b, opts = {}) {
}
}

function __livereactload_loadAsModule(__livereactload_source, __livereactload_sourcemap) {
return eval(
'function __livereactload_module(require, module, exports){\n' +
__livereactload_source +
'\n}; __livereactload_module;' +
(__livereactload_sourcemap || '')
);
}

module.exports = LiveReactloadPlugin
12 changes: 10 additions & 2 deletions src/reloading.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,21 @@ function loader(mappings, entryPoints, options) {
var body = mapping[0];
if (typeof body !== "function") {
debug("Compiling module", mapping[2])
var compiled = __livereactload_loadAsModule(body, mapping[2].sourcemap);
var compiled = compileModule(body, mapping[2].sourcemap);
mapping[0] = compiled;
mapping[2].source = body;
}
}

function compileModule(source, sourcemap) {
return eval(
"function __livereactload_module(require, module, exports){\n" +
source +
"\n}; __livereactload_module;" +
(sourcemap || "")
);
}

function unknownUseCase() {
throw new Error(
"Unknown use-case encountered! Please raise an issue: " +
Expand Down Expand Up @@ -428,7 +437,6 @@ function loader(mappings, entryPoints, options) {
function error(msg) {
console.error("LiveReactload ::", msg);
}

}

module.exports = loader;
Expand Down

0 comments on commit 0d1f53c

Please sign in to comment.