Browse Source

Disallow 'default' as an identifier name

better-aggressive
Oskar Segersvärd 9 years ago
parent
commit
502b5cf940
  1. 3
      src/Module.js
  2. 5
      test/function/confused-default-identifier/_config.js
  3. 3
      test/function/confused-default-identifier/foo.js
  4. 6
      test/function/confused-default-identifier/main.js

3
src/Module.js

@ -24,6 +24,9 @@ class SyntheticDefaultDeclaration {
}
addReference ( reference ) {
// Don't change the name to `default`; it's not a valid identifier name.
if ( reference.name !== 'default' ) return;
reference.declaration = this;
this.name = reference.name;
}

5
test/function/confused-default-identifier/_config.js

@ -0,0 +1,5 @@
module.exports = {
description: 'Rollup should not get confused and allow "default" as an identifier name'
};
// https://github.com/rollup/rollup/issues/215

3
test/function/confused-default-identifier/foo.js

@ -0,0 +1,3 @@
export default function Foo () {
}

6
test/function/confused-default-identifier/main.js

@ -0,0 +1,6 @@
// export
export {default as Foo} from './foo';
export default function () {
// whatever
}
Loading…
Cancel
Save