list.js
list.js copied to clipboard
How am I suppose to import list.js with es6 and webpack ?
I would have expect a export default List;
then I could do import List from 'list.js';
How am I suppose to do that ? thanks in advance !
Simply put import List from 'list.js';
on top of your file and use the library using new List()
.
@thedaviddias Thanx for answering :) That is precisely what I'd expect but it seems like not working (I'm using version 1.5.0 of list.js)
:/
As said, I had to add manually export default List;
to the end of the minified file as I heard here https://github.com/javve/list.js/issues/542#issuecomment-324858891 to make it work...
u can also try window.ListJS = require('list.js')
I did what @ctf0 suggested, except mine was window.List = required('list.js')
so that it's consistent with the name in the documentation.
For me even the window.List = required('list.js')
gives me an empty object - same as import List from 'list.js';
Does not work in my case :(
@binarykiwi looks like you're typing required
instead of require
. Remove the d and see if that helps.
@fakefarm no, that doesn't help either.
Still this error: Uncaught ReferenceError: List is not defined
Hmm, yeah this sounds like a problem. Could someone provide me with an example project for this issue? So I can try it out myself locally.
import List from 'list.js';
at the top of src/index.js works fine, @javve. (list.js 1.5.0)
I've had this error too, but I had npm installed listjs where it should have been list.js.
I made this work creating a new file
class.list.js
const List = require('list.js/src/index');
export default List;
And i was able to use it in my own file:
import List from './class.list';
I hope this helps
The following works for me:
npm install list.js
import List from 'list.js;
mounted: function () {
// Init list
new List('myList', {
valueNames: ['country', 'percent'],
page: 3,
pagination: true
});
}
This should be via CDN and documented.
try this require('./file.js').list
I've tried all of the above suggestions with no luck and am continually met with the following error: ReferenceError: Can't find variable: List
. Is there a new approach to using this library with Webpack? Can this get documented officially?
This worked for me.
import * as List from 'list.js';
Any news ?