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
@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2011 eBay Software Foundation
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@ -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