diff --git a/src/Module.js b/src/Module.js index 606f525..9db3dd8 100644 --- a/src/Module.js +++ b/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; } diff --git a/test/function/confused-default-identifier/_config.js b/test/function/confused-default-identifier/_config.js new file mode 100644 index 0000000..75c2e8f --- /dev/null +++ b/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 diff --git a/test/function/confused-default-identifier/foo.js b/test/function/confused-default-identifier/foo.js new file mode 100644 index 0000000..8b43bca --- /dev/null +++ b/test/function/confused-default-identifier/foo.js @@ -0,0 +1,3 @@ +export default function Foo () { + +} diff --git a/test/function/confused-default-identifier/main.js b/test/function/confused-default-identifier/main.js new file mode 100644 index 0000000..d4f149e --- /dev/null +++ b/test/function/confused-default-identifier/main.js @@ -0,0 +1,6 @@ +// export +export {default as Foo} from './foo'; + +export default function () { + // whatever +}