registration[1] is not a function
See original GitHub issueGot a problem because of #2144. setTimeout
to promise.resolve().then(...)
means macro task to micro task, but the micro task will run immediately in script. When trying to get register, the firstNamedDefine
can’t be got, because it has been destroyed. So this error ‘registration[1] is not a function’ occurs. The timeline likes:
execute scripnt -> register named module -> clear firstNamedDefine
-> script’s load
event triggered -> get register ->
firstNamedDefine
is null
It’ll be reproduce by running only running the test suit ‘Named System.register’.
I wonder if there’s necessary to clear the firstNameDefined
by delay? This process seems OK(maybe):
execute script -> register named module -> update firstNamedDefine
-> script’s load
event triggered -> get register -> clear firstNamedDefine
-> execute script -> …
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (2 by maintainers)
I don’t know whether 6.9.0 fixed typescript bundles using the outFile option.
@joeldenning thanks for following up on this. What you’re suggesting actually does sound like exactly the right approach actually. Perhaps we can turn this into an
execComplete
hook where the default implementation callsgetRegister
, something like:It does seem like this gets around the original problem we wanted the timeout for entirely since we can clear everything on completion of all the defines.
Note that we would need to ensure the hook also is called for the
eval
extension and worker cases as well.Let me know if that sounds like an approach further, and happy to jump in too as necessary. The replication makes all the difference here so thanks @liajoy for the details.