-
Notifications
You must be signed in to change notification settings - Fork 21
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
Sometimes having non-top-level things named the same as top-level things causes imports to be named incorrectly in bundles #45
Comments
It is necessary to check all declarations to prevent imports being shadowed (#18), but off the top of my head I'm not sure if that applies here.
- if ( hasOwnProp.call( otherMod.ast._declared, replacement ) ) {
+ if ( ~otherMod.ast._topLevelNames.indexOf( replacement ) ) { ...doesn't break any tests, though I can't guarantee it doesn't cause a variant of #18 to reappear - will need to check. Does Ractive build correctly if you make the change above? |
D'oh!
No, it still gets some imports prefixed incorrectly because there are some top-level identifiers that overlap too. Perhaps I'm approaching this from the wrong side... if the export was renamed to match its |
Hmm. Is there a branch somewhere I can clone? Would be keen to take a look and maybe try to extract a test case |
I pushed a temp branch here https://github.com/evs-chris/esperanto/tree/temp It's basically a fresh checkout of esperanto with some mild abuse to |
@evs-chris am kicking myself... - ... || otherModulesDeclare( mod, mod.name ) ?
+ ... || otherModulesDeclare( mod, x.name ) ? Have published 0.6.1 with this fix. |
👍 Ractive builds again! Kicking myself is three eighths of my exercise regimen. |
I haven't been able to reproduce this in simple test cases, but I have with the Ractive source. I'm not sure exactly why at this point, but (after fiddling about with merging
_Mustache.js
into one file)Section$bubble
was being included in the bundle unchanged, but when it was imported in_Section.js
, it was being mangled tobubble__Section$bubble
. The ostensible reason for that is that a few other modules have a declaredbubble
variable/function in them somewhere (fireEvents.js
, in my case). ModifyingotherModulesDeclare
to only look at top-level identifiers clears that up. Is there a reason to look at all of the identifiers instead of only those in the "global" namespace? No PR because I'm not entirely sure what is or should be going on, and there's probably a more appropriate fix :)The text was updated successfully, but these errors were encountered: