question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

commonJsToGoogmoduleTransformer misses some `module.exports = ...` statements.

See original GitHub issue

visitTopLevelStatement calls rewriteModuleExportsAssignment, which transforms statements of the form module.exports = foo to exports = foo. However, it fails to do that same transformation if that statement is used to assign something else as well (e.g. var bar = module.exports = foo should get transformed to var bar = exports = foo, but does not)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
evmarcommented, Nov 17, 2020

I think we don’t support commonjs in general, but only enough to massage TS’s commonjs output from ES module input. It’s not an intentional omission, we just have no TS code that uses commonjs directly.

0reactions
coreywoodfieldcommented, Nov 17, 2020

Ah okay. I just noticed that the first line was transformed but the second one wasn’t, which I figured was a bug. I assumed this would be supported because the code very deliberately replaces module.exports with exports, but not in all cases

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node Module Exports Explained - freeCodeCamp
exports being the exported component of any types - object, function, string, and so on. Default exporting in a Node.js module is as...
Read more >
javascript - webpack: import + module.exports in the same ...
I got the error Uncaught TypeError: Cannot assign to read only property 'exports' of object '#<Object>' . Turns out that changing import $...
Read more >
Understanding module.exports and exports in Node.js
James shows how to work with modules in Node.js, focusing on how to export and consume them, and explaining ... So what has...
Read more >
Add missing require() calls and module.exports statements
It uses ESLint programmatic API. codemode:addModuleExports. Find all javascripts inside app/components, filter by the lack of module.exports ...
Read more >
Node.js Module Exports - Demystified - Stackify
Understand Node.js Module Exports and get comfortable using the syntax. ... You'll see it's done with some pretty ugly-looking if-statements ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found