-
Notifications
You must be signed in to change notification settings - Fork 12k
Loading 3rd party library using System.js #1204
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
Loading 3rd party library using System.js #1204
Comments
Something like this in const map: any = {
'jquery': 'vendor/jquery/jquery.min.js'
};
/** User packages configuration. */
const packages: any = {
'jquery':{
format: 'cjs'
}
}; |
You also need to |
Thanks for your responses. So I tried the above in a new test project. But when serving to production (because my index.html imports seem to be ignored in production), I'm still getting |
I think I'm having the same issue. The vendor files are not being copied in the -prod build. It's fine in the dev build. |
@amindunited seems to be the same problem. Which version of CLI are you using? |
@StephenPaul I'm using 1.0.0-beta.8 |
I'm using 1.0.0-beta.6. Not sure how to escalate this. |
I haven't been able to get to the issue yet, but if you comment out lines 158-160 in 'node_modules/angular2-cli/lib/broccoli/angular2-app.js':
the files will be copied to the vendor directory. |
So, I hate to be that guy, but this is not an issue with the CLI. It doesn't need to be escalated. You need to educate yourself on SystemJS more. You shouldn't have to edit your Here is a working repository I created for you with And here is a link to get going with SystemJS: https://github.com/systemjs/systemjs/blob/master/docs/config-api.md |
@delasteve you're absolutely right - was a product of system.js ignorance ;). I appreciate your effort. That repo and reference helped. |
So, instead of using CDNs, always include everything in the build? |
You can use a CDN. map: {
"jquery": "https://code.jquery.com/jquery-3.0.0.min.js"
} |
@delasteve First off, thanks for making that repo! I forked it and added another js library to show what I'm doing before running 'ng build -prod' fails to copy the files to vendor. jquery, and the polyfills work, but the new library doesn't get copied over. I'm quite stuck on this. I wonder if you would mind having a look? |
I see it in the prod bundle that is created. If you go to the browser console and type watermark, it returns a function. jQuery has map files associated with it, and those are copied over in production. If watermark had map files (checked dist, it doesn't) or any other asset files (eg. bootstrap with the .css and font files) they would be copied over also. Looks like you got it working to me. |
For now, I'm just running tsd install on my build machine after npm i. It is working fine. It might be nice to update the docs to include this scenario for including a library which you do not want to download and distribute. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Linux Ubuntu 64
node: 5.8.0
os: linux x64
Until now, to load 3rd party libraries (like jQuery), I've simply:
However, after building and serving to production, I see my jquery isn't pulling through (no doubt because system.js hasn't been aware of it). I've been struggling to get the system.js build system to pick up jQuery (even after following these examples). Precisely, what are the modifications I need to make to system-config.js to pick it up?
Thanks in advance.
The text was updated successfully, but these errors were encountered: