imballinst / react-bs-datatable

Bootstrap datatable without jQuery. Features include: filter, sort, pagination, checkbox, and control customization.
https://imballinst.github.io/react-bs-datatable
MIT License
59 stars 20 forks source link

src/*.js cannot be imported #13

Closed rockwelln closed 6 years ago

rockwelln commented 6 years ago

Hello, I didn't had the chance to test the last big changes earlier. I tried to update this morning and had the surprise to see the sources to import to customize the table contains JSX syntax, which is fine in some cases but if CRA is used, the build fails with, for example:

./node_modules/react-bs-datatable/src/TableBody.js
Module parse failed: node_modules/react-bs-datatable/src/TableBody.js Unexpected token (12:8)
You may need an appropriate loader to handle this file type.
|     for (let i = 0; i < paginatedData.length; i += 1) {
|       body.push(
|         <BodyRow
|           key={`${keyName}-row-${i}`}
|           tableHeader={tableHeader}

I think, it would be better to compile/distribute those sources into 'lib's like it is done in react-bootstrap project (see https://github.com/react-bootstrap/react-bootstrap/blob/master/tools/lib/build.js)

imballinst commented 6 years ago

Hello! First, sorry for the hasty push, because you weren't responding for 1 week, I thought I should push it right away. Turned out it wasn't okay after all. Next time I'll just wait patiently.

I actually didn't test it with projects using CRA. Very well, I'll look into it. From what I have understood from your explanation, will CRA not compile JSX from vendor modules?

Regarding build to separate 'libs', do you mean compiling every file in src/*.js so they can be used without Babel on imports/requires (ie. A.js, B.js, and C.js are all using ES6/JSX, compiled to a.js, b.js, and c.js which all are in ES5 and doesn't contain any JSX)

If what I think above are true, I'll need to find a way for Webpack to compile per file.

rockwelln commented 6 years ago

Hey, no problem, I was late to reply, perfectly normal to push your changes (don't wait for me next time).

will CRA not compile JSX from vendor modules

It's my understanding.

Regarding build to separate 'libs', do you mean compiling every file in src/*.js so they can be used without Babel on imports/requires (ie. A.js, B.js, and C.js are all using ES6/JSX, compiled to a.js, b.js, and c.js which all are in ES5 and doesn't contain any JSX)

Correct.

I'll need to find a way for Webpack to compile per file.

I think react-bootstrap (where you can import from /lib/ each sub-component individually) can be a starter.

imballinst commented 6 years ago

Alright, cool! I'll try to fix this ASAP

imballinst commented 6 years ago

Hello, could you see and check my PR #14 when you have time? Just to make sure the solution is working in general, not just for me ;) thanks!

rockwelln commented 6 years ago

Great, your patch works fine to me :-). Thank you and happy new year!!!

imballinst commented 6 years ago

That's great to know! :D You're welcome and happy new year too! Will merge this later in the day.