cinemascience / cinema_components

A JavaScript library for building Cinema viewers
Other
2 stars 5 forks source link

Cannot build: babel-minify gives syntax error #9

Open camtauxe opened 6 years ago

camtauxe commented 6 years ago

I am unable to build the library using the makefile. I get the following error on my computer.

mkdir -p build
cd src; cat Database.js Component.js Glyph.js ImageSpread.js Pcoord.js PcoordCanvas.js PcoordSVG.js Query.js ScatterPlot.js ScatterPlotCanvas.js ScatterPlotSVG.js | babel-minify > ../build/CinemaComponents.v2.4.1.min.js
/usr/local/lib/node_modules/babel-minify/lib/cli.js:39
function printHelpInfo({
                       ^

SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/babel-minify/bin/minify.js:3:1)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
makefile:6: recipe for target 'minify' failed
make: *** [minify] Error 1

Ideally, we should find a better solution for minify-ing the code as having to install nodejs, npm and babel-minify just to build the project is pretty absurd. Perhaps it would be best to forego minify-ing altogether and simply concatenate the source files together because at least that won't require any dependencies.

dtorban commented 6 years ago

I created a pull request #10 to fix this issue. When you make it concatenates all the files. The *.min.js file is just the concatonated version. You can still call the following to actually minify it:

make minify
camtauxe commented 6 years ago

I'm re-opening this issue because not minifying the code is really just a work-around, but the core issue of babel-minify not working is still present.

camtauxe commented 6 years ago

As another work-around, I made it so that it is possible to override what minify-ing tool is used on a particular person's machine. By default, it will use babel-minify, but if you have a file called 'minifier.local' in your working directory (ignored by git) then it will instead use the tool specified there.