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

Omit setTimeout milliseconds (saves bytes). #2105

Merged
merged 1 commit into from Jan 19, 2020
Merged

Omit setTimeout milliseconds (saves bytes). #2105

merged 1 commit into from Jan 19, 2020

Conversation

joeldenning
Copy link
Collaborator

@@ -35,7 +35,7 @@
this.registerRegistry[name] = define;
if (!firstNamedDefine) {
firstNamedDefine = define;
setTimeout(clearFirstNamedDefine, 0);
setTimeout(clearFirstNamedDefine);
Copy link
Member

Choose a reason for hiding this comment

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

I forgot we did this... I know I originally suggested it, but perhaps we can have a shouldClear variable now and check this anytime before we check firstNamedDefine or something similar.

Or do you not think there is any risk here at all? My concern is just the edge case of many System.imports clashing on the timing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How would the shouldClear variable work? What would it hook into to know when to reset firstNamedDefine?

Copy link
Member

Choose a reason for hiding this comment

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

What is the exact lifetime we want for firstNamedDefine?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think "current script finishes executing" is the ideal, although I don't know of a way to know that - perhaps the load event on the script element?

What we're trying to cover is a scenario similar to the following:

<script>
  const m = await System.import('./a.js')
  console.log(m.default) // thing1
</script>
// a.js

System.register('name1', [], _export => ({
  execute() {
    _export('default', 'thing1');
  }
})) 

System.register('name2', [], _export => ({
  execute() {
    _export('default', 'thing2')
  }
})) 

Copy link
Member

Choose a reason for hiding this comment

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

This might well be fine... let me not hold back the PRs over this since it's an existing thing - we can track it in a new issue if there are better ways to think about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants