0

Please pardon my lack of knowledge on js bundling but I would like to import this javascript file into my Vue.js project and use its function and I just can't see to get it to work.

https://github.com/omnisci/Charting-Sample/blob/master/main.js

Maybe this is just something fundamental about how the file was bundled but I am trying to import it like this

import * as omni from "../main";

and then trying to use a function from the file like this

omni.crossfilter.crossfilter(con, tableName)

But I am getting this error

Uncaught TypeError: _omni__WEBPACK_IMPORTED_MODULE_1__.crossfilter is not a function

When I just include the file in regular html file using a src and script tag it works just fine calling the function. If anyone could give me some guidance on what I am doing wrong here, or how to import this properly I would really appreciate it.

4
  • have you tried import omni from "../omni"? Might sometimes also be import { omni } from "../omni" Commented May 19, 2020 at 1:15
  • stackoverflow.com/questions/48426972/… This may help you. Commented May 19, 2020 at 2:20
  • It also depends on how you exported your function from main.js. Can you also add your omni snippet? Commented May 19, 2020 at 17:40
  • This is the file that the functions are exported in. I didn't write it so I was not sure if it would even work with vue. github.com/omnisci/Charting-Sample/blob/master/main.js Commented May 19, 2020 at 17:52

1 Answer 1

0

Just write:

import '../main'

and call functions after import:

/ ...
crossfilter(con, tableName)
Sign up to request clarification or add additional context in comments.

2 Comments

This is still telling me "error 'crossfilter' is not defined". I edited my question so that it is more clear what I am importing. (I had renamed the file main.js to omni.js)
The minified file just generate global variables. Try to console.log(crossFilter) after import to check it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.