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

Provide support for the Require.js cjsTranslate option #45

Closed
gfranko opened this issue May 18, 2014 · 2 comments
Closed

Provide support for the Require.js cjsTranslate option #45

gfranko opened this issue May 18, 2014 · 2 comments
Assignees
Labels

Comments

@gfranko
Copy link
Owner

gfranko commented May 18, 2014

Support the Require.js optimizer cjsTranslate option, which will allow support for "cleaning" CommonJS module code. This is currently broken in the current AMDclean release.

@gfranko
Copy link
Owner Author

gfranko commented Jun 1, 2014

Example CommonJS Code

// commonjs1.js
var commonjs2 = require('./commonjs2');

var _commonjs2_ = 'blah';

var commonjs4 = require('./commonjs4');

commonjs2.exampleFunc();

// commonjs2.js
module.exports = {
    'exampleBool': true,
    'exampleFunc': require('commonjs3').exampleFunc
}

// commonjs3.js
exports.exampleFunc = function() {
    var test = true;
    return test;
}

// commonjs4.js
exports.test = 'this is a test';

Standard JavaScript

var commonjs3, commonjs2, commonjs4, commonjs1;
commonjs3 = function (exports) {
    exports.exampleFunc = function () {
        var test = true;
        return test;
    };
    return exports;
}({});
commonjs2 = function (exports) {
    exports = {
        'exampleBool': true,
        'exampleFunc': commonjs3.exampleFunc
    };
    return exports;
}({});
commonjs4 = function (exports) {
    exports.test = 'this is a test';
    return exports;
}({});
commonjs1 = function (exports, __commonjs2__, _commonjs4_) {
    var commonjs2 = __commonjs2__;
    var _commonjs2_ = 'blah';
    var commonjs4 = _commonjs4_;
    commonjs2.exampleFunc();
    return exports;
}({}, commonjs2, commonjs4);

gfranko added a commit that referenced this issue Jun 2, 2014
@gfranko gfranko self-assigned this Jun 2, 2014
@gfranko
Copy link
Owner Author

gfranko commented Jun 6, 2014

This has been fixed in the 2.1.0 release.

@gfranko gfranko closed this as completed Jun 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant