Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(635)

Unified Diff: pkg/dev_compiler/lib/src/compiler/module_builder.dart

Issue 2697093002: Deferred parsing for legacy modules (Closed)
Patch Set: Removing pending Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/dev_compiler/lib/src/compiler/js_names.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/dev_compiler/lib/src/compiler/module_builder.dart
diff --git a/pkg/dev_compiler/lib/src/compiler/module_builder.dart b/pkg/dev_compiler/lib/src/compiler/module_builder.dart
index 415554a81ce7b21bda89328d94a4be835a314c55..355f3effaf5c6f9e2c91b956a79e6606db96da2f 100644
--- a/pkg/dev_compiler/lib/src/compiler/module_builder.dart
+++ b/pkg/dev_compiler/lib/src/compiler/module_builder.dart
@@ -161,8 +161,19 @@ class LegacyModuleBuilder extends _ModuleBuilder {
for (var importName in import.namedImports) {
assert(!importName.isStar); // import * not supported in legacy modules.
var asName = importName.asName ?? importName.name;
- importStatements.add(js.statement(
- 'const # = #.#', [asName, moduleVar, importName.name.name]));
+ var fromName = importName.name.name;
+ // Load non-SDK modules on demand (i.e., deferred).
+ if (import.from.valueWithoutQuotes != dartSdkModule) {
+ importStatements.add(js.statement(
+ 'let # = dart_library.defer(#, #, function (mod, lib) {'
Jennifer Messerly 2017/02/15 20:08:49 Does this work for a JavaScript module we import?
vsm 2017/02/15 20:32:58 If that JS module uses our legacy modules as well,
+ ' # = mod;'
+ ' # = lib;'
+ '});',
+ [asName, moduleVar, js.string(fromName), moduleVar, asName]));
+ } else {
+ importStatements.add(js.statement(
+ 'const # = #.#', [asName, moduleVar, importName.name.name]));
+ }
}
}
statements.insertAll(0, importStatements);
« no previous file with comments | « pkg/dev_compiler/lib/src/compiler/js_names.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698