Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@mdebbar
Copy link
Contributor

@mdebbar mdebbar commented Apr 13, 2021

By splitting the engine into smaller libs, we get much faster interactions with the IDE. Things like auto-suggestion and go-to-definition are too slow because the engine is single monolithic library.

This PR includes the tooling changes that make it possible to split the engine. It also migrates several files as a proof-of-concept, and to serve as an example for future migrations.

flutter/flutter#80755

@mdebbar mdebbar added the platform-web Code specifically for the web engine label Apr 13, 2021
@google-cla google-cla bot added the cla: yes label Apr 13, 2021
@jonahwilliams
Copy link
Contributor

I suppose if it builds, you know it works :)

How much more do you think you'd be adding onto the SDK rewriter? If it still needs more work, consider adding unit testability for the more complicated find/replace rules

Comment on lines +36 to +43
import 'engine/navigation/history.dart';
export 'engine/navigation/history.dart';

import 'engine/navigation/js_url_strategy.dart';
export 'engine/navigation/js_url_strategy.dart';

import 'engine/navigation/url_strategy.dart';
export 'engine/navigation/url_strategy.dart';
Copy link
Member

@ditman ditman Apr 13, 2021

Choose a reason for hiding this comment

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

Something that might make this files slightly more compact (but still maintaining modularity), is to make a engine/navigation/navigation.dart that exports everything it needs to export from within the navigation "sub-package".

That way, in this more global package, you just need to do: export engine/navigation/navigation.dart.

If you prefer to have more control, you can then show only what's really part of the public API of the engine, vs what navigation was available to engine programmers.

We've done this here, for example:

And then, from the google maps, only reexport (via a show) what we explicitly want end users to see from the package above:

(Note that the last link still has two part'ed files, because there's a cross-dependency between them! :P)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense! I'll do this.

import 'package:ui/src/engine/navigation/url_strategy.dart';
import 'package:ui/src/engine/services/message_codec.dart';
import 'package:ui/src/engine/services/message_codecs.dart';
import 'package:ui/src/engine/test_embedding.dart';
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't engine.dart already re-export everything?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's like a framework test importing the entire flutter package. Why?

I think grouping them in navigation/navigation.dart and services/services.dart like @ditman suggested makes sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

But import 'package:ui/src/engine.dart' show window; is still there, so using show and then importing individual parts seems redundant.

}
}

final RegExp _dartLangVersion = RegExp(r'\n// @dart = (.*)');
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove language version specifiers now? /cc @jonahwilliams

Copy link
Contributor

Choose a reason for hiding this comment

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

For the package version you can opt in at the SDK constraint level. I'm not sure if we need to do anything else for the SDK version

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jonahwilliams so I just bump sdk constraint from >=2.12.0-0 <3.0.0 to >=2.13.0-0 <3.0.0, and remove the dart language comments? Or is there another specific sdk version I should use?

} else {
// The file doesn't have a dart language version, so we just insert the part
// directive at the beginning.
source = 'part of engine;\n' + source;
Copy link
Contributor

Choose a reason for hiding this comment

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

It's strange that some files don't have the language version. Can we make them all consistent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All files have the language version. They can't not have it. The build would fail. But I was trying to write the code assuming we may remove language versions at some point.

import '../ui.dart' as ui;

part 'engine/alarm_clock.dart';
import 'engine/alarm_clock.dart';
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 leave a comment that explains how this file is pre-processed and point to the sdk_rewriter.dart

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes platform-web Code specifically for the web engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants