Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FrontendServerAssetReader #871

Merged
merged 3 commits into from
Jan 21, 2020
Merged

FrontendServerAssetReader #871

merged 3 commits into from
Jan 21, 2020

Conversation

grouma
Copy link
Member

@grouma grouma commented Jan 17, 2020

  • Start building out FrontendServerAssetReader for use with the Frontend Server

Towards #865

@grouma grouma requested a review from jakemac53 January 17, 2020 21:11
@grouma
Copy link
Member Author

grouma commented Jan 17, 2020

cc @jonahwilliams

@@ -1,6 +1,7 @@
## 1.0.0-dev

- Remove dependency on `package:build_daemon`.
- Add 'FrontendServerAssetReader` for use with Frontend Server builds.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unmatched quotes


bool _haveReadOriginals = false;

/// Creates a `FrotnendServerAssetReader`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[FrontendServerAssetReader]

_jsonIncremental = File('$outputPath.incremental.json');

@override
Future<String> dartSourceContents(String serverPath) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually interesting..... this wouldn't be anything specific to the frontend_server.

At the same time we will want an identical abstraction to this one which knows how to serve the JS files.

This class should probably extend an abstract DartSourceAssetReader blass which reads from the FS using a package resolver.

And then this file should also add an additional jsFileContents(String serverPath) method which we can plug into our server in webdev.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we want to go with the base class approach. I think we'd want to delegate to a DartSourceAssetReader or something. I'll cross that hump when I get there though.

Future<void> updateCaches() async {
if (!_haveReadOriginals) {
await _updateCaches(_mapOriginal, _jsonOriginal);
_haveReadOriginals = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to an if else

}

Future<void> _updateCaches(File map, File json) async {
if (!(await map.exists() && await json.exists())) return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should consider throwing here (or logging an error at least)

File mapOriginal;

Future<void> _createTempFixtures() async {
var fixtures = p.absolute(p.relative('test/fixtures', from: p.current));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need any of the p.absolute(p.relative( here. But you should do p.join('test', 'fixtures').

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is required for Windows testing? It's the pattern we do for the other fixtures, hence why I copied it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't be necessary, this is just getting passed to a normal File constructor.

dwds/test/readers/frontend_server_asset_reader_test.dart Outdated Show resolved Hide resolved
dwds/test/readers/frontend_server_asset_reader_test.dart Outdated Show resolved Hide resolved
@grouma grouma merged commit 9ff6626 into master Jan 21, 2020
@grouma grouma deleted the frontend-server branch January 21, 2020 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants