Unverified Commit 06348522 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

workaround for mangled web sdk source map packages (#39774)

parent 64424a6a
......@@ -262,7 +262,7 @@ class WebFs {
return Response.ok(file.readAsBytesSync(), headers: <String, String>{
'Content-Type': 'text/javascript',
});
} else if (request.url.path.contains('dart_sdk')) {
} else if (request.url.path.endsWith('dart_sdk.js')) {
final File file = fs.file(fs.path.join(
artifacts.getArtifactPath(Artifact.flutterWebSdk),
'kernel',
......@@ -272,12 +272,29 @@ class WebFs {
return Response.ok(file.readAsBytesSync(), headers: <String, String>{
'Content-Type': 'text/javascript',
});
} else if (request.url.path.endsWith('dart_sdk.js.map')) {
final File file = fs.file(fs.path.join(
artifacts.getArtifactPath(Artifact.flutterWebSdk),
'kernel',
'amd',
'dart_sdk.js.map',
));
return Response.ok(file.readAsBytesSync());
} else if (request.url.path.endsWith('.dart')) {
// This is likely a sourcemap request. The first segment is the
// package name, and the rest is the path to the file relative to
// the package uri. For example, `foo/bar.dart` would represent a
// file at a path like `foo/lib/bar.dart`. If there is no leading
// segment, then we assume it is from the current package.
// Handle sdk requests that have mangled urls from engine build.
if (request.url.path.contains('flutter_web_sdk')) {
// Note: the request is a uri and not a file path, so they always use `/`.
final String sdkPath = fs.path.joinAll(request.url.path.split('flutter_web_sdk/').last.split('/'));
final String webSdkPath = artifacts.getArtifactPath(Artifact.flutterWebSdk);
return Response.ok(fs.file(fs.path.join(webSdkPath, sdkPath)).readAsBytesSync());
}
final String packageName = request.url.pathSegments.length == 1
? flutterProject.manifest.appName
: request.url.pathSegments.first;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment