diff --git a/README.md b/README.md index 5a4d677..76898ab 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/package.json b/package.json index a877d43..078973e 100644 --- a/package.json +++ b/package.json @@ -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 (https://github.com/milankinen)", "license": "MIT", diff --git a/src/browserify-plugin/main.js b/src/browserify-plugin/main.js index a78a931..c9566b7 100644 --- a/src/browserify-plugin/main.js +++ b/src/browserify-plugin/main.js @@ -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) { @@ -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}`) } @@ -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 diff --git a/src/reloading.js b/src/reloading.js index b501c91..b2380d3 100644 --- a/src/reloading.js +++ b/src/reloading.js @@ -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: " + @@ -428,7 +437,6 @@ function loader(mappings, entryPoints, options) { function error(msg) { console.error("LiveReactload ::", msg); } - } module.exports = loader;