Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
59d20555
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
59d20555
编写于
1月 17, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use createCachedData when possible
上级
311fa7e8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
41 addition
and
17 deletion
+41
-17
src/main.js
src/main.js
+2
-1
src/vs/loader.js
src/vs/loader.js
+39
-16
未找到文件。
src/main.js
浏览文件 @
59d20555
...
...
@@ -268,7 +268,8 @@ function getNodeCachedDir() {
}
jsFlags
()
{
return
this
.
value
?
'
--nolazy
'
:
undefined
;
// return this.value ? '--nolazy' : undefined;
return
undefined
;
}
ensureExists
()
{
...
...
src/vs/loader.js
浏览文件 @
59d20555
...
...
@@ -179,7 +179,7 @@ var AMDLoader;
};
Utilities
.
forEachProperty
=
function
(
obj
,
callback
)
{
if
(
obj
)
{
var
key
=
undefined
;
var
key
=
void
0
;
for
(
key
in
obj
)
{
if
(
obj
.
hasOwnProperty
(
key
))
{
callback
(
key
,
obj
[
key
]);
...
...
@@ -327,8 +327,8 @@ var AMDLoader;
return
options
;
};
ConfigurationOptionsUtil
.
mergeConfigurationOptions
=
function
(
overwrite
,
base
)
{
if
(
overwrite
===
undefined
)
{
overwrite
=
null
;
}
if
(
base
===
undefined
)
{
base
=
null
;
}
if
(
overwrite
===
void
0
)
{
overwrite
=
null
;
}
if
(
base
===
void
0
)
{
base
=
null
;
}
var
result
=
AMDLoader
.
Utilities
.
recursiveClone
(
base
||
{});
// Merge known properties and overwrite the unknown ones
AMDLoader
.
Utilities
.
forEachProperty
(
overwrite
,
function
(
key
,
value
)
{
...
...
@@ -660,6 +660,7 @@ var AMDLoader;
this
.
_env
=
env
;
this
.
_didInitialize
=
false
;
this
.
_didPatchNodeRequire
=
false
;
this
.
_hasCreateCachedData
=
false
;
}
NodeScriptLoader
.
prototype
.
_init
=
function
(
nodeRequire
)
{
if
(
this
.
_didInitialize
)
{
...
...
@@ -671,6 +672,8 @@ var AMDLoader;
this
.
_vm
=
nodeRequire
(
'
vm
'
);
this
.
_path
=
nodeRequire
(
'
path
'
);
this
.
_crypto
=
nodeRequire
(
'
crypto
'
);
// check for `createCachedData`-api
this
.
_hasCreateCachedData
=
typeof
(
new
this
.
_vm
.
Script
(
''
).
createCachedData
)
===
'
function
'
;
};
// patch require-function of nodejs such that we can manually create a script
// from cached data. this is done by overriding the `Module._compile` function
...
...
@@ -711,7 +714,7 @@ var AMDLoader;
options
.
cachedData
=
that
.
_fs
.
readFileSync
(
cachedDataPath
);
}
catch
(
e
)
{
options
.
produceCachedData
=
true
;
options
.
produceCachedData
=
!
that
.
_hasCreateCachedData
;
}
var
script
=
new
that
.
_vm
.
Script
(
wrapper
,
options
);
var
compileWrapper
=
script
.
runInThisContext
(
options
);
...
...
@@ -719,7 +722,7 @@ var AMDLoader;
var
require
=
makeRequireFunction
(
this
);
var
args
=
[
this
.
exports
,
require
,
this
,
filename
,
dirname
,
process
,
_commonjsGlobal
,
Buffer
];
var
result
=
compileWrapper
.
apply
(
this
.
exports
,
args
);
that
.
_processCachedData
(
moduleManager
,
script
,
cachedDataPath
);
that
.
_processCachedData
(
moduleManager
,
script
,
wrapper
,
cachedDataPath
,
!
options
.
cachedData
);
return
result
;
};
};
...
...
@@ -778,15 +781,15 @@ var AMDLoader;
}
else
{
var
cachedDataPath_1
=
_this
.
_getCachedDataPath
(
opts
.
nodeCachedData
.
seed
,
opts
.
nodeCachedData
.
path
,
scriptSrc
);
_this
.
_fs
.
readFile
(
cachedDataPath_1
,
function
(
err
,
cachedData
)
{
_this
.
_fs
.
readFile
(
cachedDataPath_1
,
function
(
_
err
,
cachedData
)
{
// create script options
var
options
=
{
filename
:
vmScriptSrc
,
produceCachedData
:
typeof
cachedData
===
'
undefined
'
,
produceCachedData
:
!
_this
.
_hasCreateCachedData
&&
typeof
cachedData
===
'
undefined
'
,
cachedData
:
cachedData
};
var
script
=
_this
.
_loadAndEvalScript
(
moduleManager
,
scriptSrc
,
vmScriptSrc
,
contents
,
options
,
recorder
,
callback
,
errorback
);
_this
.
_processCachedData
(
moduleManager
,
script
,
c
achedDataPath_1
);
_this
.
_processCachedData
(
moduleManager
,
script
,
c
ontents
,
cachedDataPath_1
,
!
options
.
cachedData
);
});
}
});
...
...
@@ -820,7 +823,7 @@ var AMDLoader;
var
basename
=
this
.
_path
.
basename
(
filename
).
replace
(
/
\.
js$/
,
''
);
return
this
.
_path
.
join
(
basedir
,
basename
+
"
-
"
+
hash
+
"
.code
"
);
};
NodeScriptLoader
.
prototype
.
_processCachedData
=
function
(
moduleManager
,
script
,
c
achedDataPath
)
{
NodeScriptLoader
.
prototype
.
_processCachedData
=
function
(
moduleManager
,
script
,
c
ontents
,
cachedDataPath
,
createCachedData
)
{
var
_this
=
this
;
if
(
script
.
cachedDataRejected
)
{
// data rejected => delete cache file
...
...
@@ -838,13 +841,12 @@ var AMDLoader;
});
}
});
},
moduleManager
.
getConfig
().
getOptionsLiteral
().
nodeCachedData
.
writeDelay
);
},
moduleManager
.
getConfig
().
getOptionsLiteral
().
nodeCachedData
.
writeDelay
/
2
);
}
else
if
(
script
.
cachedDataProduced
)
{
// data produced => tell outside world
moduleManager
.
getConfig
().
getOptionsLiteral
().
nodeCachedData
.
onData
(
undefined
,
{
path
:
cachedDataPath
,
length
:
script
.
cachedData
.
length
path
:
cachedDataPath
});
// data produced => write cache file
NodeScriptLoader
.
_runSoon
(
function
()
{
...
...
@@ -859,6 +861,27 @@ var AMDLoader;
});
},
moduleManager
.
getConfig
().
getOptionsLiteral
().
nodeCachedData
.
writeDelay
);
}
else
if
(
this
.
_hasCreateCachedData
&&
createCachedData
)
{
// NEW world
// data produced => tell outside world
moduleManager
.
getConfig
().
getOptionsLiteral
().
nodeCachedData
.
onData
(
undefined
,
{
path
:
cachedDataPath
});
// soon'ish create and save cached data
NodeScriptLoader
.
_runSoon
(
function
()
{
var
data
=
script
.
createCachedData
(
contents
);
_this
.
_fs
.
writeFile
(
cachedDataPath
,
data
,
function
(
err
)
{
if
(
!
err
)
{
return
;
}
moduleManager
.
getConfig
().
getOptionsLiteral
().
nodeCachedData
.
onData
({
errorCode
:
'
writeFile
'
,
path
:
cachedDataPath
,
detail
:
err
});
});
},
moduleManager
.
getConfig
().
getOptionsLiteral
().
nodeCachedData
.
writeDelay
*
2
);
}
};
NodeScriptLoader
.
_runSoon
=
function
(
callback
,
minTimeout
)
{
var
timeout
=
minTimeout
+
Math
.
ceil
(
Math
.
random
()
*
minTimeout
);
...
...
@@ -1067,7 +1090,7 @@ var AMDLoader;
AMDLoader
.
PluginDependency
=
PluginDependency
;
var
ModuleManager
=
(
function
()
{
function
ModuleManager
(
env
,
scriptLoader
,
defineFunc
,
requireFunc
,
loaderAvailableTimestamp
)
{
if
(
loaderAvailableTimestamp
===
undefined
)
{
loaderAvailableTimestamp
=
0
;
}
if
(
loaderAvailableTimestamp
===
void
0
)
{
loaderAvailableTimestamp
=
0
;
}
this
.
_env
=
env
;
this
.
_scriptLoader
=
scriptLoader
;
this
.
_loaderAvailableTimestamp
=
loaderAvailableTimestamp
;
...
...
@@ -1186,7 +1209,7 @@ var AMDLoader;
*/
ModuleManager
.
prototype
.
defineModule
=
function
(
strModuleId
,
dependencies
,
callback
,
errorback
,
stack
,
moduleIdResolver
)
{
var
_this
=
this
;
if
(
moduleIdResolver
===
undefined
)
{
moduleIdResolver
=
new
ModuleIdResolver
(
strModuleId
);
}
if
(
moduleIdResolver
===
void
0
)
{
moduleIdResolver
=
new
ModuleIdResolver
(
strModuleId
);
}
var
moduleId
=
this
.
_moduleIdProvider
.
getModuleId
(
strModuleId
);
if
(
this
.
_modules2
[
moduleId
])
{
if
(
!
this
.
_config
.
isDuplicateMessageIgnoredFor
(
strModuleId
))
{
...
...
@@ -1245,7 +1268,7 @@ var AMDLoader;
* @return The exports of module 'id'
*/
ModuleManager
.
prototype
.
synchronousRequire
=
function
(
_strModuleId
,
moduleIdResolver
)
{
if
(
moduleIdResolver
===
undefined
)
{
moduleIdResolver
=
new
ModuleIdResolver
(
_strModuleId
);
}
if
(
moduleIdResolver
===
void
0
)
{
moduleIdResolver
=
new
ModuleIdResolver
(
_strModuleId
);
}
var
dependency
=
this
.
_normalizeDependency
(
_strModuleId
,
moduleIdResolver
);
var
m
=
this
.
_modules2
[
dependency
.
id
];
if
(
!
m
)
{
...
...
@@ -1637,7 +1660,7 @@ var AMDLoader;
jQuery
:
true
};
var
_requireFunc_config
=
function
(
params
,
shouldOverwrite
)
{
if
(
shouldOverwrite
===
undefined
)
{
shouldOverwrite
=
false
;
}
if
(
shouldOverwrite
===
void
0
)
{
shouldOverwrite
=
false
;
}
moduleManager
.
configure
(
params
,
shouldOverwrite
);
};
var
RequireFunc
=
function
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录