# Import 3rd paty libraries to kibana plugin

**URL:** <https://discuss.elastic.co/t/import-3rd-paty-libraries-to-kibana-plugin/104693>\
**Category:** Kibana\
**Created:** [October 20, 2017, 11:52am UTC](https://discuss.elastic.co/t/import-3rd-paty-libraries-to-kibana-plugin/104693 "2017-10-20T11:52:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nugusbayevkk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nugusbayevkk/32/126683_2.png) [@nugusbayevkk](https://discuss.elastic.co/u/nugusbayevkk)\
**Post date:** [October 20, 2017, 11:52am UTC](https://discuss.elastic.co/t/import-3rd-paty-libraries-to-kibana-plugin/104693/1 "2017-10-20T11:52:47Z")

</div>

hello guys,  
i need some advice, hot to add to plugin development libraries: html2cavas, pdfmake:

i define:  
const app = uiModules.get('app/logger', );

then i create controller

> ```
> app.controller('loggerController', function ($scope, kbnUrl, $route, $routeParams,
> $window, $interval, $http, $document, $timeout, $location) {
> 
> ```

...

> ```
> $scope.exportData = function() {
> html2canvas(document.getElementById('exportthis'), {
> onrendered: function (canvas) {
> var data = canvas.toDataURL();
> var docDefinition = {
> content: [{
> image: data,
> width: 500,
> }]
> };
> pdfMake.createPdf(docDefinition).download("report.pdf");
> }
> });
> }
> }
> 
> ```

with npm install i install pdfmake and html2canvas  
and try to impport this with 2 way:  
require('pdfmake')  
require('html2canvas'

or try  
import from ('pdfmake')  
import from ('html2canvas')

after i got exception when i run npm start:

optmzr log [11:44:30.393] [fatal][optimize] Lazy optimization failed in 1.33 secondsError: Optimizations failure.

```
WARNING in ./plugins/logtrail/~/html2canvas/dist/html2canvas.js
Critical dependencies:
8:484-491 This seems to be a pre-built javascript file. Though this is possible, it's not recommended. Try to require the original source to get better results.
 @ ./plugins/logtrail/~/html2canvas/dist/html2canvas.js 8:484-491

```

Error: Optimizations failure.

```
WARNING in ./plugins/logtrail/~/html2canvas/dist/html2canvas.js
Critical dependencies:
8:484-491 This seems to be a pre-built javascript file. Though this is possible, it's not recommended. Try to require the original source to get better results.
 @ ./plugins/logtrail/~/html2canvas/dist/html2canvas.js 8:484-491

at Object.exports.create (/opt/development/kibana/node_modules/boom/lib/index.js:21:17)
at LazyOptimizer.failedStatsToError (/opt/development/kibana/src/optimize/base_optimizer.js:224:17)

```

i work with kibana version: 5.5.2, elk 5.5.2

node version = 8.6.0  
npm version = 5.3.0

How correct make import this libraries?

---

<div class="post-metadata">

**Author:** ![nugusbayevkk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nugusbayevkk/32/126683_2.png) [@nugusbayevkk](https://discuss.elastic.co/u/nugusbayevkk)\
**Post date:** [October 22, 2017, 11:04am UTC](https://discuss.elastic.co/t/import-3rd-paty-libraries-to-kibana-plugin/104693/2 "2017-10-22T11:04:44Z")

</div>

guys i found solution:  
in this cases need follow official instructions [https://www.elastic.co/guide/en/kibana/current/development-dependencies.html](https://www.elastic.co/guide/en/kibana/current/development-dependencies.html)  
at first i found alternative in [http://npmsearch.com/](http://npmsearch.com/)  
and then added :  
import html2canvas from 'html2canvas-webpack';  
require('pdfmake/build/pdfmake.js');  
require('pdfmake/build/vfs\_fonts.js')

thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 19, 2017, 11:04am UTC](https://discuss.elastic.co/t/import-3rd-paty-libraries-to-kibana-plugin/104693/3 "2017-11-19T11:04:58Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
