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
Conversation
@@ -35,7 +35,7 @@ | |||
this.registerRegistry[name] = define; | |||
if (!firstNamedDefine) { | |||
firstNamedDefine = define; | |||
setTimeout(clearFirstNamedDefine, 0); | |||
setTimeout(clearFirstNamedDefine); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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')
}
}))
There was a problem hiding this comment.
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.
Zero milliseconds is the default. https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout