So this works in the latest version of Chrome, which is freaking awesome:
# index.html
<!DOCTYPE html>
<html>
<head><title>import demo</title></head>
<body>
<script type="module" src="./app.js"></script>
</body>
</html>
# app.js
import { concat } from 'https://unpkg.com/lodash-es'
console.log('lodash =', concat([1,2,],3,4))
md5-7cccffcb4f3f503f02d26944c21234be
```js
# app.js
import { concat } from 'https://unpkg.com/lodash-es'
console.log('lodash =', concat([1,2,],3,4))
And it has the 302 redirect resolution issue explained in https://github.com/ModuleLoader/es-module-loader/issues/538
At the moment, I'm "solving" this by manually mapping module identifiers to their final URL, which basically means adding a line of config for every deep dependency in my project. (And that became so burdensome I started using the UMD builds of my dependencies instead of their native ES6 source code.) I'm building a client-side IDE so I need to be able to dynamically load npm modules, which is why I'm not just using Webpack or something.
Any idea how I can get around this? Is there a hook where I could mangle the resolving algorithm in SystemJS to use the post-302 location?
Ok, so the reason for this is we don't support "catching" redirects in the fetch component of SystemJS.
Supporting this is important for spec alignment so let's aim to get this feature in soon.
Basically we'd need something along the following lines:
fetch, detect a redirect, and return the redirect URL along with the sourcescriptLoad then unfortunately we don't have this information so this would have to be for the fetch mode only.meta.redirectURL or similar on the load record.This should be relatively straightforward to implement, so I will aim to get to this, although it won't be very soon unfortunately.
locate call.This is still a tricky one to support in SystemJS 2.0. Leaving open, but its nature is a wontfix.
(although I'm always open to bright ideas too)
It should be possible to support with the translate loader though, just not the script loader.
Removing the wontfix label for the translate loader support.
I implemented this in es-module-shims in https://github.com/guybedford/es-module-shims/commit/a811843f6a2a1cbc7504971ba572a314f96f1e9b and it was pretty straightforward.
The hardest part is just figuring out how to pipe this information in the System loader internals.
So it turns out the translate loader is not really being focused on. Given this I think we can go back to the wontfix scenario here.
Most helpful comment
I implemented this in es-module-shims in https://github.com/guybedford/es-module-shims/commit/a811843f6a2a1cbc7504971ba572a314f96f1e9b and it was pretty straightforward.
The hardest part is just figuring out how to pipe this information in the System loader internals.