Skip to content

Commit

Permalink
feat: use es2015 syntax to re-export default export (#32)
Browse files Browse the repository at this point in the history
BREAKING CHANGE:

This changes the output generated by create-index and can effect CI if it runs linting tests against create-index.
  • Loading branch information
Guibod authored and gajus committed Jan 27, 2017
1 parent 893d993 commit 65892e3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/utilities/createIndexCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const buildExportBlock = (files) => {
let importBlock;

importBlock = _.map(files, (fileName) => {
return 'export ' + safeVariableName(fileName) + ' from \'./' + fileName + '\';';
return 'export { default as ' + safeVariableName(fileName) + ' } from \'./' + fileName + '\';';
});

importBlock = importBlock.join('\n');
Expand Down
12 changes: 6 additions & 6 deletions test/createIndexCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('createIndexCode()', () => {
expect(indexCode).to.equal(codeExample(`
// @create-index
export foo from './foo';
export { default as foo } from './foo';
`));
});
it('describes multiple children', () => {
Expand All @@ -29,8 +29,8 @@ export foo from './foo';
expect(indexCode).to.equal(codeExample(`
// @create-index
export bar from './bar';
export foo from './foo';
export { default as bar } from './bar';
export { default as foo } from './foo';
`));
});
context('file with extension', () => {
Expand All @@ -40,7 +40,7 @@ export foo from './foo';
expect(indexCode).to.equal(codeExample(`
// @create-index
export foo from './foo.js';
export { default as foo } from './foo.js';
`));
});
});
Expand All @@ -51,8 +51,8 @@ export foo from './foo.js';
expect(indexCode).to.equal(codeExample(`
// @create-index
export bar from './bar';
export foo from './foo';
export { default as bar } from './bar';
export { default as foo } from './foo';
`));
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/write-index/mixed/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @create-index

export bar from './bar';
export foo from './foo.js';
export { default as bar } from './bar';
export { default as foo } from './foo.js';

4 changes: 2 additions & 2 deletions test/writeIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ describe('writeIndex()', () => {
expect(indexCode).to.equal(codeExample(`
// @create-index
export bar from './bar';
export foo from './foo.js';
export { default as bar } from './bar';
export { default as foo } from './foo.js';
`));
});
});

0 comments on commit 65892e3

Please sign in to comment.