Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
5a52c24f
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,发现更多精彩内容 >>
提交
5a52c24f
编写于
7月 20, 2018
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add an alternative optimize-editor task
上级
d8e13dc7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
55 addition
and
28 deletion
+55
-28
build/gulpfile.editor.js
build/gulpfile.editor.js
+20
-0
build/gulpfile.vscode.js
build/gulpfile.vscode.js
+1
-0
build/lib/optimize.js
build/lib/optimize.js
+15
-14
build/lib/optimize.ts
build/lib/optimize.ts
+19
-14
未找到文件。
build/gulpfile.editor.js
浏览文件 @
5a52c24f
...
...
@@ -83,6 +83,7 @@ gulp.task('extract-editor-src', ['clean-editor-src'], function() {
entryPoints
:
[
'
vs/editor/editor.main
'
,
'
vs/editor/editor.worker
'
,
'
vs/base/worker/workerMain
'
,
// 'user',
// 'user2',
],
...
...
@@ -105,6 +106,7 @@ gulp.task('extract-editor-src', ['clean-editor-src'], function() {
gulp
.
task
(
'
clean-optimized-editor
'
,
util
.
rimraf
(
'
out-editor
'
));
gulp
.
task
(
'
optimize-editor
'
,
[
'
clean-optimized-editor
'
,
'
compile-client-build
'
],
common
.
optimizeTask
({
src
:
'
out-build
'
,
entryPoints
:
editorEntryPoints
,
otherSources
:
editorOtherSources
,
resources
:
editorResources
,
...
...
@@ -120,6 +122,24 @@ gulp.task('optimize-editor', ['clean-optimized-editor', 'compile-client-build'],
gulp
.
task
(
'
clean-editor-build
'
,
util
.
rimraf
(
'
out-editor-build
'
));
gulp
.
task
(
'
compile-editor-build
'
,
[
'
clean-editor-build
'
,
'
extract-editor-src
'
],
compilation
.
compileTask
(
'
out-editor-src
'
,
'
out-editor-build
'
,
true
));
gulp
.
task
(
'
optimize-editor2
'
,
[
'
clean-optimized-editor
'
,
'
compile-editor-build
'
],
common
.
optimizeTask
({
src
:
'
out-editor-build
'
,
entryPoints
:
editorEntryPoints
,
otherSources
:
editorOtherSources
,
resources
:
editorResources
,
loaderConfig
:
{
paths
:
{
'
vs
'
:
'
out-editor-build/vs
'
,
'
vscode
'
:
'
empty:
'
}
},
bundleLoader
:
false
,
header
:
BUNDLED_FILE_HEADER
,
bundleInfo
:
true
,
out
:
'
out-editor
'
,
languages
:
languages
}));
gulp
.
task
(
'
clean-minified-editor
'
,
util
.
rimraf
(
'
out-editor-min
'
));
gulp
.
task
(
'
minify-editor
'
,
[
'
clean-minified-editor
'
,
'
optimize-editor
'
],
common
.
minifyTask
(
'
out-editor
'
));
...
...
build/gulpfile.vscode.js
浏览文件 @
5a52c24f
...
...
@@ -95,6 +95,7 @@ const BUNDLED_FILE_HEADER = [
gulp
.
task
(
'
clean-optimized-vscode
'
,
util
.
rimraf
(
'
out-vscode
'
));
gulp
.
task
(
'
optimize-vscode
'
,
[
'
clean-optimized-vscode
'
,
'
compile-build
'
,
'
compile-extensions-build
'
],
common
.
optimizeTask
({
src
:
'
out-build
'
,
entryPoints
:
vscodeEntryPoints
,
otherSources
:
[],
resources
:
vscodeResources
,
...
...
build/lib/optimize.js
浏览文件 @
5a52c24f
...
...
@@ -37,19 +37,19 @@ function loaderConfig(emptyPaths) {
}
exports
.
loaderConfig
=
loaderConfig
;
var
IS_OUR_COPYRIGHT_REGEXP
=
/Copyright
\(
C
\)
Microsoft Corporation/i
;
function
loader
(
bundledFileHeader
,
bundleLoader
)
{
function
loader
(
src
,
bundledFileHeader
,
bundleLoader
)
{
var
sources
=
[
'
out-build/vs/loader.js
'
src
+
"
/vs/loader.js
"
];
if
(
bundleLoader
)
{
sources
=
sources
.
concat
([
'
out-build/vs/css.js
'
,
'
out-build/vs/nls.js
'
src
+
"
/vs/css.js
"
,
src
+
"
/vs/nls.js
"
]);
}
var
isFirst
=
true
;
return
(
gulp
.
src
(
sources
,
{
base
:
'
out-build
'
})
.
src
(
sources
,
{
base
:
""
+
src
})
.
pipe
(
es
.
through
(
function
(
data
)
{
if
(
isFirst
)
{
isFirst
=
false
;
...
...
@@ -71,7 +71,7 @@ function loader(bundledFileHeader, bundleLoader) {
return
f
;
})));
}
function
toConcatStream
(
bundledFileHeader
,
sources
,
dest
)
{
function
toConcatStream
(
src
,
bundledFileHeader
,
sources
,
dest
)
{
var
useSourcemaps
=
/
\.
js$/
.
test
(
dest
)
&&
!
/
\.
nls
\.
js$/
.
test
(
dest
);
// If a bundle ends up including in any of the sources our copyright, then
// insert a fake source at the beginning of each bundle with our copyright
...
...
@@ -91,7 +91,7 @@ function toConcatStream(bundledFileHeader, sources, dest) {
}
var
treatedSources
=
sources
.
map
(
function
(
source
)
{
var
root
=
source
.
path
?
REPO_ROOT_PATH
.
replace
(
/
\\
/g
,
'
/
'
)
:
''
;
var
base
=
source
.
path
?
root
+
'
/out-build
'
:
''
;
var
base
=
source
.
path
?
root
+
(
"
/
"
+
src
)
:
''
;
return
new
VinylFile
({
path
:
source
.
path
?
root
+
'
/
'
+
source
.
path
.
replace
(
/
\\
/g
,
'
/
'
)
:
'
fake
'
,
base
:
base
,
...
...
@@ -102,12 +102,13 @@ function toConcatStream(bundledFileHeader, sources, dest) {
.
pipe
(
useSourcemaps
?
util
.
loadSourcemaps
()
:
es
.
through
())
.
pipe
(
concat
(
dest
));
}
function
toBundleStream
(
bundledFileHeader
,
bundles
)
{
function
toBundleStream
(
src
,
bundledFileHeader
,
bundles
)
{
return
es
.
merge
(
bundles
.
map
(
function
(
bundle
)
{
return
toConcatStream
(
bundledFileHeader
,
bundle
.
sources
,
bundle
.
dest
);
return
toConcatStream
(
src
,
bundledFileHeader
,
bundle
.
sources
,
bundle
.
dest
);
}));
}
function
optimizeTask
(
opts
)
{
var
src
=
opts
.
src
;
var
entryPoints
=
opts
.
entryPoints
;
var
otherSources
=
opts
.
otherSources
;
var
resources
=
opts
.
resources
;
...
...
@@ -123,7 +124,7 @@ function optimizeTask(opts) {
if
(
err
)
{
return
bundlesStream
.
emit
(
'
error
'
,
JSON
.
stringify
(
err
));
}
toBundleStream
(
bundledFileHeader
,
result
.
files
).
pipe
(
bundlesStream
);
toBundleStream
(
src
,
bundledFileHeader
,
result
.
files
).
pipe
(
bundlesStream
);
// Remove css inlined resources
var
filteredResources
=
resources
.
slice
();
result
.
cssInlinedResources
.
forEach
(
function
(
resource
)
{
...
...
@@ -132,7 +133,7 @@ function optimizeTask(opts) {
}
filteredResources
.
push
(
'
!
'
+
resource
);
});
gulp
.
src
(
filteredResources
,
{
base
:
'
out-build
'
}).
pipe
(
resourcesStream
);
gulp
.
src
(
filteredResources
,
{
base
:
""
+
src
}).
pipe
(
resourcesStream
);
var
bundleInfoArray
=
[];
if
(
opts
.
bundleInfo
)
{
bundleInfoArray
.
push
(
new
VinylFile
({
...
...
@@ -145,9 +146,9 @@ function optimizeTask(opts) {
});
var
otherSourcesStream
=
es
.
through
();
var
otherSourcesStreamArr
=
[];
gulp
.
src
(
otherSources
,
{
base
:
'
out-build
'
})
gulp
.
src
(
otherSources
,
{
base
:
""
+
src
})
.
pipe
(
es
.
through
(
function
(
data
)
{
otherSourcesStreamArr
.
push
(
toConcatStream
(
bundledFileHeader
,
[
data
],
data
.
relative
));
otherSourcesStreamArr
.
push
(
toConcatStream
(
src
,
bundledFileHeader
,
[
data
],
data
.
relative
));
},
function
()
{
if
(
!
otherSourcesStreamArr
.
length
)
{
setTimeout
(
function
()
{
otherSourcesStream
.
emit
(
'
end
'
);
},
0
);
...
...
@@ -156,7 +157,7 @@ function optimizeTask(opts) {
es
.
merge
(
otherSourcesStreamArr
).
pipe
(
otherSourcesStream
);
}
}));
var
result
=
es
.
merge
(
loader
(
bundledFileHeader
,
bundleLoader
),
bundlesStream
,
otherSourcesStream
,
resourcesStream
,
bundleInfoStream
);
var
result
=
es
.
merge
(
loader
(
src
,
bundledFileHeader
,
bundleLoader
),
bundlesStream
,
otherSourcesStream
,
resourcesStream
,
bundleInfoStream
);
return
result
.
pipe
(
sourcemaps
.
write
(
'
./
'
,
{
sourceRoot
:
null
,
...
...
build/lib/optimize.ts
浏览文件 @
5a52c24f
...
...
@@ -50,21 +50,21 @@ declare class FileSourceMap extends VinylFile {
public
sourceMap
:
sm
.
RawSourceMap
;
}
function
loader
(
bundledFileHeader
:
string
,
bundleLoader
:
boolean
):
NodeJS
.
ReadWriteStream
{
function
loader
(
src
:
string
,
bundledFileHeader
:
string
,
bundleLoader
:
boolean
):
NodeJS
.
ReadWriteStream
{
let
sources
=
[
'
out-build/vs/loader.js
'
`
${
src
}
/vs/loader.js`
];
if
(
bundleLoader
)
{
sources
=
sources
.
concat
([
'
out-build/vs/css.js
'
,
'
out-build/vs/nls.js
'
`
${
src
}
/vs/css.js`
,
`
${
src
}
/vs/nls.js`
]);
}
let
isFirst
=
true
;
return
(
gulp
.
src
(
sources
,
{
base
:
'
out-build
'
})
.
src
(
sources
,
{
base
:
`
${
src
}
`
})
.
pipe
(
es
.
through
(
function
(
data
)
{
if
(
isFirst
)
{
isFirst
=
false
;
...
...
@@ -87,7 +87,7 @@ function loader(bundledFileHeader: string, bundleLoader: boolean): NodeJS.ReadWr
);
}
function
toConcatStream
(
bundledFileHeader
:
string
,
sources
:
bundle
.
IFile
[],
dest
:
string
):
NodeJS
.
ReadWriteStream
{
function
toConcatStream
(
src
:
string
,
bundledFileHeader
:
string
,
sources
:
bundle
.
IFile
[],
dest
:
string
):
NodeJS
.
ReadWriteStream
{
const
useSourcemaps
=
/
\.
js$/
.
test
(
dest
)
&&
!
/
\.
nls
\.
js$/
.
test
(
dest
);
// If a bundle ends up including in any of the sources our copyright, then
...
...
@@ -110,7 +110,7 @@ function toConcatStream(bundledFileHeader: string, sources: bundle.IFile[], dest
const
treatedSources
=
sources
.
map
(
function
(
source
)
{
const
root
=
source
.
path
?
REPO_ROOT_PATH
.
replace
(
/
\\
/g
,
'
/
'
)
:
''
;
const
base
=
source
.
path
?
root
+
'
/out-build
'
:
''
;
const
base
=
source
.
path
?
root
+
`/
${
src
}
`
:
''
;
return
new
VinylFile
({
path
:
source
.
path
?
root
+
'
/
'
+
source
.
path
.
replace
(
/
\\
/g
,
'
/
'
)
:
'
fake
'
,
...
...
@@ -124,13 +124,17 @@ function toConcatStream(bundledFileHeader: string, sources: bundle.IFile[], dest
.
pipe
(
concat
(
dest
));
}
function
toBundleStream
(
bundledFileHeader
:
string
,
bundles
:
bundle
.
IConcatFile
[]):
NodeJS
.
ReadWriteStream
{
function
toBundleStream
(
src
:
string
,
bundledFileHeader
:
string
,
bundles
:
bundle
.
IConcatFile
[]):
NodeJS
.
ReadWriteStream
{
return
es
.
merge
(
bundles
.
map
(
function
(
bundle
)
{
return
toConcatStream
(
bundledFileHeader
,
bundle
.
sources
,
bundle
.
dest
);
return
toConcatStream
(
src
,
bundledFileHeader
,
bundle
.
sources
,
bundle
.
dest
);
}));
}
export
interface
IOptimizeTaskOpts
{
/**
* The folder to read files from.
*/
src
:
string
;
/**
* (for AMD files, will get bundled and get Copyright treatment)
*/
...
...
@@ -167,6 +171,7 @@ export interface IOptimizeTaskOpts {
}
export
function
optimizeTask
(
opts
:
IOptimizeTaskOpts
):
()
=>
NodeJS
.
ReadWriteStream
{
const
src
=
opts
.
src
;
const
entryPoints
=
opts
.
entryPoints
;
const
otherSources
=
opts
.
otherSources
;
const
resources
=
opts
.
resources
;
...
...
@@ -183,7 +188,7 @@ export function optimizeTask(opts: IOptimizeTaskOpts): () => NodeJS.ReadWriteStr
bundle
.
bundle
(
entryPoints
,
loaderConfig
,
function
(
err
,
result
)
{
if
(
err
)
{
return
bundlesStream
.
emit
(
'
error
'
,
JSON
.
stringify
(
err
));
}
toBundleStream
(
bundledFileHeader
,
result
.
files
).
pipe
(
bundlesStream
);
toBundleStream
(
src
,
bundledFileHeader
,
result
.
files
).
pipe
(
bundlesStream
);
// Remove css inlined resources
const
filteredResources
=
resources
.
slice
();
...
...
@@ -193,7 +198,7 @@ export function optimizeTask(opts: IOptimizeTaskOpts): () => NodeJS.ReadWriteStr
}
filteredResources
.
push
(
'
!
'
+
resource
);
});
gulp
.
src
(
filteredResources
,
{
base
:
'
out-build
'
}).
pipe
(
resourcesStream
);
gulp
.
src
(
filteredResources
,
{
base
:
`
${
src
}
`
}).
pipe
(
resourcesStream
);
const
bundleInfoArray
:
VinylFile
[]
=
[];
if
(
opts
.
bundleInfo
)
{
...
...
@@ -209,9 +214,9 @@ export function optimizeTask(opts: IOptimizeTaskOpts): () => NodeJS.ReadWriteStr
const
otherSourcesStream
=
es
.
through
();
const
otherSourcesStreamArr
:
NodeJS
.
ReadWriteStream
[]
=
[];
gulp
.
src
(
otherSources
,
{
base
:
'
out-build
'
})
gulp
.
src
(
otherSources
,
{
base
:
`
${
src
}
`
})
.
pipe
(
es
.
through
(
function
(
data
)
{
otherSourcesStreamArr
.
push
(
toConcatStream
(
bundledFileHeader
,
[
data
],
data
.
relative
));
otherSourcesStreamArr
.
push
(
toConcatStream
(
src
,
bundledFileHeader
,
[
data
],
data
.
relative
));
},
function
()
{
if
(
!
otherSourcesStreamArr
.
length
)
{
setTimeout
(
function
()
{
otherSourcesStream
.
emit
(
'
end
'
);
},
0
);
...
...
@@ -221,7 +226,7 @@ export function optimizeTask(opts: IOptimizeTaskOpts): () => NodeJS.ReadWriteStr
}));
const
result
=
es
.
merge
(
loader
(
bundledFileHeader
,
bundleLoader
),
loader
(
src
,
bundledFileHeader
,
bundleLoader
),
bundlesStream
,
otherSourcesStream
,
resourcesStream
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录