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