Unverified Commit 60d0fef1 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] move stack_trace_mapper and require.js into memory file system (#52276)

parent 4ce34f25
......@@ -511,14 +511,16 @@ class WebDevFS implements DevFS {
if (bundleFirstUpload) {
generator.addFileSystemRoot(outputDirectoryPath);
final String entrypoint = globals.fs.path.basename(mainPath);
webAssetServer.writeFile('/require.js', requireJS.readAsStringSync());
webAssetServer.writeFile('/dart_stack_trace_mapper.js', stackTraceMapper.readAsStringSync());
webAssetServer.writeFile('/$entrypoint', globals.fs.file(mainPath).readAsStringSync());
webAssetServer.writeFile('/manifest.json', '{"info":"manifest not generated in run mode."}');
webAssetServer.writeFile('/flutter_service_worker.js', '// Service worker not loaded in run mode.');
webAssetServer.writeFile(
'/main.dart.js',
generateBootstrapScript(
requireUrl: _filePathToUriFragment(requireJS.path),
mapperUrl: _filePathToUriFragment(stackTraceMapper.path),
requireUrl: '/require.js',
mapperUrl: '/dart_stack_trace_mapper.js',
entrypoint: '/$entrypoint.lib.js',
),
);
......@@ -605,19 +607,6 @@ class WebDevFS implements DevFS {
));
}
String _filePathToUriFragment(String path) {
if (globals.platform.isWindows) {
final bool startWithSlash = path.startsWith('/');
final String partial =
globals.fs.path.split(path).skip(startWithSlash ? 2 : 1).join('/');
if (partial.startsWith('/')) {
return partial;
}
return '/$partial';
}
return path;
}
class ReleaseAssetServer {
ReleaseAssetServer(this.entrypoint);
......
......@@ -367,6 +367,8 @@ void main() {
invalidatedFiles: <Uri>[],
);
expect(webDevFS.webAssetServer.getFile('/require.js'), isNotNull);
expect(webDevFS.webAssetServer.getFile('/dart_stack_trace_mapper.js'), isNotNull);
expect(webDevFS.webAssetServer.getFile('/main.dart'), isNotNull);
expect(webDevFS.webAssetServer.getFile('/manifest.json'), isNotNull);
expect(webDevFS.webAssetServer.getFile('/flutter_service_worker.js'), isNotNull);
......
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