Uglifyjs: TypeError: S.input is not a function

Created on 5 Jul 2017  路  5Comments  路  Source: mishoo/UglifyJS

Bug report or feature request?

Bug report

ES5 or ES6+ input?

ES5

Uglify version (uglifyjs -V)

3.0.23

JavaScript input

function (source, path) {
    let result = UglifyJS.minify({ path: source })
    if (result.error !== undefined) {
       console.log(result.error)
       return source
    }
    return result.code
}

JavaScript output or error produced.

TypeError: S.input is not a function
    at next (eval at <anonymous> (D:\Code\Go\src\github.com\hacdias\filemanager\_assets\node_modules\uglify-js\tools\node.js:21:1), <anonymous>:2025:25)
    at parse (eval at <anonymous> (D:\Code\Go\src\github.com\hacdias\filemanager\_assets\node_modules\uglify-js\tools\node.js:21:1), <anonymous>:2011:15)
    at Object.minify (eval at <anonymous> (D:\Code\Go\src\github.com\hacdias\filemanager\_assets\node_modules\uglify-js\tools\node.js:21:1), <anonymous>:10541:42)
    at Object.transform (D:\Code\Go\src\github.com\hacdias\filemanager\_assets\build\webpack.base.conf.js:81:33)
    at D:\Code\Go\src\github.com\hacdias\filemanager\_assets\node_modules\copy-webpack-plugin\dist\writeFile.js:49:35
    at tryCatcher (D:\Code\Go\src\github.com\hacdias\filemanager\_assets\node_modules\bluebird\js\main\util.js:26:23)
    at Promise._settlePromiseFromHandler (D:\Code\Go\src\github.com\hacdias\filemanager\_assets\node_modules\bluebird\js\main\promise.js:510:31)
    at Promise._settlePromiseAt (D:\Code\Go\src\github.com\hacdias\filemanager\_assets\node_modules\bluebird\js\main\promise.js:584:18)
    at Promise._settlePromises (D:\Code\Go\src\github.com\hacdias\filemanager\_assets\node_modules\bluebird\js\main\promise.js:700:14)
    at Async._drainQueue (D:\Code\Go\src\github.com\hacdias\filemanager\_assets\node_modules\bluebird\js\main\async.js:123:16)
    at Async._drainQueues (D:\Code\Go\src\github.com\hacdias\filemanager\_assets\node_modules\bluebird\js\main\async.js:133:10)
    at Immediate.Async.drainQueues (D:\Code\Go\src\github.com\hacdias\filemanager\_assets\node_modules\bluebird\js\main\async.js:15:14)
    at runCallback (timers.js:672:20)
    at tryOnImmediate (timers.js:645:5)
    at processImmediate [as _immediateCallback] (timers.js:617:5)

Most helpful comment

It's working! Thanks @alexlamsl

All 5 comments

What is source? minify() expects it to be a string containing JavaScript code.

Source is a Buffer with JS code, yes. I'm minifying a couple of JS files (every file inside those folders: https://github.com/codemirror/CodeMirror/tree/master/mode )

It needs to be a string - uglify-js does not handle Buffer.

Oh, sorry then. I'll try to convert this to a string.

It's working! Thanks @alexlamsl

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pvdz picture pvdz  路  3Comments

alexlamsl picture alexlamsl  路  5Comments

andreialecu picture andreialecu  路  5Comments

alexlamsl picture alexlamsl  路  4Comments

Havunen picture Havunen  路  5Comments