Questions tagged [uglifyjs2]

A general-purpose JavaScript parser/compressor/beautifier toolkit developed on Node.js

112 questions
0
votes
1 answer

Can I beautify javascript with uglifyjs via API?

Can I programmaticaly beautify JavaScript code with UglifyJS library? When I try to use something like var uglifyjs = require('uglify-js'); ... var options = { compress: false, mangle: false, beautify: true }; var code = uglifyjs(source,…
Ivan Shatsky
  • 6,428
  • 2
  • 9
  • 24
0
votes
0 answers

How to minify legacy javascript libraries (ES6)

I have several legacy JS libraries for a website that I would like to minify (and ideally also concatenate into one bundle). However, since the libraries use ES6 syntax I cannot simply use uglify-js on command line and minify since it requires the…
kashiraja
  • 632
  • 11
  • 17
0
votes
1 answer

Uglify.js - how to mangle just SOME global variable/function names (using Grunt)

Hi, I'm using Grunt and Uglify.js to mangle my code and I found out that by default the global function/variable names are not mangled, which makes sense. I then found out, that there is a way on how to mangle them with using some settings but than…
Oliver Goossens
  • 1,823
  • 3
  • 19
  • 25
0
votes
0 answers

How to handle react set state using dictionary syntax with uglify?

React's documentation has handle change function which retrieves object key at the run time. https://reactjs.org/docs/forms.html#handling-multiple-inputs I have similar; //handles state change handleChange = prop => event => { …
Mohamed
  • 1,129
  • 1
  • 13
  • 32
0
votes
1 answer

Is it possible to stop UglifyJS from injecting "_" as a replacement name?

Is there a way to configure Uglify with a blacklist of strings that should not be injected during replacement? For example, Uglify is currently replacing TypeError with _: TypeError("Promise can't be resolved") => _("Promise can't be resolved").…
ssw
  • 143
  • 1
  • 4
0
votes
1 answer

Webpack's UglifyJsPlugin throws error with Node modules containing let

This is the relevant code (I'm using Vue.js' Webpack official template): .babelrc: "presets": [ "babel-preset-es2015", "babel-preset-stage-2", ] webpack.prod.config.js new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false, …
alex
  • 5,551
  • 8
  • 34
  • 67
0
votes
0 answers

How to mangle class names

How could I mangle class names like this (ES6) export class MyClass{....} using UglifyJS? I've already played around enough with different mangle options and combinations given in the API but still, no avail. On google search, almost all of the…
Desu
  • 567
  • 1
  • 6
  • 14
0
votes
1 answer

UglifyJS Can't use regex

From here, I can't seem to use this uglifyjs mtool.js -c -m --mangle-props regex=/_$/ -o mtool.min.js as it produces an error: ERROR: regex.test is not a function at should_mangle (eval at …
Desu
  • 567
  • 1
  • 6
  • 14
0
votes
0 answers

UglifyJs output line length restriction

I am using the following snippets while building my react based application with webpack. I need to restrict the max line length of the output file to 7000 characters and the below config helps do it except if there is a CSS line in the bundle. The…
0
votes
1 answer

How to configure UglifyJS 2 to only concatenate in C#?

I'm using UglifyJS2 for the Bundle Transformer NuGet package within my C# project and I just want to be able to concatenate my JS files without minifying them for my QA environment, but I can't figure out how to do it. Is it possible? Here is my…
adam0101
  • 23,476
  • 18
  • 75
  • 147
0
votes
0 answers

UglifyJS trying to mangle RamdaJS produces error

I am trying to mangle my code using UglifyJS. The libraries i include are (some) Ramda, React, Underscore, react-select ... However when i mangle the code, in RamdaJS "output" section it gives me the error : First argument to arity must be…
Razvan
  • 670
  • 3
  • 9
  • 23
0
votes
1 answer

uglifyjs mangle props ".source" error

I have some problems using UglifyJS. When i am using uglifyjs with this command: uglifyjs -o live_ugly.js --compress --mangle-props 1 --mangle -r "$,require,exports" live.js I gives me an error : Cannot read property 'source' of undefined The code…
Razvan
  • 670
  • 3
  • 9
  • 23
0
votes
1 answer

Babel transforming new Request (fetch-api) to function call, causing errors in Chrome

I wrote a separate API library that I'm keeping as pure ES6 (with generators, etc) but it relies on the isomorphic-fetch library (so it can be used in both node and browser contexts). When importing it with webpack 2 in another project, everything…
0
votes
1 answer

Why does UglifyJS transpile `someFunction` to `(0, v.someFunction)`?

I'm using UglifyJS to transpile a React web app, and I noticed that it seems to wrap a lot of function calls, specifically functions imported from another module/file, with (0, and ). What is the point of this? Example: It transpiles this var…
ahstro
  • 3,832
  • 3
  • 21
  • 45
0
votes
1 answer

UglifyJS2 call minify function programmatically

I would like to know if I can call the minify main function programmatically. I am able to run the same code as defined in compress, however replacing UglifyJS.Compressor with UglifyJS.minify does not work. This is because I would like to pass the…
nha
  • 16,039
  • 11
  • 76
  • 108