stealjs / steal

Gets JavaScript
https://stealjs.com
MIT License
1.37k stars 522 forks source link

Empty module exports in built output #1305

Open m-mujica opened 7 years ago

m-mujica commented 7 years ago

Sample code to replicate issue: https://github.com/asmarques1990/stealjs-antlr Reported on https://gitter.im/stealjs/steal?at=5a0c31c671ad3f8736e8d293

while debugging this with @chasenlehara we noticed the problem is in this module:

screen shot 2017-11-15 at 10 54 06

require('./RuleContext') returns an empty object when it should not.

The weird thing is that define is able to load './RuleContext' correctly (see line 3345) [arguments[4] has the things exported by the module]

If I step into that require it goes through this code

screen shot 2017-11-15 at 10 45 01

But entry.module.exports is still empty after the link happens.

matthewp commented 7 years ago

sure this isn't circular deps?

m-mujica commented 7 years ago

I did not check for that. Let me see.

m-mujica commented 7 years ago

Yup, so ParserRuleContext -> RuleContext -> antlr/tree/Trees -> ParserRuleContext

m-mujica commented 7 years ago

Also, RuleContext -> tree/Trees -> RuleContext

screen shot 2017-11-15 at 11 08 02

screen shot 2017-11-15 at 11 14 57

asmarques1990 commented 7 years ago

Thanks Guys! I'll open a PR to ANTLR4 with the fix. Meanwhile there is some workaround in StealJS?

m-mujica commented 7 years ago

@asmarques1990 We don't know if this is a bug in Steal.js yet. If you can reduce it down for us that would be awesome. You could either:

a) try to load antlr in Node.js and see if it works there. If the circular dependency is not a problem in Node.js, we have a bug.

b) Instead of testing in node you might also use something like webpack if it works there, then we need to figure out why it does not work in Steal.