diff --git a/.travis.yml b/.travis.yml index 8cd6eee4fa..7760208089 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ install: - rm -rf node_modules - npm install - export PATH=$PWD/node_modules/.bin:$PATH - - export NODE_OPTIONS="--max-old-space-size=3072" + - export NODE_OPTIONS="--max-old-space-size=4096" - export TZ=America/Los_Angeles script: # [Error] module QtQuick is not installed diff --git a/docs/ReleaseNotes.md b/docs/ReleaseNotes.md index bbabb00928..9cba62f19c 100644 --- a/docs/ReleaseNotes.md +++ b/docs/ReleaseNotes.md @@ -23,6 +23,7 @@ part of the locale specifier if it has a very common/default value * For languages that are written in multiple scripts, but where one is dominant, the script is only included when it is not the default/dominant one * Most languages are only ever written in one script, so the script is left out * Updated the script info to UCD 12.0.0, and the likely locale info to CLDR 35.1 +* Added source maps to the npm package so that you can debug into the original ilib code easily Bug Fixes: * Fixed unit test failures which occur on QT 5.12 diff --git a/js/Gruntfile.js b/js/Gruntfile.js new file mode 100644 index 0000000000..2a9a550a53 --- /dev/null +++ b/js/Gruntfile.js @@ -0,0 +1,126 @@ +/** + * Gruntfile.js - build the ilib javascript project + * + * @license + * Copyright © 2019, JEDLSoft + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * 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. + */ + +module.exports = function(grunt) { + require('load-grunt-tasks')(grunt); + + // Project configuration. + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + mkdir: { + prepare: { + options: { + create: [ + 'locale', + 'output', + 'output/reports', + 'output/js', + 'output/dyncode', + 'output/dyncode/lib', + 'output/dyncode/src/lib', + 'output/test', + 'output/jsdoc' + ] + } + } + }, + copy: { + src: { + files: [{ + cwd:"lib", + src: [ + "**/*.js", + "!**/ilib.js", + '!**/ilib-*.js', + '!externs.js', + '!datefmtstr.js', + '!ilib-stubs*', + "!**/metafiles/*" + ], + dest: 'output/dyncode/src/lib', + expand: true + },{ + cwd:"lib", + src: [ + "ilib-node*", + "ilib-qt*", + "ilib-webpack*", + "ilib-unpack.js", + "ilib-web.js" + ], + dest: 'output/dyncode/src/lib', + expand: true + },{ + src: [ + "index.js" + ], + dest: 'output/dyncode/src', + expand: true + }] + } + }, + replace: { + version: { + src: [ + "lib/ilib.js" + ], + dest: "output/dyncode/src/lib/ilib.js", + replacements: [{ + from: '// !macro ilibVersion', + to: '"<%= pkg.version %>"' + }] + } + }, + uglify: { + lib: { + options: { + banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n', + mangle: false, + sourceMap: true, + output: { + comments: "/(\!data|\!loadLocaleData|\!defineLocaleData|\!macro|eslint-)/" + } + }, + files: [{ + expand: true, + cwd: 'output/dyncode/src', + src: [ + '**/*.js' + ], + dest: 'output/dyncode' + }] + } + }, + clean: { + dist: ['lib'] + } + }); + + // Load the plugin that provides the "uglify" task. + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-copy'); + grunt.loadNpmTasks('grunt-mkdir'); + + // Default task(s). + // grunt.registerTask('default', ['uglify']); + // grunt.registerMultiTask('mkdir', ['mkdir']); + // grunt.registerMultiTask('copy', ['copy']); + grunt.registerTask('uglifypkg', ['mkdir:prepare', 'copy:src', 'replace:version', 'uglify:lib']); +}; diff --git a/js/build.properties b/js/build.properties index 4a3440321d..359c34f41b 100644 --- a/js/build.properties +++ b/js/build.properties @@ -18,3 +18,4 @@ CLOSURECOMP=${basedir}/../tools/google-closure-compiler.r20150920 WEBPACKDIR=${basedir}/../node_modules/webpack uglify.location=${basedir}/../node_modules/uglify-js webpack.command=${basedir}/../node_modules/.bin/webpack +webpack.heap.size=4096 \ No newline at end of file diff --git a/js/build.xml b/js/build.xml index 41ae0a4df0..beb2fa7b06 100644 --- a/js/build.xml +++ b/js/build.xml @@ -24,7 +24,7 @@ limitations under the License. - + @@ -40,6 +40,7 @@ limitations under the License. + @@ -116,8 +117,8 @@ limitations under the License. + - @@ -132,7 +133,7 @@ limitations under the License. executing webpack - + @@ -143,7 +144,7 @@ limitations under the License. - + @@ -289,102 +290,38 @@ limitations under the License. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - + + + - - + + + + + - + - - + @@ -403,25 +340,26 @@ limitations under the License. - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + + @@ -434,7 +372,7 @@ limitations under the License. - + @@ -454,32 +392,15 @@ limitations under the License. - + - - - - - - - - - - - - - - - - - @@ -526,11 +447,11 @@ limitations under the License. Executing webpack - + - + @@ -539,11 +460,11 @@ limitations under the License. Executing webpack - + - + diff --git a/js/package.json.template b/js/package.json.template index d2e74646b1..e3c99a8710 100644 --- a/js/package.json.template +++ b/js/package.json.template @@ -50,16 +50,14 @@ "type": "git", "url": "git@github.com:iLib-js/iLib.git" }, - "repositories": [ - { - "type": "git", - "url": "git@github.com:iLib-js/iLib.git" - } - ], "scripts": { "test": "ant test" }, "devDependencies": { - "http-server": "^0.9.0" + "grunt-contrib-copy": "^1.0.0", + "grunt-contrib-uglify": "^4.0.1", + "grunt-mkdir": "^1.0.0", + "grunt-text-replace": "^0.4.0", + "http-server": "^0.9.0" } } diff --git a/js/webpack.config.js b/js/webpack.config.js index d485f5859c..0f6b0c7c6f 100644 --- a/js/webpack.config.js +++ b/js/webpack.config.js @@ -98,6 +98,10 @@ module.exports = function(env, args) { loader: 'ilib-webpack-loader', options: options } + },{ + test: /\.js$/, + use: ["source-map-loader"], + enforce: "pre" }] }, plugins: [ @@ -125,6 +129,7 @@ module.exports = function(env, args) { ret.plugins.splice(0, 0, new UglifyJsPlugin({ cache: true, parallel: 4, + sourceMap: true, uglifyOptions: { compress: true, warnings: true diff --git a/package.json b/package.json index 1064e02985..b33977dc42 100644 --- a/package.json +++ b/package.json @@ -54,13 +54,14 @@ "babel-loader": "^7.1.5", "cldr-data": "^34.0.0", "ejs": "^2.6.1", - "grunt": "^1.0.3", - "grunt-cli": "^1.2.0", - "grunt-contrib-clean": "^1.1.0", + "grunt": "^1.0.4", + "grunt-cli": "^1.3.2", + "grunt-contrib-clean": "^2.0.0", + "grunt-contrib-jshint": "^2.1.0", "grunt-contrib-compress": "^1.4.3", "grunt-contrib-copy": "^1.0.0", - "grunt-contrib-nodeunit": "~0.4.1", - "grunt-contrib-uglify": "^3.4.0", + "grunt-contrib-nodeunit": "^2.0.0", + "grunt-contrib-uglify": "^4.0.1", "grunt-eslint": "^21.0.0", "grunt-http-server": "^2.1.0", "grunt-jsdoc": "^2.2.1", @@ -74,12 +75,15 @@ "ilib-webpack-loader": "^1.3.0", "ilib-webpack-plugin": "^1.3.0", "iso-15924": "^2.1.0", + "jit-grunt": "^0.10.0", "jsdoc2": "^2.4.0", + "load-grunt-tasks": "^5.0.0", "nodeunit": "^0.11.0", "should": "^13.2.3", + "source-map-loader": "^0.2.4", "tap": "^10.0.2", "trireme": "^0.9.3", - "uglify-js": "^3.4.9", + "uglify-js2": "^2.1.11", "uglifyjs-webpack-plugin": "^1.3.0", "webpack": "^4.32.2", "webpack-cli": "^3.3.2",