-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
registration[1] is not a function #2293
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
Comments
Please provide a demonstration of the issue. You can fork this code sandbox to do so. The Named System.register tests pass for me locally. Running only the Named Register test suite causes all of them to fail, since the tests rely on order of execution to set up the SystemJS extras. |
Please see this: https://codesandbox.io/s/nostalgic-microservice-4sp9j?file=/index.html |
Thanks, I'm able to reproduce the error. The reason that we use Because the named register extra has been so problematic, I've stopped using it myself and have encouraged others to stop using it. However, it is still supported and we can look into this bug you've been encountering. The idea of using @guybedford can you comment here on this? It seems that neither |
Perhaps one solution would be to have script-load.js call a method on the systemjs instance after the load event fires? systemjs/src/features/script-load.js Line 71 in 895ebaf
Perhaps something like this? // script-load.js
script.addEventListener('load', () => {
const register = System.getRegister();
if (System.scriptLoaded) System.scriptLoaded()
}) // named-register.js
System.prototype.scriptLoaded = () => {
firstNamedDefine = null;
} Perhaps that change, combined with switching back to |
@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 // script-load.js
script.addEventListener('load', function (s) {
System.execComplete(s.url);
}) 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 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. |
|
Oh so we can perhaps remove the Promise.resolve and setTimeout entirely, since the I probably won't work on this today, but might be able to work on it later this week. @guybedford if you have time and interest to work on it before me, definitely do so - I'm not attached to being the one who implements it. |
We released a fix for this in https://github.com/systemjs/systemjs/releases/tag/6.9.0. It's still possible to see this error if you're incorrectly using the named-register extra, but the fix should help things for valid calls to System.register |
@joeldenning, with 6.9.0 version bundle by |
I don't know whether 6.9.0 fixed typescript bundles using the outFile option. |
…js#2293. (systemjs#2329) * Fix named-register.js - omit name from register call. Resolves systemjs#2293. * Feedback
…js#2293. (systemjs#2329) (#1) * Fix named-register.js - omit name from register call. Resolves systemjs#2293. * Feedback Co-authored-by: Joel Denning <joeldenning@gmail.com>
Got a problem because of #2144.
setTimeout
topromise.resolve().then(...)
means macro task to micro task, but the micro task will run immediately in script. When trying to get register, thefirstNamedDefine
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'sload
event triggered -> get register ->firstNamedDefine
is nullIt'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'sload
event triggered -> get register -> clearfirstNamedDefine
-> execute script -> ...The text was updated successfully, but these errors were encountered: