mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
Fixes circular dependency issue between runtime/index.js and hot-reload/index.js
This commit is contained in:
parent
f0fe0e4c0a
commit
a3f4a823a4
@ -19,19 +19,29 @@ require('raptor-polyfill/string/endsWith');
|
||||
var extend = require('raptor-util/extend');
|
||||
var compiler = require('../compiler');
|
||||
var nodePath = require('path');
|
||||
var runtime = require('../runtime');
|
||||
var Template = runtime.Template;
|
||||
|
||||
var modifiedFlag = 1;
|
||||
var runtime;
|
||||
|
||||
/**
|
||||
* Lazily require the Marko runtime because there is a circular dependency.
|
||||
* We need to export our `enable` function before actually requiring the
|
||||
* Marko runtime.
|
||||
*/
|
||||
function _getMarkoRuntime() {
|
||||
return runtime || (runtime = require('../runtime'));
|
||||
}
|
||||
|
||||
exports.enable = function() {
|
||||
|
||||
var runtime = _getMarkoRuntime();
|
||||
|
||||
if (runtime.__hotReloadEnabled) {
|
||||
// Marko has already been monkey-patched. Nothing to do!
|
||||
return;
|
||||
}
|
||||
|
||||
var Template = runtime.Template;
|
||||
|
||||
runtime.__hotReloadEnabled = true;
|
||||
|
||||
// We set an environment variable so that _all_ marko modules
|
||||
@ -93,7 +103,7 @@ exports.enable = function() {
|
||||
};
|
||||
|
||||
exports.handleFileModified = function(path) {
|
||||
|
||||
var runtime = _getMarkoRuntime();
|
||||
var basename = nodePath.basename(path);
|
||||
|
||||
if (path.endsWith('.marko') ||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user