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
Add 'module' variable for modules #520
Comments
And also ensure that |
please bear in mind that reassigning exports = function wut() {}; If we require that file in node the exported value would be just a regular empty object. In order to actually overwrite the module.exports = function wut() {}; Inside a module, and only when required, However, in the main file, function log(s) {
console.log(s);
}
if (this === global) {
log('main');
} else {
module.exports = log;
} |
As summary, this is how in JS you would evaluate a module: function evalRequire(scriptContent) {
var exports = {};
var module = {exports: exports};
Function(
'global,exports,module',
scriptContent
).call(
exports,
global,
exports,
module
);
return module.exports;
} As you can see, replacing the
|
Thanks, yes, it does. I'm actually pretty sure I added the |
http://forum.espruino.com/comments/12223159/
This should work - currently you need to use just
exports
:The text was updated successfully, but these errors were encountered: