Skip to content
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

Prevent nameclashes with internal variables #1737

Merged
merged 2 commits into from
Jul 16, 2018
Merged

Conversation

fathyb
Copy link
Contributor

@fathyb fathyb commented Jul 15, 2018

Fixes #1699

Found in core-js code

var $exports = module.exports = function (name) {
  return store[name] || (store[name] =
    USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
};

$exports.store = store;

@@ -121,7 +121,7 @@ module.exports = {
// Rename each binding in the top-level scope to something unique.
for (let name in scope.bindings) {
if (!name.startsWith('$' + t.toIdentifier(asset.id))) {
let newName = getName(asset, 'var', name);
let newName = getName(asset, 'var', name, '$');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should clash with anything. This would generate e.g. $id$var$exports vs our internal which is just $id$exports. Seems like the problem might be something else though I'm not sure why this would fix it...

@devongovett
Copy link
Member

Turns out the regex matching exports variables was wrong. Fixed it.

@devongovett devongovett merged commit 91a339e into master Jul 16, 2018
@devongovett devongovett deleted the fix/hoist-name-clash branch July 16, 2018 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants