Skip to content

Commit 024f873

Browse files
committed
mod: lazyAppReload is false by default
1 parent c22dd7c commit 024f873

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

plugins/isomorphic/index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
11
var Module = require('module');
22
var frontendCache = {};
33
var frontendFactoryCache = {};
4+
var frontendLoaded = {};
45
var debuglog = require('debuglog')('yog/isomorphic');
56

67
module.exports.isomorphic = ['views', function (app, conf) {
78
var namespaceConnector = conf.namespaceConnector || ':';
89

910
global.define = function (id, factory) {
10-
debuglog('isomorphic script', id, 'loaded');
1111
frontendFactoryCache['frontend_' + id] = factory;
1212
};
1313

14-
function getDeps(id) {
14+
function getDeps(id, loaded) {
1515
let deps = [];
1616
var info = app.fis.getInfo(id);
1717
if (!info) {
1818
return deps;
1919
}
2020
if (info.deps) {
2121
info.deps.forEach(dep => {
22-
deps = deps.concat(getDeps(dep));
22+
deps = deps.concat(getDeps(dep, loaded));
2323
});
2424
}
25-
if (info.type === 'js') {
25+
if (info.type === 'js' && !loaded[info.subpath]) {
2626
if (!info.subpath) {
2727
throw new Error('Please update your yog2 cli version to support isomorphic mode.');
2828
}
29+
loaded[info.subpath] = true;
2930
deps.push(info.subpath);
3031
}
3132
return deps;
@@ -38,7 +39,7 @@ module.exports.isomorphic = ['views', function (app, conf) {
3839
return originModuleLoad(request, parent, isMain);
3940
}
4041
if (!frontendFactoryCache['frontend_' + request]) {
41-
getDeps(request).forEach(dep => {
42+
getDeps(request, frontendLoaded).forEach(dep => {
4243
debuglog('require isomorphic script from', dep);
4344
require(yog.ROOT_PATH + dep);
4445
});
@@ -59,6 +60,7 @@ module.exports.isomorphic = ['views', function (app, conf) {
5960

6061
return {
6162
cleanCache: function () {
63+
frontendLoaded = {};
6264
frontendCache = {};
6365
frontendFactoryCache = {};
6466
}

plugins/recv-reload/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ function reloadIsomorphic() {
121121
if (yog.plugins.isomorphic && yog.plugins.isomorphic.cleanCache) {
122122
yog.plugins.isomorphic.cleanCache();
123123
if (yog.conf.static) {
124-
console.log('clean')
125124
cleanCacheForFolder(yog.conf.static.staticPath);
126125
} else {
127126
cleanCacheForFolder(path.join(yog.ROOT_PATH, 'static'));
@@ -342,5 +341,5 @@ module.exports['recv-reload'].defaultConf = {
342341
uploadTimeout: 30,
343342
maxTarSize: '200mb',
344343
onCacheClean: null,
345-
lazyAppReload: true
344+
lazyAppReload: false
346345
};

0 commit comments

Comments
 (0)