requirejs broken by corejs upgrade
jods4 opened this issue · comments
This line of code inside createLoader()
is now an issue for us, since the last corejs
update (2.0.2):
Line 47 in b6f1849
The whole story is a bit complicated and I'm not 100% sure what the fix should be...
We use requirejs as our AMD loader. This means that we shouldn't have window.System
defined.
What triggered the issue is that corejs
now contains a polyfill for System.global
.
But by creating the System
object, it fooled Aurelia into thinking that I have a System loader, which I don't. So the code crashes on the next line with System.normalizeSync
is undefined.
Now, you might think "well, let's be more specific and test if (System && System.normalizeSync)
". I think this would fix the short-term crash but I'm not sure if it's a long-term solution.
Consider this: in the future, what will happen when users finally upgrade to a modern browser that includes a built-in System
loader?
Answer: Aurelia will think that I'm using the System
loader... and nothing will work because I deploy optimized requirejs
bundles.
I think it would be best if either:
- Aurelia tests for the presence of requirejs first:
if (window.require) else if (window.System)
. Since there is no reason requirejs would be loaded unless I'm intending to use it; or - Aurelia takes some explicit config at startup that says which loader I am using, no guessing game.
❗ This is a critical issue: without dirty work-arounds using Aurelia + latest corejs + requirejs simply does not work.
Good news is that I was planning to make some improvements in there this week. So, I can address this then too.