Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
03103a4f
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,发现更多精彩内容 >>
提交
03103a4f
编写于
7月 19, 2018
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add extract-editor-src with treeshaking task
上级
f07a1989
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
1680 addition
and
9 deletion
+1680
-9
.gitignore
.gitignore
+1
-0
build/gulpfile.editor.js
build/gulpfile.editor.js
+28
-1
build/lib/standalone.js
build/lib/standalone.js
+82
-4
build/lib/standalone.ts
build/lib/standalone.ts
+87
-4
build/lib/treeshaking.js
build/lib/treeshaking.js
+676
-0
build/lib/treeshaking.ts
build/lib/treeshaking.ts
+806
-0
未找到文件。
.gitignore
浏览文件 @
03103a4f
...
...
@@ -6,6 +6,7 @@ node_modules/
out/
out-build/
out-editor/
out-editor-src/
out-editor-esm/
out-editor-min/
out-monaco-editor-core/
...
...
build/gulpfile.editor.js
浏览文件 @
03103a4f
...
...
@@ -75,6 +75,33 @@ function editorLoaderConfig() {
const
languages
=
i18n
.
defaultLanguages
.
concat
([]);
// i18n.defaultLanguages.concat(process.env.VSCODE_QUALITY !== 'stable' ? i18n.extraLanguages : []);
gulp
.
task
(
'
clean-editor-src
'
,
util
.
rimraf
(
'
out-editor-src
'
));
gulp
.
task
(
'
extract-editor-src
'
,
[
'
clean-editor-src
'
],
function
()
{
standalone
.
extractEditor
({
sourcesRoot
:
path
.
join
(
root
,
'
src
'
),
entryPoints
:
[
'
vs/editor/editor.main
'
,
'
vs/editor/editor.worker
'
,
// 'user',
// 'user2',
],
libs
:
[
`lib.d.ts`
,
`lib.es2015.collection.d.ts`
],
redirects
:
{
'
vs/base/browser/ui/octiconLabel/octiconLabel
'
:
'
vs/base/browser/ui/octiconLabel/octiconLabel.mock
'
,
},
compilerOptions
:
{
module
:
2
,
// ModuleKind.AMD
// moduleResolution: 'classic'
},
shakeLevel
:
1
,
// 1-InnerFile, 2-ClassMembers
importIgnorePattern
:
/^vs
\/
css!/
,
destRoot
:
path
.
join
(
root
,
'
out-editor-src
'
)
});
});
gulp
.
task
(
'
clean-optimized-editor
'
,
util
.
rimraf
(
'
out-editor
'
));
gulp
.
task
(
'
optimize-editor
'
,
[
'
clean-optimized-editor
'
,
'
compile-client-build
'
],
common
.
optimizeTask
({
entryPoints
:
editorEntryPoints
,
...
...
@@ -229,7 +256,7 @@ gulp.task('editor-distro', ['clean-editor-distro', 'compile-editor-esm', 'minify
});
gulp
.
task
(
'
analyze-editor-distro
'
,
function
()
{
// @ts-ignore
// @ts-ignore
var
bundleInfo
=
require
(
'
../out-editor/bundleInfo.json
'
);
var
graph
=
bundleInfo
.
graph
;
var
bundles
=
bundleInfo
.
bundles
;
...
...
build/lib/standalone.js
浏览文件 @
03103a4f
...
...
@@ -7,9 +7,87 @@ Object.defineProperty(exports, "__esModule", { value: true });
var
ts
=
require
(
"
typescript
"
);
var
fs
=
require
(
"
fs
"
);
var
path
=
require
(
"
path
"
);
var
tss
=
require
(
"
./treeshaking
"
);
var
REPO_ROOT
=
path
.
join
(
__dirname
,
'
../../
'
);
var
SRC_DIR
=
path
.
join
(
REPO_ROOT
,
'
src
'
);
var
OUT_EDITOR
=
path
.
join
(
REPO_ROOT
,
'
out-editor
'
);
var
dirCache
=
{};
function
writeFile
(
filePath
,
contents
)
{
function
ensureDirs
(
dirPath
)
{
if
(
dirCache
[
dirPath
])
{
return
;
}
dirCache
[
dirPath
]
=
true
;
ensureDirs
(
path
.
dirname
(
dirPath
));
if
(
fs
.
existsSync
(
dirPath
))
{
return
;
}
fs
.
mkdirSync
(
dirPath
);
}
ensureDirs
(
path
.
dirname
(
filePath
));
fs
.
writeFileSync
(
filePath
,
contents
);
}
function
extractEditor
(
options
)
{
var
result
=
tss
.
shake
(
options
);
for
(
var
fileName
in
result
)
{
if
(
result
.
hasOwnProperty
(
fileName
))
{
writeFile
(
path
.
join
(
options
.
destRoot
,
fileName
),
result
[
fileName
]);
}
}
var
copied
=
{};
var
copyFile
=
function
(
fileName
)
{
if
(
copied
[
fileName
])
{
return
;
}
copied
[
fileName
]
=
true
;
var
srcPath
=
path
.
join
(
options
.
sourcesRoot
,
fileName
);
var
dstPath
=
path
.
join
(
options
.
destRoot
,
fileName
);
fs
.
writeFileSync
(
dstPath
,
fs
.
readFileSync
(
srcPath
));
};
var
writeOutputFile
=
function
(
fileName
,
contents
)
{
writeFile
(
path
.
join
(
options
.
destRoot
,
fileName
),
contents
);
};
for
(
var
fileName
in
result
)
{
if
(
result
.
hasOwnProperty
(
fileName
))
{
var
fileContents
=
result
[
fileName
];
var
info
=
ts
.
preProcessFile
(
fileContents
);
for
(
var
i
=
info
.
importedFiles
.
length
-
1
;
i
>=
0
;
i
--
)
{
var
importedFileName
=
info
.
importedFiles
[
i
].
fileName
;
var
importedFilePath
=
void
0
;
if
(
/^vs
\/
css!/
.
test
(
importedFileName
))
{
importedFilePath
=
importedFileName
.
substr
(
'
vs/css!
'
.
length
)
+
'
.css
'
;
}
else
{
importedFilePath
=
importedFileName
;
}
if
(
/
(
^
\.\/)
|
(
^
\.\.\/)
/
.
test
(
importedFilePath
))
{
importedFilePath
=
path
.
join
(
path
.
dirname
(
fileName
),
importedFilePath
);
}
if
(
/
\.
css$/
.
test
(
importedFilePath
))
{
transportCSS
(
importedFilePath
,
copyFile
,
writeOutputFile
);
}
else
{
if
(
fs
.
existsSync
(
path
.
join
(
options
.
sourcesRoot
,
importedFilePath
+
'
.js
'
)))
{
copyFile
(
importedFilePath
+
'
.js
'
);
}
}
}
}
}
[
'
tsconfig.json
'
,
'
vs/css.build.js
'
,
'
vs/css.d.ts
'
,
'
vs/css.js
'
,
'
vs/loader.js
'
,
'
vs/monaco.d.ts
'
,
'
vs/nls.build.js
'
,
'
vs/nls.d.ts
'
,
'
vs/nls.js
'
,
'
vs/nls.mock.ts
'
,
].
forEach
(
copyFile
);
}
exports
.
extractEditor
=
extractEditor
;
function
createESMSourcesAndResources
(
options
)
{
var
OUT_FOLDER
=
path
.
join
(
REPO_ROOT
,
options
.
outFolder
);
var
OUT_RESOURCES_FOLDER
=
path
.
join
(
REPO_ROOT
,
options
.
outResourcesFolder
);
...
...
@@ -94,7 +172,7 @@ function createESMSourcesAndResources(options) {
options
.
entryPoints
.
forEach
(
function
(
entryPoint
)
{
return
enqueue
(
entryPoint
);
});
while
(
queue
.
length
>
0
)
{
var
module_1
=
queue
.
shift
();
if
(
transportCSS
(
options
,
module_1
,
enqueue
,
write
))
{
if
(
transportCSS
(
module_1
,
enqueue
,
write
))
{
continue
;
}
if
(
transportResource
(
options
,
module_1
,
enqueue
,
write
))
{
...
...
@@ -171,7 +249,7 @@ function createESMSourcesAndResources(options) {
fs
.
writeFileSync
(
path
.
join
(
OUT_FOLDER
,
'
vs/monaco.d.ts
'
),
monacodts
);
}
exports
.
createESMSourcesAndResources
=
createESMSourcesAndResources
;
function
transportCSS
(
options
,
module
,
enqueue
,
write
)
{
function
transportCSS
(
module
,
enqueue
,
write
)
{
if
(
!
/
\.
css/
.
test
(
module
))
{
return
false
;
}
...
...
@@ -179,10 +257,10 @@ function transportCSS(options, module, enqueue, write) {
var
fileContents
=
fs
.
readFileSync
(
filename
).
toString
();
var
inlineResources
=
'
base64
'
;
// see https://github.com/Microsoft/monaco-editor/issues/148
var
inlineResourcesLimit
=
300000
;
//3000; // see https://github.com/Microsoft/monaco-editor/issues/336
var
newContents
=
_rewriteOrInlineUrls
(
file
name
,
file
Contents
,
inlineResources
===
'
base64
'
,
inlineResourcesLimit
);
var
newContents
=
_rewriteOrInlineUrls
(
fileContents
,
inlineResources
===
'
base64
'
,
inlineResourcesLimit
);
write
(
module
,
newContents
);
return
true
;
function
_rewriteOrInlineUrls
(
originalFileFSPath
,
contents
,
forceBase64
,
inlineByteLimit
)
{
function
_rewriteOrInlineUrls
(
contents
,
forceBase64
,
inlineByteLimit
)
{
return
_replaceURL
(
contents
,
function
(
url
)
{
var
imagePath
=
path
.
join
(
path
.
dirname
(
module
),
url
);
var
fileContents
=
fs
.
readFileSync
(
path
.
join
(
SRC_DIR
,
imagePath
));
...
...
build/lib/standalone.ts
浏览文件 @
03103a4f
...
...
@@ -6,11 +6,94 @@
import
*
as
ts
from
'
typescript
'
;
import
*
as
fs
from
'
fs
'
;
import
*
as
path
from
'
path
'
;
import
*
as
tss
from
'
./treeshaking
'
;
const
REPO_ROOT
=
path
.
join
(
__dirname
,
'
../../
'
);
const
SRC_DIR
=
path
.
join
(
REPO_ROOT
,
'
src
'
);
const
OUT_EDITOR
=
path
.
join
(
REPO_ROOT
,
'
out-editor
'
);
let
dirCache
:
{
[
dir
:
string
]:
boolean
;
}
=
{};
function
writeFile
(
filePath
:
string
,
contents
:
string
):
void
{
function
ensureDirs
(
dirPath
:
string
):
void
{
if
(
dirCache
[
dirPath
])
{
return
;
}
dirCache
[
dirPath
]
=
true
;
ensureDirs
(
path
.
dirname
(
dirPath
));
if
(
fs
.
existsSync
(
dirPath
))
{
return
;
}
fs
.
mkdirSync
(
dirPath
);
}
ensureDirs
(
path
.
dirname
(
filePath
));
fs
.
writeFileSync
(
filePath
,
contents
);
}
export
function
extractEditor
(
options
:
tss
.
ITreeShakingOptions
&
{
destRoot
:
string
}):
void
{
let
result
=
tss
.
shake
(
options
);
for
(
let
fileName
in
result
)
{
if
(
result
.
hasOwnProperty
(
fileName
))
{
writeFile
(
path
.
join
(
options
.
destRoot
,
fileName
),
result
[
fileName
]);
}
}
let
copied
:
{
[
fileName
:
string
]:
boolean
;
}
=
{};
const
copyFile
=
(
fileName
:
string
)
=>
{
if
(
copied
[
fileName
])
{
return
;
}
copied
[
fileName
]
=
true
;
const
srcPath
=
path
.
join
(
options
.
sourcesRoot
,
fileName
);
const
dstPath
=
path
.
join
(
options
.
destRoot
,
fileName
);
fs
.
writeFileSync
(
dstPath
,
fs
.
readFileSync
(
srcPath
));
};
const
writeOutputFile
=
(
fileName
:
string
,
contents
:
string
)
=>
{
writeFile
(
path
.
join
(
options
.
destRoot
,
fileName
),
contents
);
};
for
(
let
fileName
in
result
)
{
if
(
result
.
hasOwnProperty
(
fileName
))
{
const
fileContents
=
result
[
fileName
];
const
info
=
ts
.
preProcessFile
(
fileContents
);
for
(
let
i
=
info
.
importedFiles
.
length
-
1
;
i
>=
0
;
i
--
)
{
const
importedFileName
=
info
.
importedFiles
[
i
].
fileName
;
let
importedFilePath
:
string
;
if
(
/^vs
\/
css!/
.
test
(
importedFileName
))
{
importedFilePath
=
importedFileName
.
substr
(
'
vs/css!
'
.
length
)
+
'
.css
'
;
}
else
{
importedFilePath
=
importedFileName
;
}
if
(
/
(
^
\.\/)
|
(
^
\.\.\/)
/
.
test
(
importedFilePath
))
{
importedFilePath
=
path
.
join
(
path
.
dirname
(
fileName
),
importedFilePath
);
}
if
(
/
\.
css$/
.
test
(
importedFilePath
))
{
transportCSS
(
importedFilePath
,
copyFile
,
writeOutputFile
);
}
else
{
if
(
fs
.
existsSync
(
path
.
join
(
options
.
sourcesRoot
,
importedFilePath
+
'
.js
'
)))
{
copyFile
(
importedFilePath
+
'
.js
'
);
}
}
}
}
}
[
'
tsconfig.json
'
,
'
vs/css.build.js
'
,
'
vs/css.d.ts
'
,
'
vs/css.js
'
,
'
vs/loader.js
'
,
'
vs/monaco.d.ts
'
,
'
vs/nls.build.js
'
,
'
vs/nls.d.ts
'
,
'
vs/nls.js
'
,
'
vs/nls.mock.ts
'
,
].
forEach
(
copyFile
);
}
export
interface
IOptions
{
entryPoints
:
string
[];
outFolder
:
string
;
...
...
@@ -111,7 +194,7 @@ export function createESMSourcesAndResources(options: IOptions): void {
while
(
queue
.
length
>
0
)
{
const
module
=
queue
.
shift
();
if
(
transportCSS
(
options
,
module
,
enqueue
,
write
))
{
if
(
transportCSS
(
module
,
enqueue
,
write
))
{
continue
;
}
if
(
transportResource
(
options
,
module
,
enqueue
,
write
))
{
...
...
@@ -198,7 +281,7 @@ export function createESMSourcesAndResources(options: IOptions): void {
}
function
transportCSS
(
options
:
IOptions
,
module
:
string
,
enqueue
:
(
module
:
string
)
=>
void
,
write
:
(
path
:
string
,
contents
:
string
|
Buffer
)
=>
void
):
boolean
{
function
transportCSS
(
module
:
string
,
enqueue
:
(
module
:
string
)
=>
void
,
write
:
(
path
:
string
,
contents
:
string
|
Buffer
)
=>
void
):
boolean
{
if
(
!
/
\.
css/
.
test
(
module
))
{
return
false
;
...
...
@@ -209,11 +292,11 @@ function transportCSS(options: IOptions, module: string, enqueue: (module: strin
const
inlineResources
=
'
base64
'
;
// see https://github.com/Microsoft/monaco-editor/issues/148
const
inlineResourcesLimit
=
300000
;
//3000; // see https://github.com/Microsoft/monaco-editor/issues/336
const
newContents
=
_rewriteOrInlineUrls
(
file
name
,
file
Contents
,
inlineResources
===
'
base64
'
,
inlineResourcesLimit
);
const
newContents
=
_rewriteOrInlineUrls
(
fileContents
,
inlineResources
===
'
base64
'
,
inlineResourcesLimit
);
write
(
module
,
newContents
);
return
true
;
function
_rewriteOrInlineUrls
(
originalFileFSPath
:
string
,
contents
:
string
,
forceBase64
:
boolean
,
inlineByteLimit
:
number
):
string
{
function
_rewriteOrInlineUrls
(
contents
:
string
,
forceBase64
:
boolean
,
inlineByteLimit
:
number
):
string
{
return
_replaceURL
(
contents
,
(
url
)
=>
{
let
imagePath
=
path
.
join
(
path
.
dirname
(
module
),
url
);
let
fileContents
=
fs
.
readFileSync
(
path
.
join
(
SRC_DIR
,
imagePath
));
...
...
build/lib/treeshaking.js
0 → 100644
浏览文件 @
03103a4f
此差异已折叠。
点击以展开。
build/lib/treeshaking.ts
0 → 100644
浏览文件 @
03103a4f
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录