-
Notifications
You must be signed in to change notification settings - Fork 185
Release new loader branch #491
Comments
what still needs doing? This is presumably linked with #381. I agree that it's high time this project moved on from the old spec. Would it help if we created a milestone with the outstanding tasks listed with 'PR welcome' or some such? |
I don't think we're even linked to 381 at all here either, as this project can continue to make regular breaking changes due to its nature. We're currently running on an older version of the loader spec, so we could update to the latest PRs made over the last year, or at least a set of them including things like ensuring the new globals are all correct. Then the main thing secondly would be a Babel 6 upgrade / recent Traceur upgrade, and updating the docs. |
and an update to SystemJS :-) It's a long time since I looked at the 1.0 branch but I have some time, so, if you like, I can look through the code and see what I think still needs doing. Probably won't have time for any meaningful testing, but if it's usable it could be released as alpha/beta. I can also see what state the docs are in. |
In due course SystemJS as well certainly, but I think we should get this update out independent to SystemJS, and SystemJS can upgrade when the timing makes sense. If you're able to look into this that would be a huge help!! As I say the rough main things are probably checking the top-level global names, Babel / Traceur upgrades and the docs. I can certainly provide as much detailed feedback as is necessary too. |
you're meaning here |
the question to me is what we're doing with transpilers - as in discussion of #463. |
ok, have now looked through the code. The bad news is that there's quite a few functions (in On the top-level globals, I notice a couple of other places where out-of-date functions are being used:
On I would move the URL polyfill into userland. This is only needed for IE, and IMHO it should be up to the app developer to decide whether they want to support IE or not. |
one other out-of-date function: |
@guybedford here's what I propose doing:
We'll have to see then what time I have available for filling in the empty functions. |
This all sounds really great, it definitely sounds sensible to take a high-level docs focus first. I've included some feedback below.
Sure, I've created a 0.50 branch based on the 1.0 branch.
Agreed!
Yes happy to remove the sites implementation.
This code was exactly to the spec previously, so following spec commits since the date of the loader code may be one way of going about this upgrade. This is a tough job though, so I certainly understand if you don't have time for this. I think a documentation-first focus and getting the other code points you've mentioned right first makes sense here. If we have something that runs, updating this project to that as an alpha with a caveat that this is still being updated to the new spec would be a great start, as it means people can be testing out the module tag, or testing out the loader spec API and seeing how it fits together, which should be the whole point of this project - to show real working loader code, and to help demystify the spec. |
this is something that bothers me. I was expecting Chrome to provide the first implementation, but Edge seems to have got there first https://blogs.windows.com/msedgedev/2016/05/17/es6-modules-and-beyond/. If a user has this enabled in the browser, it will process any module tag(s), and in this case the polyfill should not do anything with the tags. But I can't think of any way for the polyfill to know whether this has been done or not. Any ideas? |
also related to module tag, https://html.spec.whatwg.org/multipage/webappapis.html#integration-with-the-javascript-module-system only allows |
@probins definitely a feature detection can be put together for existing implementations of the module tag. Eg creating a module tag and injecting it into the head it see if it executes. Yes the module tag restricts names to URL-like. The default loader resolver would implement the same algorithm also throwing on plain names, but then resolver extensions would be able to remove this restriction, as it is exactly designed to be overridden by the ability to set a custom resolver and that is why it is there. |
yes, I suppose it could create a property in System, for example, and then check whether it's been created or not. ok, I'll start work on a Readme rewrite this week some time. I'll create small PRs rather than one large one. |
one thing I was forgetting was that Node does not have URL(), so some sort of module/polyfill is needed for running in Node - which includes running Travis/tests |
something else to decide is what to do about metadata. The current loader includes metadata as a param in all the prototype methods, but this is not (atm) defined in the current spec. Remove this for the time being? |
This would be an argument for bringing back the internal URL polyfill actually. No reason not to support Node and IE out the box without further configuration.
Sure. |
have a separate build for Node which includes the URL polyfill? When a function is only supported in a minority of browsers, then I think it's fair enough to always include a polyfill, but according to http://gs.statcounter.com/ IE usage is now down below 10% (if you count desktop+mobile). Even allowing for those using older versions of other browsers, that's still only a small proportion, so you're adding unneeded overhead for the majority just to cater for the minority. |
The URL polyfill still has spotty implementation consistency as well... I think we should just blanket keep it in actually. Evergreen should be the target... which means supporting all modern browsers out the box without any extra configuration necessary. |
@guybedford a question: why does |
@probins this is in order to actually be able to run the native linking code. If we implement this in instantiate / translate then a whole bulk of the code in the spec becomes useless. Theres two approaches here:
(2) is the approach we've taken here so far. |
on hold pending whatwg/loader#147 |
@probins if you're interested to review, I've just posted up a new loader rewrite on the 1.0 branch! |
:-) I'll take a look in the next few days |
I really like the change to modules/rollup - much cleaner and easier to read. Also like the System.register build, so I built this. But when I run |
I then tried a similar test in the browser:
This fails I'll try some further tests with System.register in the browser, which is my main interest; ATM I'm not too bothered whether it works in Node or not. AIUI, System.register should also work in |
a couple of other things my editor complains about:
Also, in system-register-only.js, |
@probins thanks for these I've added the changes. |
test now works in Node and my demo.html, thanks. I should be able to find time tomorrow to go through the loader in more detail; won't be anything like a test, more a comparison with the spec. |
ok, Guy, here's some preliminary comments:
What's your plan? Presumably you'll be adding more tests. I have been planning on converting my current modules, still in CJS, to ES6/System.register, and could then use this register build to load. This would be a more substantial test; however, I don't use much of the loader (just import), and anyway conversion won't happen overnight. |
might also be worth stressing that System.register now works in |
@probins thanks for the further feedback, I've included some notes in the spec differences section. I've restructured the project some more, so the direction should be clearer now... I'd value your opinion if the general structure makes sense to you? (having built and published the three example loaders now, this is now the base for the next version of SystemJS) |
I've published this now to https://www.npmjs.com/package/es-module-loader. @Rich-Harris kindly offered the I think the main thing to work towards is just getting the documentation, API documentation and tests to a point where this can be exposed as the face of this project on GitHub and shared. I'll be working towards this tomorrow and Friday, hopefully to get something out this week! |
in general, I like the new structure, but system-register should include support for |
on docs, there's quite a bit of relevant stuff in systemjs/systemjs#1143 which could be either split or just provide a link from here to there. |
@probins it would be nice to support module scripts for System.register, but the problem with this approach is that it will error when browsers do support |
there has to be a userland check anyway (we had a discussion before about how to implement that): if supported load ES6 else load polyfill with System.register. That's the only way I can see to handle the transition when only some browsers support. |
to expand a bit on my previous code: if ES6 supported, create module script to load myES6Bootstrap.js else create scripts to do:
|
It certainly can work for content sniffing the response to |
in fact, this isn't necessary, as I can just as easily use import() in the polyfill onload - and that has the advantage of making the build a bit smaller. What do you see as the advantage of using System.register in Node, as opposed to converting ES6 to CJS and using the existing loading mechanism? |
Ok, I've launched this now as a 1.0 release. I've been doing some performance benchmarking and it looks like this new loader is on average 10 - 100x faster at loading bundles than SystemJS! Now to get SystemJS updated to this base... @probins System.register is all about replicating the exact execution semantics... in future this will include the loader context ( |
great stuff - a giant step forward! 👏 I'll go through the docs at some point soon. If SystemJS is converted to a set of ES6 modules too with an uglified System.register version in dist/, it should be easy to add them singly in the browser as required rather than having to go through a separate build step. |
It's really important now to release the 1.0 branch so that this project can again match the loader spec more closely.
I think it would make sense to keep it as a minor patch - say 0.20, at least until the loader spec is stable.
Even if we're not fully spec compliant, having the spec API is obviously a much better thing than still being on the old API, and it's a shame the new loader branch has just sat there now for over a year.
If anyone is interested in working on this please get in touch. If we can release it tomorrow we should. I'd hate to be holding this work back.
The text was updated successfully, but these errors were encountered: