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

Add auto-import extra #2210

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Change auto-import to always import during loading
  • Loading branch information
tmsns committed Jul 23, 2020
commit 04d7099efa35fc630338fea94dc4ff3b9c1eb539
10 changes: 5 additions & 5 deletions src/extras/auto-import.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/**
* Auto-import the first call to System.register
* Auto-import all calls to System.register during loading
*/
(function (global) {
var systemJSPrototype = global.System.constructor.prototype;
var systemInstantiate = systemJSPrototype.instantiate;
var systemRegister = systemJSPrototype.register;
var systemGetRegister = systemJSPrototype.getRegister;

// hook into System.register (but release it after first usage)
// hook into System.register
systemJSPrototype.register = function (deps, declare) {
// reset System.register for subsequent usage
systemJSPrototype.register = systemRegister;

// register normally
systemRegister.call(this, deps, declare);

// only auto import if the document is not loading
if (document.readyState !== 'loading') return;

// retrieve last register
var register = systemGetRegister.call(this);

Expand Down