Skip to content

Commit bbc9994

Browse files
MarkzipanCommit Queue
authored andcommitted
[ddc] Rolling internal dart_library.js into the external module loader.
Change-Id: If25fd9ac78d795d16b7edca507df0b806a0ebf39 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433262 Commit-Queue: Mark Zhou <[email protected]> Reviewed-by: Nicholas Shahan <[email protected]>
1 parent 15c58a8 commit bbc9994

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

pkg/dev_compiler/lib/js/ddc/ddc_module_loader.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if (!self.dart_library) {
2626
/**
2727
* Returns true if we're running in d8.
2828
*
29-
* TOOD(markzipan): Determine if this d8 check is too inexact.
29+
* TODO(markzipan): Determine if this d8 check is too inexact.
3030
*/
3131
self.dart_library.isD8 = self.document.head == void 0;
3232

@@ -70,12 +70,14 @@ if (!self.dart_library) {
7070
lastLoadEnd = Math.max(lastLoadEnd, data.loadEnd);
7171
}
7272
}
73+
let loadTimeMs =
74+
lastLoadEnd === Number.MIN_VALUE ? 0 : lastLoadEnd - firstLoadStart;
7375
return {
7476
'dartSize': dartSize,
7577
'jsSize': jsSize,
7678
'sourceMapSize': sourceMapSize,
7779
'evaluatedModules': evaluatedModules,
78-
'loadTimeMs': lastLoadEnd - firstLoadStart
80+
'loadTimeMs': loadTimeMs
7981
};
8082
}
8183
self.dart_library.appMetrics = appMetrics;
@@ -375,7 +377,7 @@ if (!self.dart_library) {
375377
* Returns an instantiated module given its module name.
376378
*
377379
* Note: this method is not meant to be used outside DDC generated code,
378-
* however it is currently being used in many places becase DDC lacks an
380+
* however it is currently being used in many places because DDC lacks an
379381
* Embedding API. This API will be removed in the future once the Embedding
380382
* API is established.
381383
*/
@@ -779,8 +781,7 @@ if (!self.dart_library) {
779781
return import_(moduleName, appName).__dynamic_module_entrypoint__();
780782
});
781783
}
782-
}
783-
784+
};
784785
})(dart_library);
785786
}
786787

@@ -875,7 +876,7 @@ if (!self.dart_library) {
875876
onLoad?.();
876877
return;
877878
}
878-
let script = dart_library.createScript();
879+
let script = self.dart_library.createScript();
879880
let policy = {
880881
createScriptURL: function (src) { return src; }
881882
};
@@ -1358,7 +1359,7 @@ if (!self.deferred_loader) {
13581359
* point the library is known to exist but is not yet usable. It is an
13591360
* error to import a library that has not been defined.
13601361
* - Initialization Phase: The library's initialization function is evaluated
1361-
* to create a library object containing all of it's members. After
1362+
* to create a library object containing all of its members. After
13621363
* initialization a library is ready to be linked.
13631364
* - Link Phase: The link function (a library member synthesized by the
13641365
* compiler) is called to connect class hierarchies of the classes defined
@@ -1447,7 +1448,7 @@ if (!self.deferred_loader) {
14471448
} else if (libraryName in this.libraryInitializers) {
14481449
throw 'Library ' + libraryName +
14491450
' was previously defined but DDC is not currently executing a hot ' +
1450-
' reload or a hot restart. Failed to define the library.'
1451+
' reload or a hot restart. Failed to define the library.';
14511452
} else {
14521453
this.libraryInitializers[libraryName] = initializer;
14531454
}
@@ -1623,7 +1624,7 @@ if (!self.deferred_loader) {
16231624
for (let file of this.pendingHotReloadFileUrls) {
16241625
reloadFilePromises.push(
16251626
new Promise((resolve) => {
1626-
self.$dartLoader.forceLoadScript(file, resolve)
1627+
self.$dartLoader.forceLoadScript(file, resolve);
16271628
})
16281629
);
16291630
}
@@ -1728,7 +1729,7 @@ if (!self.deferred_loader) {
17281729
}
17291730

17301731
function dartDeveloperLibrary() {
1731-
return libraryManager.initializeAndLinkLibrary('dart:developer')
1732+
return libraryManager.initializeAndLinkLibrary('dart:developer');
17321733
}
17331734

17341735
function dartRuntimeLibrary() {

0 commit comments

Comments
 (0)