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

Fixup and simplify auto import cases #2225

Merged
merged 1 commit into from
Aug 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 3 additions & 12 deletions src/features/script-load.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ systemJSPrototype.createScript = function (url) {
var lastAutoImportUrl, lastAutoImportDeps;
var autoImportCandidates = {};
var systemRegister = systemJSPrototype.register;
var timeoutCnt = 0;
systemJSPrototype.register = function (deps, declare) {
if (hasDocument && document.readyState === 'loading' && typeof deps !== 'string') {
var scripts = document.getElementsByTagName('script');
Expand All @@ -40,17 +39,9 @@ systemJSPrototype.register = function (deps, declare) {
lastAutoImportUrl = url;
lastAutoImportDeps = deps;
autoImportCandidates[url] = [deps, declare];
var loader = this;
// This timeout ensures that if this is a dynamic script injection by SystemJS
// that the auto import will be cleared after the timeout and hence will not
// be auto imported
timeoutCnt++;
setTimeout(function () {
if (autoImportCandidates[url])
loader.import(url);
if (--timeoutCnt === 0 && document.readyState !== 'loading')
autoImportCandidates = {};
});
// if this is already a System load, then the instantiate has already begun
// so this re-import has no consequence
this.import(url);
}
}
else {
Expand Down