[flutter_tools] Generate correct entrypoint module name for experimental web compiler (#49486)

This commit is contained in:
Jonah Williams
2020-01-27 17:41:29 -08:00
committed by GitHub
parent 7f715628b0
commit ace2c2297f
2 changed files with 53 additions and 49 deletions

View File

@@ -68,7 +68,6 @@ class WebAssetServer {
// RandomAccessFile and read on demand.
final Map<String, Uint8List> _files = <String, Uint8List>{};
final Map<String, Uint8List> _sourcemaps = <String, Uint8List>{};
final RegExp _drivePath = RegExp(r'\/[A-Z]:\/');
final Packages _packages;
@@ -92,6 +91,7 @@ class WebAssetServer {
await response.close();
return;
}
// TODO(jonahwilliams): better path normalization in frontend_server to remove
// this workaround.
String requestPath = request.uri.path;
@@ -347,17 +347,20 @@ class WebDevFS implements DevFS {
'web',
'dart_stack_trace_mapper.js',
));
final String entrypoint = PackageUriMapper(mainPath, '.packages', null, null)
.map(mainPath)
?.pathSegments?.join('/');
_webAssetServer.writeFile(
'/main.dart.js',
generateBootstrapScript(
requireUrl: _filePathToUriFragment(requireJS.path),
mapperUrl: _filePathToUriFragment(stackTraceMapper.path),
entrypoint: '${_filePathToUriFragment(mainPath)}.lib.js',
entrypoint: entrypoint != null ? '/packages/$entrypoint.lib.js' : '$mainPath.lib.js',
));
_webAssetServer.writeFile(
'/main_module.js',
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(