Skip to content

Commit 1efc4db

Browse files
committed
Release version 3.1.2
2 parents fb71b9c + ca9d199 commit 1efc4db

6 files changed

Lines changed: 45 additions & 22 deletions

File tree

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
language: node_js
22
node_js:
3-
- "4.2.0"
3+
- "4"
4+
- "5"
5+
- "6"
46
before_script:
57
- npm install -g npm
68
script:

examples/01-basic-usage/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
},
2525
"devDependencies": {
2626
"babel-plugin-react-transform": "^2.0.2",
27-
"livereactload": "file:../..",
27+
"livereactload": "latest",
2828
"nodemon": "^1.9.2",
2929
"react-proxy": "^1.1.8",
3030
"watchify": "^3.7.0"

examples/02-redux/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
"devDependencies": {
2929
"babel-plugin-react-transform": "^2.0.2",
30-
"livereactload": "file:../..",
30+
"livereactload": "latest",
3131
"nodemon": "^1.9.2",
3232
"react-proxy": "^1.1.8",
3333
"watchify": "^3.7.0"

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "livereactload",
3-
"version": "3.1.1",
3+
"version": "3.1.2",
44
"description": "Live code editing with Browserify and React",
55
"author": "Matti Lankinen <m.lankinen@iki.fi> (https://github.com/milankinen)",
66
"license": "MIT",
@@ -29,21 +29,21 @@
2929
"dependencies": {
3030
"cli-color": "1.1.0",
3131
"convert-source-map": "1.3.0",
32-
"lodash": "4.13.1",
33-
"md5": "2.1.0",
32+
"lodash": "4.17.4",
33+
"md5": "2.2.1",
3434
"offset-sourcemap-lines": "1.0.0",
35-
"through2": "2.0.1",
35+
"through2": "2.0.3",
3636
"umd": "3.0.1",
3737
"ws": "1.1.1"
3838
},
3939
"devDependencies": {
40-
"babel-cli": "^6.10.1",
41-
"babel-preset-es2015": "^6.9.0",
40+
"babel-cli": "^6.18.0",
41+
"babel-preset-es2015": "^6.18.0",
4242
"babel-tape-runner": "2.0.1",
43-
"bluebird": "3.4.1",
44-
"chokidar": "1.6.0",
45-
"shelljs": "0.7.0",
46-
"tape": "4.6.0",
43+
"bluebird": "3.4.7",
44+
"chokidar": "1.6.1",
45+
"shelljs": "0.7.5",
46+
"tape": "4.6.3",
4747
"zombie": "4.2.1"
4848
}
4949
}

src/browserify-plugin/main.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ function LiveReactloadPlugin(b, opts = {}) {
107107
if (converter) {
108108
sourceWithoutMaps = convertSourceMaps.removeComments(source)
109109
hash = md5(sourceWithoutMaps)
110-
converter.setProperty('sources', [file.replace(basedir, hash)])
111110
adjustedSourcemap = convertSourceMaps.fromObject(offsetSourceMaps(converter.toObject(), 1)).toComment()
112111
} else {
113112
hash = md5(source)

src/reloading.js

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ function loader(mappings, entryPoints, options) {
4242

4343
var scope = {
4444
mappings: mappings,
45+
revNums: {},
4546
cache: {},
4647
reloading: false,
4748
reloadHooks: {},
@@ -80,23 +81,22 @@ function loader(mappings, entryPoints, options) {
8081
}
8182
}
8283

83-
function compile(mapping) {
84+
function compile(mapping, revision) {
8485
var body = mapping[0];
8586
if (typeof body !== "function") {
86-
debug("Compiling module", mapping[2])
87+
debug("Compiling module", mapping[2], "[revision " + revision + " ]")
8788
var compiled = compileModule(body, mapping[2].sourcemap);
8889
mapping[0] = compiled;
8990
mapping[2].source = body;
9091
}
9192
}
9293

9394
function compileModule(source, sourcemap) {
94-
return eval(
95-
"function __livereactload_module(require, module, exports){\n" +
96-
source +
97-
"\n}; __livereactload_module;" +
98-
(sourcemap || "")
95+
var toModule = new Function(
96+
"__livereactload_source", "__livereactload_sourcemap",
97+
"return eval('function __livereactload_module(require, module, exports){\\n' + __livereactload_source + '\\n}; __livereactload_module;' + (__livereactload_sourcemap || ''));"
9998
);
99+
return toModule(source, sourcemap)
100100
}
101101

102102
function unknownUseCase() {
@@ -163,12 +163,34 @@ function loader(mappings, entryPoints, options) {
163163
var mapping = mappings[id];
164164
var meta = mapping[2];
165165
if (!old || old[2].hash !== meta.hash) {
166-
compile(mapping);
166+
var rev = scope.revNums[id] ? ++scope.revNums[id] : (scope.revNums[id] = 1);
167+
if (old && meta.sourcemap) {
168+
addVersionToSourceMap(meta, rev);
169+
}
170+
compile(mapping, rev);
167171
scope.mappings[id] = mapping;
168172
changes.push([id, old]);
169173
}
170174
});
171175
return changes;
176+
177+
// Updates the source map by adding a revision parameter to the filename.
178+
// Without this new filename, browsers will ignore the updated source map.
179+
function addVersionToSourceMap(meta, revision) {
180+
var comment = meta.sourcemap
181+
.replace(/^\/\*/g, '//')
182+
.replace(/\*\/$/g, '');
183+
// decode sourcemap comment and add hash param
184+
comment = comment.split(',').pop();
185+
var sourcemap = JSON.parse(atob(comment));
186+
for (var i = 0; i < sourcemap.sources.length; i++) {
187+
sourcemap.sources[i] += "?rev=" + revision;
188+
}
189+
// re-encode to sourcemap comment
190+
comment = btoa(JSON.stringify(sourcemap));
191+
comment = '//# sourceMappingURL=data:application/json;base64,' + comment;
192+
meta.sourcemap = comment;
193+
}
172194
}
173195

174196
/**

0 commit comments

Comments
 (0)