Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
deno
提交
c1b302d7
D
deno
项目概览
张重言
/
deno
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
deno
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c1b302d7
编写于
10月 17, 2019
作者:
Y
Yusuke Sakurai
提交者:
Ryan Dahl
10月 16, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: remote jsx/tsx files were compiled as js/ts (#3125)
上级
59835072
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
194 addition
and
7 deletion
+194
-7
cli/file_fetcher.rs
cli/file_fetcher.rs
+97
-7
cli/tests/048_media_types_jsx.ts
cli/tests/048_media_types_jsx.ts
+23
-0
cli/tests/048_media_types_jsx.ts.out
cli/tests/048_media_types_jsx.ts.out
+1
-0
cli/tests/049_info_flag_script_jsx.out
cli/tests/049_info_flag_script_jsx.out
+14
-0
cli/tests/integration_tests.rs
cli/tests/integration_tests.rs
+12
-0
cli/tests/subdir/mt_application_ecmascript_jsx.j2.jsx
cli/tests/subdir/mt_application_ecmascript_jsx.j2.jsx
+5
-0
cli/tests/subdir/mt_application_x_javascript_jsx.j4.jsx
cli/tests/subdir/mt_application_x_javascript_jsx.j4.jsx
+5
-0
cli/tests/subdir/mt_application_x_typescript_tsx.t4.tsx
cli/tests/subdir/mt_application_x_typescript_tsx.t4.tsx
+5
-0
cli/tests/subdir/mt_javascript_jsx.jsx
cli/tests/subdir/mt_javascript_jsx.jsx
+5
-0
cli/tests/subdir/mt_text_ecmascript_jsx.j3.jsx
cli/tests/subdir/mt_text_ecmascript_jsx.j3.jsx
+5
-0
cli/tests/subdir/mt_text_javascript_jsx.j1.jsx
cli/tests/subdir/mt_text_javascript_jsx.j1.jsx
+5
-0
cli/tests/subdir/mt_text_typescript_tsx.t1.tsx
cli/tests/subdir/mt_text_typescript_tsx.t1.tsx
+5
-0
cli/tests/subdir/mt_video_mp2t_tsx.t3.tsx
cli/tests/subdir/mt_video_mp2t_tsx.t3.tsx
+5
-0
cli/tests/subdir/mt_video_vdn_tsx.t2.tsx
cli/tests/subdir/mt_video_vdn_tsx.t2.tsx
+5
-0
tools/http_server.py
tools/http_server.py
+2
-0
未找到文件。
cli/file_fetcher.rs
浏览文件 @
c1b302d7
...
...
@@ -505,12 +505,16 @@ fn map_content_type(path: &Path, content_type: Option<&str>) -> msg::MediaType {
|
"text/typescript"
|
"video/vnd.dlna.mpeg-tts"
|
"video/mp2t"
|
"application/x-typescript"
=>
msg
::
MediaType
::
TypeScript
,
|
"application/x-typescript"
=>
{
map_js_like_extension
(
path
,
msg
::
MediaType
::
TypeScript
)
}
"application/javascript"
|
"text/javascript"
|
"application/ecmascript"
|
"text/ecmascript"
|
"application/x-javascript"
=>
msg
::
MediaType
::
JavaScript
,
|
"application/x-javascript"
=>
{
map_js_like_extension
(
path
,
msg
::
MediaType
::
JavaScript
)
}
"application/json"
|
"text/json"
=>
msg
::
MediaType
::
Json
,
"text/plain"
=>
map_file_extension
(
path
),
_
=>
{
...
...
@@ -523,6 +527,21 @@ fn map_content_type(path: &Path, content_type: Option<&str>) -> msg::MediaType {
}
}
fn
map_js_like_extension
(
path
:
&
Path
,
default
:
msg
::
MediaType
,
)
->
msg
::
MediaType
{
match
path
.extension
()
{
None
=>
default
,
Some
(
os_str
)
=>
match
os_str
.to_str
()
{
None
=>
default
,
Some
(
"jsx"
)
=>
msg
::
MediaType
::
JSX
,
Some
(
"tsx"
)
=>
msg
::
MediaType
::
TSX
,
Some
(
_
)
=>
default
,
},
}
}
fn
filter_shebang
(
bytes
:
Vec
<
u8
>
)
->
Vec
<
u8
>
{
let
string
=
str
::
from_utf8
(
&
bytes
)
.unwrap
();
if
let
Some
(
i
)
=
string
.find
(
'\n'
)
{
...
...
@@ -1410,7 +1429,7 @@ mod tests {
}
#[test]
fn
test_map_content_type
()
{
fn
test_map_content_type
_extension_only
()
{
// Extension only
assert_eq!
(
map_content_type
(
Path
::
new
(
"foo/bar.ts"
),
None
),
...
...
@@ -1428,6 +1447,10 @@ mod tests {
map_content_type
(
Path
::
new
(
"foo/bar.js"
),
None
),
msg
::
MediaType
::
JavaScript
);
assert_eq!
(
map_content_type
(
Path
::
new
(
"foo/bar.txt"
),
None
),
msg
::
MediaType
::
Unknown
);
assert_eq!
(
map_content_type
(
Path
::
new
(
"foo/bar.jsx"
),
None
),
msg
::
MediaType
::
JSX
...
...
@@ -1436,15 +1459,14 @@ mod tests {
map_content_type
(
Path
::
new
(
"foo/bar.json"
),
None
),
msg
::
MediaType
::
Json
);
assert_eq!
(
map_content_type
(
Path
::
new
(
"foo/bar.txt"
),
None
),
msg
::
MediaType
::
Unknown
);
assert_eq!
(
map_content_type
(
Path
::
new
(
"foo/bar"
),
None
),
msg
::
MediaType
::
Unknown
);
}
#[test]
fn
test_map_content_type_media_type_with_no_extension
()
{
// Media Type
assert_eq!
(
map_content_type
(
Path
::
new
(
"foo/bar"
),
Some
(
"application/typescript"
)),
...
...
@@ -1494,6 +1516,10 @@ mod tests {
map_content_type
(
Path
::
new
(
"foo/bar"
),
Some
(
"text/json"
)),
msg
::
MediaType
::
Json
);
}
#[test]
fn
test_map_file_extension_media_type_with_extension
()
{
assert_eq!
(
map_content_type
(
Path
::
new
(
"foo/bar.ts"
),
Some
(
"text/plain"
)),
msg
::
MediaType
::
TypeScript
...
...
@@ -1502,6 +1528,70 @@ mod tests {
map_content_type
(
Path
::
new
(
"foo/bar.ts"
),
Some
(
"foo/bar"
)),
msg
::
MediaType
::
Unknown
);
assert_eq!
(
map_content_type
(
Path
::
new
(
"foo/bar.tsx"
),
Some
(
"application/typescript"
)
),
msg
::
MediaType
::
TSX
);
assert_eq!
(
map_content_type
(
Path
::
new
(
"foo/bar.tsx"
),
Some
(
"application/javascript"
)
),
msg
::
MediaType
::
TSX
);
assert_eq!
(
map_content_type
(
Path
::
new
(
"foo/bar.tsx"
),
Some
(
"application/x-typescript"
)
),
msg
::
MediaType
::
TSX
);
assert_eq!
(
map_content_type
(
Path
::
new
(
"foo/bar.tsx"
),
Some
(
"video/vnd.dlna.mpeg-tts"
)
),
msg
::
MediaType
::
TSX
);
assert_eq!
(
map_content_type
(
Path
::
new
(
"foo/bar.tsx"
),
Some
(
"video/mp2t"
)),
msg
::
MediaType
::
TSX
);
assert_eq!
(
map_content_type
(
Path
::
new
(
"foo/bar.jsx"
),
Some
(
"application/javascript"
)
),
msg
::
MediaType
::
JSX
);
assert_eq!
(
map_content_type
(
Path
::
new
(
"foo/bar.jsx"
),
Some
(
"application/x-typescript"
)
),
msg
::
MediaType
::
JSX
);
assert_eq!
(
map_content_type
(
Path
::
new
(
"foo/bar.jsx"
),
Some
(
"application/ecmascript"
)
),
msg
::
MediaType
::
JSX
);
assert_eq!
(
map_content_type
(
Path
::
new
(
"foo/bar.jsx"
),
Some
(
"text/ecmascript"
)),
msg
::
MediaType
::
JSX
);
assert_eq!
(
map_content_type
(
Path
::
new
(
"foo/bar.jsx"
),
Some
(
"application/x-javascript"
)
),
msg
::
MediaType
::
JSX
);
}
#[test]
...
...
cli/tests/048_media_types_jsx.ts
0 → 100644
浏览文件 @
c1b302d7
// When run against the test HTTP server, it will serve different media types
// based on the URL containing `.t#.` strings, which exercises the different
// mapping of media types end to end.
import
{
loaded
as
loadedTsx1
}
from
"
http://localhost:4545/cli/tests/subdir/mt_text_typescript_tsx.t1.tsx
"
;
import
{
loaded
as
loadedTsx2
}
from
"
http://localhost:4545/cli/tests/subdir/mt_video_vdn_tsx.t2.tsx
"
;
import
{
loaded
as
loadedTsx3
}
from
"
http://localhost:4545/cli/tests/subdir/mt_video_mp2t_tsx.t3.tsx
"
;
import
{
loaded
as
loadedTsx4
}
from
"
http://localhost:4545/cli/tests/subdir/mt_application_x_typescript_tsx.t4.tsx
"
;
import
{
loaded
as
loadedJsx1
}
from
"
http://localhost:4545/cli/tests/subdir/mt_text_javascript_jsx.j1.jsx
"
;
import
{
loaded
as
loadedJsx2
}
from
"
http://localhost:4545/cli/tests/subdir/mt_application_ecmascript_jsx.j2.jsx
"
;
import
{
loaded
as
loadedJsx3
}
from
"
http://localhost:4545/cli/tests/subdir/mt_text_ecmascript_jsx.j3.jsx
"
;
import
{
loaded
as
loadedJsx4
}
from
"
http://localhost:4545/cli/tests/subdir/mt_application_x_javascript_jsx.j4.jsx
"
;
console
.
log
(
"
success
"
,
loadedTsx1
,
loadedTsx2
,
loadedTsx3
,
loadedTsx4
,
loadedJsx1
,
loadedJsx2
,
loadedJsx3
,
loadedJsx4
);
cli/tests/048_media_types_jsx.ts.out
0 → 100644
浏览文件 @
c1b302d7
success true true true true true true true true
cli/tests/049_info_flag_script_jsx.out
0 → 100644
浏览文件 @
c1b302d7
local: [WILDCARD]048_media_types_jsx.ts
type: TypeScript
compiled: [WILDCARD]048_media_types_jsx.ts.js
map: [WILDCARD]048_media_types_jsx.ts.js.map
deps:
http://127.0.0.1:4545/cli/tests/048_media_types_jsx.ts
├── http://localhost:4545/cli/tests/subdir/mt_text_typescript_tsx.t1.tsx
├── http://localhost:4545/cli/tests/subdir/mt_video_vdn_tsx.t2.tsx
├── http://localhost:4545/cli/tests/subdir/mt_video_mp2t_tsx.t3.tsx
├── http://localhost:4545/cli/tests/subdir/mt_application_x_typescript_tsx.t4.tsx
├── http://localhost:4545/cli/tests/subdir/mt_text_javascript_jsx.j1.jsx
├── http://localhost:4545/cli/tests/subdir/mt_application_ecmascript_jsx.j2.jsx
├── http://localhost:4545/cli/tests/subdir/mt_text_ecmascript_jsx.j3.jsx
└── http://localhost:4545/cli/tests/subdir/mt_application_x_javascript_jsx.j4.jsx
cli/tests/integration_tests.rs
浏览文件 @
c1b302d7
...
...
@@ -326,6 +326,18 @@ itest!(_047_jsx {
output
:
"047_jsx_test.jsx.out"
,
});
itest!
(
_048_
media_types_jsx
{
args
:
"run --reload 048_media_types_jsx.ts"
,
output
:
"048_media_types_jsx.ts.out"
,
http_server
:
true
,
});
itest!
(
_049_
info_flag_script_jsx
{
args
:
"info http://127.0.0.1:4545/cli/tests/048_media_types_jsx.ts"
,
output
:
"049_info_flag_script_jsx.out"
,
http_server
:
true
,
});
itest!
(
async_error
{
exit_code
:
1
,
args
:
"run --reload async_error.ts"
,
...
...
cli/tests/subdir/mt_application_ecmascript_jsx.j2.jsx
0 → 100644
浏览文件 @
c1b302d7
const
React
=
{
createElement
()
{}
}
const
temp
=
<
div
></
div
>;
export
const
loaded
=
true
;
cli/tests/subdir/mt_application_x_javascript_jsx.j4.jsx
0 → 100644
浏览文件 @
c1b302d7
const
React
=
{
createElement
()
{}
}
const
temp
=
<
div
></
div
>;
export
const
loaded
=
true
;
cli/tests/subdir/mt_application_x_typescript_tsx.t4.tsx
0 → 100644
浏览文件 @
c1b302d7
const
React
=
{
createElement
()
{}
}
const
temp
=
<
div
></
div
>;
export
const
loaded
=
true
;
cli/tests/subdir/mt_javascript_jsx.jsx
0 → 100644
浏览文件 @
c1b302d7
const
React
=
{
createElement
()
{}
}
const
temp
=
<
div
></
div
>;
export
const
loaded
=
true
;
cli/tests/subdir/mt_text_ecmascript_jsx.j3.jsx
0 → 100644
浏览文件 @
c1b302d7
const
React
=
{
createElement
()
{}
}
const
temp
=
<
div
></
div
>;
export
const
loaded
=
true
;
cli/tests/subdir/mt_text_javascript_jsx.j1.jsx
0 → 100644
浏览文件 @
c1b302d7
const
React
=
{
createElement
()
{}
}
const
temp
=
<
div
></
div
>;
export
const
loaded
=
true
;
cli/tests/subdir/mt_text_typescript_tsx.t1.tsx
0 → 100644
浏览文件 @
c1b302d7
const
React
=
{
createElement
()
{}
}
const
temp
=
<
div
></
div
>;
export
const
loaded
=
true
;
cli/tests/subdir/mt_video_mp2t_tsx.t3.tsx
0 → 100644
浏览文件 @
c1b302d7
const
React
=
{
createElement
()
{}
}
const
temp
=
<
div
></
div
>;
export
const
loaded
=
true
;
cli/tests/subdir/mt_video_vdn_tsx.t2.tsx
0 → 100644
浏览文件 @
c1b302d7
const
React
=
{
createElement
()
{}
}
const
temp
=
<
div
></
div
>;
export
const
loaded
=
true
;
tools/http_server.py
浏览文件 @
c1b302d7
...
...
@@ -111,6 +111,8 @@ def server():
Handler
.
extensions_map
.
update
({
".ts"
:
"application/typescript"
,
".js"
:
"application/javascript"
,
".tsx"
:
"application/typescript"
,
".jsx"
:
"application/javascript"
,
".json"
:
"application/json"
,
})
SocketServer
.
TCPServer
.
allow_reuse_address
=
True
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录