Skip to content
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

How to embed "regular" JS-Libs (e.g. Chart.js, dragula.js) in dev & prod built #1015

Closed
hmrc87 opened this issue Jun 5, 2016 · 5 comments
Closed

Comments

@hmrc87
Copy link

hmrc87 commented Jun 5, 2016

There are a lot of discussions going on regarding the --prod built and how difficult it can be to embed 3rd-Party libraries. So far I have managed to add the following libraries, they run perfectly in dev and prod-built with beta5

  • ng2-uploader
  • ng2-bootstrap
  • ng2-table

I wanted to add ng2-dragula and ng2-charts but each of them rely on a separate JavaScript-Library (chart.js and dragula.js) which I am only able to get up and running in dev-mode and when I add the import to index.html.

When I add them via system-config.js I only get errors. I tried changing the format to cjs or register or just leave it away. But I didn't find a way to add a "regular JS library like "Chart.JS" to the angular-cli project so that it runs in dev and --prod mode.

@hmrc87 hmrc87 changed the title Embed "regular" JS-Libs (e.g. Chart.js, dragula.js) in dev & prod built How to embed "regular" JS-Libs (e.g. Chart.js, dragula.js) in dev & prod built Jun 5, 2016
@hmrc87
Copy link
Author

hmrc87 commented Jun 5, 2016

I was able to get Chart.JS and dragula.js working by declaring it a "global" module in system-config.ts

'chartjs':{ format: "global" },

and importing it in my main-component import 'chartjs so that SystemJS knows that is has to include it into its combined main.js.

I don't know if this should be in the docs, since this is an SystemJS issue but it would be great to have it in the "How to install 3rd party libs" section.

More information here:
#718 (comment)

@hmrc87 hmrc87 closed this as completed Jun 5, 2016
@filipesilva
Copy link
Contributor

Heya, glad to know that you got it working! I'll try to add it to the wiki when reviewing the angular2-material example.

Meanwhile I might just redirect people here when they have similar issues. Cheers!

@vabhik
Copy link

vabhik commented Sep 20, 2016

It doesn't work in my case, I used jquery and bootstrap and tried defining the format global but it still not able to recognise them. Finally, I moved them to public folder and used them in index file. Please help if there is another working approach exists

@iBasit
Copy link

iBasit commented Sep 30, 2016

+1

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants