require1k icon indicating copy to clipboard operation
require1k copied to clipboard

Exports object does not contains modules

Open nraibaud opened this issue 7 years ago • 0 comments

This sample in the readme does not works.

<script>
R(function (require, module, exports) {
    var index = require("./index");
    exports.hello = "World!"
}, function (err, exports) {
    if (err) {
        console.error(err.statusText);
        return;
    }

    console.log(exports.hello)
});
</script>

This one works well 👍

<script>
R(function (require, module, exports) {
    var index = require("./index");
    exports.exports.hello = "World!"; // Here it is attached to the good object.
}, function (err, exports) {
    if (err) {
        console.error(err.statusText);
        return;
    }

    console.log(exports.hello)
});
</script>

Solutions : Modify the readme OR Modify the source code.

nraibaud avatar May 23 '18 23:05 nraibaud