Pārlūkot izejas kodu

HUE-7008 [autocomplete] Minify the generated parsers

This removes roughly 25% of the size.
Johan Ahlen 8 gadi atpakaļ
vecāks
revīzija
738d9210eb

+ 24 - 1
Gruntfile.js

@@ -22,6 +22,7 @@ module.exports = function(grunt) {
   var config = {};
   grunt.loadNpmTasks('grunt-contrib-less');
   grunt.loadNpmTasks('grunt-contrib-watch');
+  grunt.loadNpmTasks('grunt-contrib-uglify');
 
   // Project configuration.
   grunt.initConfig({
@@ -97,6 +98,28 @@ module.exports = function(grunt) {
         ],
         tasks: ['less']
       }
+    },
+    uglify: {
+      sqlAutocompleteParser: {
+        files: {
+          'desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sqlAutocompleteParser.js': ['desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sqlAutocompleteParser.js']
+        }
+      },
+      sqlSyntaxParser: {
+        files: {
+          'desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sqlSyntaxParser.js': ['desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sqlSyntaxParser.js']
+        }
+      },
+      sqlStatementsParser: {
+        files: {
+          'desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sqlStatementsParser.js': ['desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sqlStatementsParser.js']
+        }
+      },
+      globalSearchParser: {
+        files: {
+          'desktop/core/src/desktop/static/desktop/js/autocomplete/jison/globalSearchParser.js': ['desktop/core/src/desktop/static/desktop/js/autocomplete/jison/globalSearchParser.js']
+        }
+      }
     }
   });
-};
+};

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 679
desktop/core/src/desktop/static/desktop/js/autocomplete/globalSearchParser.js


+ 1 - 1
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/license.txt

@@ -12,4 +12,4 @@
 // distributed under the License is distributed on an "AS IS" BASIS,
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 // See the License for the specific language governing permissions and
-// limitations under the License.
+// limitations under the License.

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 74
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlAutocompleteParser.js


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 759
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlStatementsParser.js


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 74
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlSyntaxParser.js


+ 4 - 0
tools/jison/hue-jison.sh

@@ -35,6 +35,7 @@ cat autocomplete_header.jison sql_main.jison sql_valueExpression.jison sql_error
 
 echo "Creating SQL autocomplete parser..."
 jison sqlAutocompleteParser.jison sql.jisonlex
+grunt uglify:sqlAutocompleteParser
 cat license.txt sqlAutocompleteParser.js > ../sqlAutocompleteParser.js
 rm sqlAutocompleteParser.jison
 rm sqlAutocompleteParser.js
@@ -47,6 +48,7 @@ jison sqlSyntaxParser.jison sql.jisonlex
 # Workaround for a parser bug where it reports the location of the previous token on error (pull-request submitted for jison)
 # We're also adding a ruleId to the parser error composed of the last two stack ID's and used for suppressing errors in the UI
 sed -i '' 's/loc: yyloc,/loc: lexer.yylloc, ruleId: stack.slice(stack.length - 2, stack.length).join(''),/' sqlSyntaxParser.js
+grunt uglify:sqlSyntaxParser
 cat license.txt sqlSyntaxParser.js > ../sqlSyntaxParser.js
 rm sqlSyntaxParser.jison
 rm sqlSyntaxParser.js
@@ -54,12 +56,14 @@ rm sqlSyntaxParser.js
 # === Statement parser ===
 echo "Creating SQL statements parser..."
 jison sqlStatementsParser.jison
+grunt uglify:sqlStatementsParser
 cat license.txt sqlStatementsParser.js > ../sqlStatementsParser.js
 rm sqlStatementsParser.js
 
 # === Global Search parser ===
 echo "Creating Global Search parser..."
 jison globalSearchParser.jison
+grunt uglify:globalSearchParser
 cat license.txt globalSearchParser.js > ../globalSearchParser.js
 rm globalSearchParser.js
 

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels