I'm using the Bower package of Paper.js in a project. I'm using Gulp for preparing the project for the browser. There are some characters, however, that look like this in bower_components/paper/dist/paper-full.min.js:
\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec...
that end up like this after going through Gulp:
ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԧԱ-Ֆՙա-ևא-תװ-ײؠ-يٮ...
Resulting in a console error of
Uncaught SyntaxError: Invalid regular expression: /[ªµºÀ-ÖØ-öø-ˈ-Ë‘Ë -ˤˬˮͰ-ʹͶͷͺ-ͽΆΈ-ΊΌΎ-Ρ[Lots more strange characters] Range out of order in character class
Here is a relevant chunk of my gulp file:
var gulp = require('gulp');
var stylus = require('gulp-stylus');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var browserify = require('browserify');
var reactify = require('reactify');
var source = require('vinyl-source-stream');
var jade = require('gulp-jade');
var nib = require('nib');
var del = require('del');
var cfg = require('./cfg.json');
var action = {
clean: function(cb){
del([
['./', cfg.dir.root.dev].join('')
], cb);
},
concatLibs: function(){
gulp.src([
'./bower_components/jquery/dist/jquery.min.js',
'./bower_components/react/react.js',
'./bower_components/when/es6-shim/Promise.js',
'./bower_components/lodash/lodash.min.js',
'./bower_components/postal.js/lib/postal.min.js',
'./bower_components/oboe/dist/oboe-browser.min.js',
'./bower_components/paper/dist/paper-full.min.js'])
.pipe(uglify())
.pipe(concat('lib.js'))
.pipe(gulp.dest(['./', cfg.dir.root.dev, cfg.dir.type.js].join('')));
},
...
I've isolated the problem to this part of the process:
.pipe(uglify()) // in the concatLibs action
That is, commenting out this line does not generate the unusual characters, and does not result in a console error.
The uglify()
method seems to be the canonical one, required like so: var uglify = require('gulp-uglify')
. So what's the problem? Why is uglify()
causing this?