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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/scope-hoisting/concat.js
Expand Up @@ -7,7 +7,7 @@ const treeShake = require('./shake');
const mangleScope = require('./mangler');
const {getName, getIdentifier} = require('./utils');

const EXPORTS_RE = /^\$(.+?)\$exports$/;
const EXPORTS_RE = /^\$([^$]+)\$exports$/;

const DEFAULT_INTEROP_TEMPLATE = template(
'var NAME = $parcel$interopDefault(MODULE)'
Expand Down
2 changes: 1 addition & 1 deletion src/scope-hoisting/shake.js
@@ -1,6 +1,6 @@
const t = require('babel-types');

const EXPORTS_RE = /^\$(.+?)\$exports$/;
const EXPORTS_RE = /^\$([^$]+)\$exports$/;

/**
* This is a small small implementation of dead code removal specialized to handle
Expand Down
3 changes: 3 additions & 0 deletions test/integration/scope-hoisting/es6/name-clash/a.js
@@ -0,0 +1,3 @@
import {foo} from './b'

output = foo()
3 changes: 3 additions & 0 deletions test/integration/scope-hoisting/es6/name-clash/b.js
@@ -0,0 +1,3 @@
var $exports = module.exports = {}

$exports.foo = () => 'bar'
9 changes: 9 additions & 0 deletions test/scope-hoisting.js
Expand Up @@ -330,6 +330,15 @@ describe('scope hoisting', function() {
let output = await run(b);
assert.deepEqual(output, 'bar');
});

it('should not nameclash with internal variables', async function() {
let b = await bundle(
__dirname + '/integration/scope-hoisting/es6/name-clash/a.js'
);

let output = await run(b);
assert.deepEqual(output, 'bar');
});
});

describe('commonjs', function() {
Expand Down