Loses inline functions in object assigned to module.exports
See original GitHub issueThe modules.commonjs
plugin doesn’t seem to understand overwriting module.exports
module.exports = {
controller : function() { },
view : function() { }
};
// converts into
export { undefined as controller, undefined as view };
If I instead directly assign to properties on the exports
object it does the right thing.
exports.controller = function() { };
exports.view = function() { };
// converts into
export function controller() { }
export function view() { }
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
module.exports vs exports in Node.js - Stack Overflow
Basically node.js doesn't export the object that exports currently references, but exports the properties of what exports originally references.
Read more >Module exports in Node.js explained - Java Brains - YouTube
Have you seen the new Java Brains? Check out www.javabrains.io now for awesome courses and content!Learn how to export your objects and ...
Read more >Node Module Exports Explained - freeCodeCamp
This is a common module exports mistake that people who are starting out with Node.js often make. They assign exports to a new...
Read more >16. Modules - Exploring JS
An ES6 module can pick a default export, the main exported value. Default exports are especially easy to import. The following ECMAScript 6...
Read more >Understanding module.exports and exports in Node.js
Here we're assigning the functions and values we want to export to an exports property on module — and of course, this works...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Related to this, an export of a single function fails with a stacktrace:
It’s the same with simple numbers: