Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScript interface breaks if options object not provided #1

Closed
mpj opened this issue Dec 17, 2012 · 1 comment
Closed

JavaScript interface breaks if options object not provided #1

mpj opened this issue Dec 17, 2012 · 1 comment

Comments

@mpj
Copy link

mpj commented Dec 17, 2012

When using wrapup from JavaScript (i.e. not the command line) one must provide an object (empty object works) to the options method, or one will get an error from Uglify.

Example 1: WORKS!

var wrup = require("wrapup")(),
    fs = require('fs');

wrup.require("chai", "./node_modules/beautiful-lies")
    .options({
      compress: true
    })
    .up(function(err, js){
       fs.writeFile("./__requirements-wrapped-up.js", js)
    });

Example 2: ALSO WORKS!

var wrup = require("wrapup")(),
    fs = require('fs');

wrup.require("chai", "./node_modules/beautiful-lies")
    .options({
      compress: false
    })
    .up(function(err, js){
       fs.writeFile("./__requirements-wrapped-up.js", js)
    });

Example 3: THIS WORKS TOO!!!

var wrup = require("wrapup")(),
    fs = require('fs');

wrup.require("chai", "./node_modules/beautiful-lies")
    .options({
      //compress: false
    })
    .up(function(err, js){
       fs.writeFile("./__requirements-wrapped-up.js", js)
    });

Example 4: BREAKS HORRIBLY!

var wrup = require("wrapup")(),
    fs = require('fs');

wrup.require("chai", "./node_modules/beautiful-lies")
    //.options({
      //compress: false
    //})
    .up(function(err, js){
       fs.writeFile("./__requirements-wrapped-up.js", js)
    });

The error output!

        /Users/mpj/code/library/test/node_modules/wrapup/node_modules/uglify-js/lib/output.js:110
        name = name.toString();
                    ^
TypeError: Cannot call method 'toString' of undefined
    at make_name (/Users/mpj/code/library/test/node_modules/wrapup/node_modules/uglify-js/lib/output.js:110:21)
    at Object.OutputStream.print_name (/Users/mpj/code/library/test/node_modules/wrapup/node_modules/uglify-js/lib/output.js:314:50)
    at /Users/mpj/code/library/test/node_modules/wrapup/node_modules/uglify-js/lib/output.js:1032:16
    at AST_Node.print (/Users/mpj/code/library/test/node_modules/wrapup/node_modules/uglify-js/lib/output.js:355:17)
    at /Users/mpj/code/library/test/node_modules/wrapup/node_modules/uglify-js/lib/output.js:944:25
    at AST_Node.print (/Users/mpj/code/library/test/node_modules/wrapup/node_modules/uglify-js/lib/output.js:355:17)
    at /Users/mpj/code/library/test/node_modules/wrapup/node_modules/uglify-js/lib/output.js:961:19
    at AST_Node.print (/Users/mpj/code/library/test/node_modules/wrapup/node_modules/uglify-js/lib/output.js:355:17)
    at /Users/mpj/code/library/test/node_modules/wrapup/node_modules/uglify-js/lib/output.js:572:19
    at AST_Node.print (/Users/mpj/code/library/test/node_modules/wrapup/node_modules/uglify-js/lib/output.js:355:17)

​
@arian arian closed this as completed in 7d653ab Dec 18, 2012
@arian
Copy link
Member

arian commented Dec 18, 2012

Yes, forgot to set the default options correctly, so when using a named module, it didn't know which global variable it had to use (default is window).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants