-
-
Notifications
You must be signed in to change notification settings - Fork 302
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
Use unpkg as a SystemJS source #16
Comments
I don't have a lot of experience w SystemJS, but just looking at the config you've got there, could you do something like this right now? SystemJS.config({
paths: {
"gl-matrix": "//unpkg.com/dist/*.js",
"tgd": "//unpkg.com/umd/*.js"
}
}) |
Yes, that might work, but then I would need to specify each dependency (and the dependencies's dependencies) in the the paths. With the solution outlined above, you just need to configure the catchall path and most |
What is the root problem here? I see that in the |
Also, do you think the the |
The root problem is as follows: we do not want to manually register the unpkg URLs for every single package (including their dependencies). For instance:
And yes, taking hints for the |
Hi Michael! I was wondering if you needed some help to better formalize the feature, I could also give a hand for implementation. |
Yes, some help would be very much appreciated. I think implementation should be pretty straightforward. Let's pretend we're writing some user-facing docs for this feature. How could we describe it in a sentence or two? Here's a first draft:
Is that last part wrong? It seems like we're incurring extra complexity on our side because packages are not using the "browser" field properly, but there may still be a piece I'm missing. |
As stated in https://github.com/unpkg/npm-http-server/issues/57, i'm happy to make MR |
Go for it! Can you also please include an example app that demonstrates the functionality you're after? I still haven't had time to look into this properly (sorry!) and I think a sample app might help me understand better. |
@truongsinh Have you had a second to look further into this? I'd really love to see a simple little app that I can just |
@sebastien If you're still up for it, I'd love a hand with this. It sounds very promising. |
I'm not sure what to add to what I've already written. Basically, there are two new features/changes to implement:
The end goal of this is to allow unpkg to be used as a source of directly usable JavaScript packages, without having to use any packager manager at all. The problem that these changes try to solve is the variety of configurations of where the pre-built files are located. |
Thanks for the summary, @sebastien. Would you care to make a PR? Otherwise I may have some time soon to take a look. |
I sadly don't have any experience with NodeJS server development :/ |
Just a note about this:
https://unpkg.com/tgd@0.0.4/umd now redirects to https://unpkg.com/tgd@0.0.4/umd/index.js I'm not sure why I didn't see this before. It seems obvious now that it always should've worked that way to preserve relative module paths. Anyway, I think this should get us closer to being able to load stuff directly using SystemJS. |
I just opened a case ModuleLoader/es-module-loader#538 that might be of interest. Basically I noticed that relative URLs are being resolved wrt the import URL rather than the import URL after redirects, and think that may be a bug in Chrome or an opportunity to improve the spec. |
Hey guys Have been trying to get it work for almost two years now. Made many iterations, but always had some issue or another. But recently, I have been successful in using npm5's package-lock.json along with some simple post processing as source for systemjs config. Post processing is necessary for two things
Code can be found here if anyone is interested abhishiv/systemjs-npm-resolver |
I'm a little late here, but I started to use SystemJS with a PHP env in past year and I want to know: can I use unpkg as a SystemJS source now or it stills kinda buggy? |
It would be nice to use Unpkg as a universal source for packages when using dynamic loaders such as SystemJS. An ideal configuration would be:
Allowing the following forms:
Right now, this would not work for modules such as
gl-matrix
andtgd
for the following reasons:gl-matrix
exports the ES6 code by default, but has adist
version with an UMD build at https://unpkg.com/gl-matrix@2.3.2/dist/gl-matrix.jstgd
exports the UMD build under theumd
directory and usesumd/index.js
as the main file, however the relative imports fail because the Unpkg URL is unpkg.com/tgd and not unpkg.com/tgd/umdIn order to better support SystemJS-like paths, Unpkg could:
as=umd
parameter with the following semantics: look for anumd
ordist
directory, and use it as root.index.js
is present in this directory, it should be served by default when the request URL path does not end with a/
. For instance https://unpkg.com/tgd@0.0.4/umd/ and https://unpkg.com/tgd@0.0.4/umd now return the same, while it could https://unpkg.com/tgd@0.0.4/umd return the contents of https://unpkg.com/tgd@0.0.4/umd/index.js (or at least redirect to it).The relatively simple changes would allow to bypass package management systems such as NPM or JSPM and use unpkg as an online, versioned, package source.
The text was updated successfully, but these errors were encountered: