[英]Can import external JavaScript Libraries in Grafana DataSource Library
I am having an issue trying to import crypto-js library in a Grafana Datasource Pluging I am developing. 我正在尝试在我正在开发的Grafana Datasource Pluging中导入crypto-js库。
I get the following exception: 我得到以下异常:
Error: (SystemJS) Cannot set property 'CryptoJS' of undefined TypeError: Cannot set property 'CryptoJS' of undefined at Object.create.F ( http://localhost:3000/public/plugins/grafana-my-datasource/external/crypto-js.js?bust=1493397621246:25:20 ) at execute ( http://localhost:3000/public/plugins/grafana-my-datasource/external/crypto-js.js?bust=1493397621246:27:6 ) Error loading http://localhost:3000/public/plugins/grafana-my-datasource/module.js
错误:(SystemJS)无法设置未定义的属性'CryptoJS'TypeError:无法在Object.create.F中设置未定义的属性'CryptoJS'( http:// localhost:3000 / public / plugins / grafana-my-datasource / external / crypto-js.js?bust = 1493397621246:25:20 )执行时( http:// localhost:3000 / public / plugins / grafana-my-datasource / external / crypto-js.js?bust = 1493397621246:27:6加载http:// localhost:3000 / public / plugins / grafana-my-datasource / module.js时出错
I have this in the datasouce.js: 我在datasouce.js中有这个:
import _ from "lodash";
import moment from 'moment';
import CryptoJS from './external/crypto-js';
export class GenericDatasource {
.......
and in the Gruntfile.js: 并在Gruntfile.js中:
externals: {
cwd: 'src',
expand: true,
src: ['**/external/*'],
dest: 'dist'
}
Any ideas? 有任何想法吗?
Two things to check: 要检查两件事:
Is Grafana finding the js file? Grafana是否找到了js文件? Can you navigate to http://localhost:3000/public/plugins/grafana-my-datasource/external/crypto-js.js in your browser and get back a JavaScript file?
您可以在浏览器中导航到http:// localhost:3000 / public / plugins / grafana-my-datasource / external / crypto-js.js并获取JavaScript文件吗?
Are you importing it correctly? 你正确导入它吗? Is CryptoJS the default import?
CryptoJS是默认导入吗? You could try:
你可以尝试:
import * as CryptoJS from './external/crypto-js';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.