diff --git a/browser-refresh/index.js b/browser-refresh/index.js index a04c0a51a..4d18aef76 100644 --- a/browser-refresh/index.js +++ b/browser-refresh/index.js @@ -1,28 +1,23 @@ var enabled = false; +var browserRefreshClient = require('browser-refresh-client'); exports.enable = function() { + if (!browserRefreshClient.isBrowserRefreshEnabled()) { + return; + } + if (enabled) { return; } enabled = true; - if (process.env.BROWSER_REFRESH_URL) { - var modifiedEvent = 'marko.fileModified'; + var hotReload = require('../hot-reload'); + hotReload.enable(); - process.send({ - type: 'browser-refresh.specialReload', - pattern: '*.marko marko-taglib.json marko-tag.json', - modifiedEvent: modifiedEvent + browserRefreshClient + .enableSpecialReload('*.marko marko-taglib.json marko-tag.json') + .onFileModified(function(path) { + hotReload.handleFileModified(path); }); - - var hotReload = require('../hot-reload'); - hotReload.enable(); - - process.on('message', function(m) { - if (typeof m === 'object' && m.type === modifiedEvent) { - hotReload.handleFileModified(m.path); - } - }); - } }; \ No newline at end of file diff --git a/package.json b/package.json index a868b1759..86de29a01 100644 --- a/package.json +++ b/package.json @@ -1,61 +1,62 @@ { - "name": "marko", - "description": "Marko is an extensible, streaming, asynchronous, high performance, HTML-based templating language that can be used in Node.js or in the browser.", - "keywords": [ - "templating", - "template", - "async", - "streaming" - ], - "repository": { - "type": "git", - "url": "https://github.com/raptorjs/marko.git" - }, - "scripts": { - "test": "node_modules/.bin/mocha --ui bdd --reporter spec ./test && node_modules/.bin/jshint compiler/ runtime/ taglibs/" - }, - "author": "Patrick Steele-Idem ", - "maintainers": [ - "Patrick Steele-Idem " - ], - "dependencies": { - "app-module-path": "^1.0.0", - "async-writer": "^1.1.2", - "char-props": "~0.1.5", - "events": "^1.0.2", - "htmlparser2": "^3.7.2", - "marko-async": "^1.2.12", - "marko-layout": "^1.1.0", - "minimatch": "^0.2.14", - "property-handlers": "^1.0.0", - "raptor-args": "^1.0.0", - "raptor-json": "^1.0.1", - "raptor-logging": "^1.0.1", - "raptor-modules": "^1.0.5", - "raptor-polyfill": "^1.0.0", - "raptor-promises": "^1.0.1", - "raptor-regexp": "^1.0.0", - "raptor-strings": "^1.0.0", - "raptor-util": "^1.0.0", - "resolve-from": "^1.0.0", - "sax": "^0.6.0" - }, - "devDependencies": { - "chai": "~1.8.1", - "dustjs-linkedin": "^2.3.4", - "jshint": "^2.5.0", - "mocha": "~1.15.1", - "raptor-cache": "^1.1.1", - "raptor-data-providers": "^1.0.1-beta", - "through": "^2.3.4" - }, - "license": "Apache License v2.0", - "bin": { - "markoc": "bin/markoc" - }, - "main": "runtime/marko-runtime.js", - "publishConfig": { - "registry": "https://registry.npmjs.org/" - }, - "version": "1.3.15" -} \ No newline at end of file + "name": "marko", + "description": "Marko is an extensible, streaming, asynchronous, high performance, HTML-based templating language that can be used in Node.js or in the browser.", + "keywords": [ + "templating", + "template", + "async", + "streaming" + ], + "repository": { + "type": "git", + "url": "https://github.com/raptorjs/marko.git" + }, + "scripts": { + "test": "node_modules/.bin/mocha --ui bdd --reporter spec ./test && node_modules/.bin/jshint compiler/ runtime/ taglibs/" + }, + "author": "Patrick Steele-Idem ", + "maintainers": [ + "Patrick Steele-Idem " + ], + "dependencies": { + "app-module-path": "^1.0.0", + "async-writer": "^1.1.2", + "browser-refresh-client": "^1.0.0", + "char-props": "~0.1.5", + "events": "^1.0.2", + "htmlparser2": "^3.7.2", + "marko-async": "^1.2.12", + "marko-layout": "^1.1.0", + "minimatch": "^0.2.14", + "property-handlers": "^1.0.0", + "raptor-args": "^1.0.0", + "raptor-json": "^1.0.1", + "raptor-logging": "^1.0.1", + "raptor-modules": "^1.0.5", + "raptor-polyfill": "^1.0.0", + "raptor-promises": "^1.0.1", + "raptor-regexp": "^1.0.0", + "raptor-strings": "^1.0.0", + "raptor-util": "^1.0.0", + "resolve-from": "^1.0.0", + "sax": "^0.6.0" + }, + "devDependencies": { + "chai": "~1.8.1", + "dustjs-linkedin": "^2.3.4", + "jshint": "^2.5.0", + "mocha": "~1.15.1", + "raptor-cache": "^1.1.1", + "raptor-data-providers": "^1.0.1-beta", + "through": "^2.3.4" + }, + "license": "Apache License v2.0", + "bin": { + "markoc": "bin/markoc" + }, + "main": "runtime/marko-runtime.js", + "publishConfig": { + "registry": "https://registry.npmjs.org/" + }, + "version": "1.3.15" +}