Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
ace2c229
Unverified
Commit
ace2c229
authored
Jan 28, 2020
by
Jonah Williams
Committed by
GitHub
Jan 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] Generate correct entrypoint module name for experimental web compiler (#49486)
parent
7f715628
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
49 deletions
+53
-49
devfs_web.dart
packages/flutter_tools/lib/src/web/devfs_web.dart
+6
-3
devfs_web_test.dart
.../flutter_tools/test/general.shard/web/devfs_web_test.dart
+47
-46
No files found.
packages/flutter_tools/lib/src/web/devfs_web.dart
View file @
ace2c229
...
@@ -68,7 +68,6 @@ class WebAssetServer {
...
@@ -68,7 +68,6 @@ class WebAssetServer {
// RandomAccessFile and read on demand.
// RandomAccessFile and read on demand.
final
Map
<
String
,
Uint8List
>
_files
=
<
String
,
Uint8List
>{};
final
Map
<
String
,
Uint8List
>
_files
=
<
String
,
Uint8List
>{};
final
Map
<
String
,
Uint8List
>
_sourcemaps
=
<
String
,
Uint8List
>{};
final
Map
<
String
,
Uint8List
>
_sourcemaps
=
<
String
,
Uint8List
>{};
final
RegExp
_drivePath
=
RegExp
(
r'\/[A-Z]:\/'
);
final
RegExp
_drivePath
=
RegExp
(
r'\/[A-Z]:\/'
);
final
Packages
_packages
;
final
Packages
_packages
;
...
@@ -92,6 +91,7 @@ class WebAssetServer {
...
@@ -92,6 +91,7 @@ class WebAssetServer {
await
response
.
close
();
await
response
.
close
();
return
;
return
;
}
}
// TODO(jonahwilliams): better path normalization in frontend_server to remove
// TODO(jonahwilliams): better path normalization in frontend_server to remove
// this workaround.
// this workaround.
String
requestPath
=
request
.
uri
.
path
;
String
requestPath
=
request
.
uri
.
path
;
...
@@ -347,17 +347,20 @@ class WebDevFS implements DevFS {
...
@@ -347,17 +347,20 @@ class WebDevFS implements DevFS {
'web'
,
'web'
,
'dart_stack_trace_mapper.js'
,
'dart_stack_trace_mapper.js'
,
));
));
final
String
entrypoint
=
PackageUriMapper
(
mainPath
,
'.packages'
,
null
,
null
)
.
map
(
mainPath
)
?.
pathSegments
?.
join
(
'/'
);
_webAssetServer
.
writeFile
(
_webAssetServer
.
writeFile
(
'/main.dart.js'
,
'/main.dart.js'
,
generateBootstrapScript
(
generateBootstrapScript
(
requireUrl:
_filePathToUriFragment
(
requireJS
.
path
),
requireUrl:
_filePathToUriFragment
(
requireJS
.
path
),
mapperUrl:
_filePathToUriFragment
(
stackTraceMapper
.
path
),
mapperUrl:
_filePathToUriFragment
(
stackTraceMapper
.
path
),
entrypoint:
'
${_filePathToUriFragment(mainPath)}
.lib.js'
,
entrypoint:
entrypoint
!=
null
?
'/packages/
$entrypoint
.lib.js'
:
'
$mainPath
.lib.js'
,
));
));
_webAssetServer
.
writeFile
(
_webAssetServer
.
writeFile
(
'/main_module.js'
,
'/main_module.js'
,
generateMainModule
(
generateMainModule
(
entrypoint:
'
${_filePathToUriFragment(mainPath)}
.lib.js'
,
entrypoint:
entrypoint
!=
null
?
'/packages/
$entrypoint
.lib.js'
:
'
$mainPath
.lib.js'
,
));
));
_webAssetServer
.
writeFile
(
'/dart_sdk.js'
,
dartSdk
.
readAsStringSync
());
_webAssetServer
.
writeFile
(
'/dart_sdk.js'
,
dartSdk
.
readAsStringSync
());
_webAssetServer
.
writeFile
(
_webAssetServer
.
writeFile
(
...
...
packages/flutter_tools/test/general.shard/web/devfs_web_test.dart
View file @
ace2c229
...
@@ -35,21 +35,23 @@ void main() {
...
@@ -35,21 +35,23 @@ void main() {
MockHttpHeaders
headers
;
MockHttpHeaders
headers
;
Completer
<
void
>
closeCompleter
;
Completer
<
void
>
closeCompleter
;
WebAssetServer
webAssetServer
;
WebAssetServer
webAssetServer
;
MockPlatform
windows
;
MockPlatform
linux
;
MockPlatform
linux
;
Packages
packages
;
Packages
packages
;
MockPlatform
windows
;
setUpAll
(()
async
{
setUpAll
(()
async
{
packages
=
await
loadPackagesFile
(
Uri
.
base
.
resolve
(
'.packages'
));
packages
=
await
loadPackagesFile
(
Uri
.
base
.
resolve
(
'.packages'
),
loader:
(
Uri
uri
)
async
{
return
utf8
.
encode
(
'
\n
'
);
});
});
});
setUp
(()
{
setUp
(()
{
windows
=
MockPlatform
();
linux
=
MockPlatform
();
linux
=
MockPlatform
();
when
(
windows
.
environment
).
thenReturn
(
const
<
String
,
String
>{});
windows
=
MockPlatform
();
when
(
windows
.
isWindows
).
thenReturn
(
true
);
when
(
linux
.
isWindows
).
thenReturn
(
false
);
when
(
linux
.
isWindows
).
thenReturn
(
false
);
when
(
linux
.
environment
).
thenReturn
(
const
<
String
,
String
>{});
when
(
linux
.
environment
).
thenReturn
(
const
<
String
,
String
>{});
when
(
windows
.
environment
).
thenReturn
(
const
<
String
,
String
>{});
when
(
windows
.
isWindows
).
thenReturn
(
true
);
testbed
=
Testbed
(
setup:
()
{
testbed
=
Testbed
(
setup:
()
{
mockHttpServer
=
MockHttpServer
();
mockHttpServer
=
MockHttpServer
();
requestController
=
StreamController
<
HttpRequest
>.
broadcast
();
requestController
=
StreamController
<
HttpRequest
>.
broadcast
();
...
@@ -139,29 +141,6 @@ void main() {
...
@@ -139,29 +141,6 @@ void main() {
Platform:
()
=>
linux
,
Platform:
()
=>
linux
,
}));
}));
test
(
'serves JavaScript files from in memory cache on Windows'
,
()
=>
testbed
.
run
(()
async
{
final
File
source
=
globals
.
fs
.
file
(
'source'
)
..
writeAsStringSync
(
'main() {}'
);
final
File
sourcemap
=
globals
.
fs
.
file
(
'sourcemap'
)
..
writeAsStringSync
(
'{}'
);
final
File
manifest
=
globals
.
fs
.
file
(
'manifest'
)
..
writeAsStringSync
(
json
.
encode
(<
String
,
Object
>{
'/C:/foo.js'
:
<
String
,
Object
>{
'code'
:
<
int
>[
0
,
source
.
lengthSync
()],
'sourcemap'
:
<
int
>[
0
,
2
],
}}));
webAssetServer
.
write
(
source
,
manifest
,
sourcemap
);
when
(
request
.
uri
).
thenReturn
(
Uri
.
parse
(
'http://foobar/C:/foo.js'
));
requestController
.
add
(
request
);
await
closeCompleter
.
future
;
verify
(
headers
.
add
(
'Content-Length'
,
source
.
lengthSync
())).
called
(
1
);
verify
(
headers
.
add
(
'Content-Type'
,
'application/javascript'
)).
called
(
1
);
verify
(
response
.
add
(
source
.
readAsBytesSync
())).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
windows
,
}));
test
(
'serves JavaScript files from in memory cache not from manifest'
,
()
=>
testbed
.
run
(()
async
{
test
(
'serves JavaScript files from in memory cache not from manifest'
,
()
=>
testbed
.
run
(()
async
{
webAssetServer
.
writeFile
(
'/foo.js'
,
'main() {}'
);
webAssetServer
.
writeFile
(
'/foo.js'
,
'main() {}'
);
...
@@ -193,6 +172,29 @@ void main() {
...
@@ -193,6 +172,29 @@ void main() {
verify
(
response
.
statusCode
=
404
).
called
(
1
);
verify
(
response
.
statusCode
=
404
).
called
(
1
);
}));
}));
test
(
'serves JavaScript files from in memory cache on Windows'
,
()
=>
testbed
.
run
(()
async
{
final
File
source
=
globals
.
fs
.
file
(
'source'
)
..
writeAsStringSync
(
'main() {}'
);
final
File
sourcemap
=
globals
.
fs
.
file
(
'sourcemap'
)
..
writeAsStringSync
(
'{}'
);
final
File
manifest
=
globals
.
fs
.
file
(
'manifest'
)
..
writeAsStringSync
(
json
.
encode
(<
String
,
Object
>{
'/C:/foo.js'
:
<
String
,
Object
>{
'code'
:
<
int
>[
0
,
source
.
lengthSync
()],
'sourcemap'
:
<
int
>[
0
,
2
],
}}));
webAssetServer
.
write
(
source
,
manifest
,
sourcemap
);
when
(
request
.
uri
).
thenReturn
(
Uri
.
parse
(
'http://foobar/C:/foo.js'
));
requestController
.
add
(
request
);
await
closeCompleter
.
future
;
verify
(
headers
.
add
(
'Content-Length'
,
source
.
lengthSync
())).
called
(
1
);
verify
(
headers
.
add
(
'Content-Type'
,
'application/javascript'
)).
called
(
1
);
verify
(
response
.
add
(
source
.
readAsBytesSync
())).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
windows
,
}));
test
(
'serves Dart files from in filesystem on Windows'
,
()
=>
testbed
.
run
(()
async
{
test
(
'serves Dart files from in filesystem on Windows'
,
()
=>
testbed
.
run
(()
async
{
final
File
source
=
globals
.
fs
.
file
(
'foo.dart'
).
absolute
final
File
source
=
globals
.
fs
.
file
(
'foo.dart'
).
absolute
..
createSync
(
recursive:
true
)
..
createSync
(
recursive:
true
)
...
@@ -208,6 +210,22 @@ void main() {
...
@@ -208,6 +210,22 @@ void main() {
Platform:
()
=>
windows
,
Platform:
()
=>
windows
,
}));
}));
test
(
'serves asset files from in filesystem with known mime type on Windows'
,
()
=>
testbed
.
run
(()
async
{
final
File
source
=
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'build'
,
'flutter_assets'
,
'foo.png'
))
..
createSync
(
recursive:
true
)
..
writeAsBytesSync
(
kTransparentImage
);
when
(
request
.
uri
).
thenReturn
(
Uri
.
parse
(
'http://foobar/assets/foo.png'
));
requestController
.
add
(
request
);
await
closeCompleter
.
future
;
verify
(
headers
.
add
(
'Content-Length'
,
source
.
lengthSync
())).
called
(
1
);
verify
(
headers
.
add
(
'Content-Type'
,
'image/png'
)).
called
(
1
);
verify
(
response
.
addStream
(
any
)).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
windows
,
}));
test
(
'serves Dart files from in filesystem on Linux/macOS'
,
()
=>
testbed
.
run
(()
async
{
test
(
'serves Dart files from in filesystem on Linux/macOS'
,
()
=>
testbed
.
run
(()
async
{
final
File
source
=
globals
.
fs
.
file
(
'foo.dart'
).
absolute
final
File
source
=
globals
.
fs
.
file
(
'foo.dart'
).
absolute
..
createSync
(
recursive:
true
)
..
createSync
(
recursive:
true
)
...
@@ -245,23 +263,6 @@ void main() {
...
@@ -245,23 +263,6 @@ void main() {
verify
(
response
.
addStream
(
any
)).
called
(
1
);
verify
(
response
.
addStream
(
any
)).
called
(
1
);
}));
}));
test
(
'serves asset files from in filesystem with known mime type on Windows'
,
()
=>
testbed
.
run
(()
async
{
final
File
source
=
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'build'
,
'flutter_assets'
,
'foo.png'
))
..
createSync
(
recursive:
true
)
..
writeAsBytesSync
(
kTransparentImage
);
when
(
request
.
uri
).
thenReturn
(
Uri
.
parse
(
'http://foobar/assets/foo.png'
));
requestController
.
add
(
request
);
await
closeCompleter
.
future
;
verify
(
headers
.
add
(
'Content-Length'
,
source
.
lengthSync
())).
called
(
1
);
verify
(
headers
.
add
(
'Content-Type'
,
'image/png'
)).
called
(
1
);
verify
(
response
.
addStream
(
any
)).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
windows
,
}));
test
(
'serves asset files files from in filesystem with unknown mime type and length > 12'
,
()
=>
testbed
.
run
(()
async
{
test
(
'serves asset files files from in filesystem with unknown mime type and length > 12'
,
()
=>
testbed
.
run
(()
async
{
final
File
source
=
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'build'
,
'flutter_assets'
,
'foo'
))
final
File
source
=
globals
.
fs
.
file
(
globals
.
fs
.
path
.
join
(
'build'
,
'flutter_assets'
,
'foo'
))
..
createSync
(
recursive:
true
)
..
createSync
(
recursive:
true
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment