1rosehip / jplist

jPList jQuery Data Grid Controls is a flexible jQuery plugin for sorting, pagination and filtering of any HTML structure (DIVs, UL/LI, tables, etc).
http://jplist.com
Other
436 stars 177 forks source link

Compiling minfied files from the source #239

Closed mistyn8 closed 7 years ago

mistyn8 commented 7 years ago

I'm working on Windows 10, with node v6.9.1 download the zip of the repo and extract. launch the node cmd prompt run >npm run jscore Error: Cannot find module 'closurecompiler'

after a little searching '>npm install closurecompiler Configuring ClosureCompiler.js 1.5.2 ... Configuring JRE ... ✔ Global Java is available, perfect! ✔ ClosureCompiler.js has successfully been configured!

I then again try >npm run jscore

now errors with Error: Unable to access jarfile [..]\jplist-master\node_modules\closurecompiler/compiler/compiler.jar

If I look at the path... I see closure-compiler-v20161201.jar So assume renaming that should be what's necessary

the compile task then completes.

However, if I now compare the previous with the newly compiled, they aren't the same??? my compiled version starts with var $jscomp={scope:{},findInternal:function(a,b,d){a instanceof String&&(a=String(a));for(var c=a.length,e=0;e<c;e++) etc....

Any pointers for what I'm doing wrong???

1rosehip commented 7 years ago

I think the issue that you've installed the wrong version of closure compiler. If you check the package.json file of jplist project https://github.com/1rosehip/jplist/blob/master/package.json you can see the version of every library that should be installed in devDependencies section.

So you can do the following: Uninstall the current version of closure

npm uninstall closurecompiler

And then install all needed libs with the right versions:

npm install

In this case npm automatically installs all needed modules according to their versions in package.json file

You can read more about the install command here: https://docs.npmjs.com/cli/install

mistyn8 commented 7 years ago

Thanks for the response.. so I did exactly this.. unzip and from a node prompt in the root of the uzipped archive...

npm install npm did its thing... then

\jplist-master>npm run jsaddon -- bootstrap-pagination-bundle

jplist@5.2.0 jsaddon G:\visual studio 2015\Projects\JP\trifast\jplist-master node ./build/closure/rebuild-addon.js "bootstrap-pagination-bundle"

Error: Unable to access jarfile [..]\jplist-master\node_modules\closurecompiler/compiler/compiler.jar

again if I look at that location...

image

the jar filer is misnamed?

I did notice that https://www.npmjs.com/package/closurecompiler says this package is actually deprecated.... and see that you have in your build folder a google-closure-compiler folder have you perhaps aliased the deprecated one to google and I need to do something to that end?

1rosehip commented 7 years ago

Thank you for catching that, it was really a deprecation issue: https://github.com/dcodeIO/ClosureCompiler.js/issues/46

I've updated the package.json file - please download it again and perform npm install command. It should work now. Please let me know if you still have any issues with this.

mistyn8 commented 7 years ago

Yep that now successfully compiles after the npm install.. (there's a few warnings about other deprecated items but think those are from the dependancies)

However, I'm back to now if I compile bootstrap-pagination-bundle without changing anything from the downloaded source.. the dist file from the source doesn't match the freshly compiled file. :-( There seems to be 1Kb of extra code associated with $jscomp ?? So not sure what I'm doing wrong... :-(

I've attached the file that compiling pumps out. (changed to txt so that I can simply upload here) jplist.bootstrap-pagination-bundle.min.txt

1rosehip commented 7 years ago

I'm not sure if it should be the same. Maybe a new version on closure compiler uses a bit different algorithm for minification. Have yo tried this js file within your project? Do you see any issues in it's work?

mistyn8 commented 7 years ago

I haven't tried it as yet, but thought the idea of a shared repository + npm modules was that the build script should produce the exact same output.. If it adds an extra 1k to each of the add-ons I'm using that starts to mount up, and I'm guessing that the extra as it appears to be polyfills will be needlessly included in each bundle rather than an external shared reference?

Can you not specify that it uses the same version that you are currently building against? So I can replicate your setup?

Thank you kindly for your help this far.

1rosehip commented 7 years ago

Actually, I prefer to update closure compiler to the newest version. IMHO it's not so good to use something deprecated. I'm going to run tests with the new version and check if all is well later today and let you know. You are also welcome to check it.

1rosehip commented 7 years ago

After some testing I haven't found any issues with the newly compiled files. Please let me know it works for you too.