diff --git a/src/utilities/createIndexCode.js b/src/utilities/createIndexCode.js index 8b84a51..a39faa0 100644 --- a/src/utilities/createIndexCode.js +++ b/src/utilities/createIndexCode.js @@ -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'); diff --git a/test/createIndexCode.js b/test/createIndexCode.js index 2d50057..5feb6c6 100644 --- a/test/createIndexCode.js +++ b/test/createIndexCode.js @@ -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', () => { @@ -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', () => { @@ -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'; `)); }); }); @@ -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'; `)); }); }); diff --git a/test/fixtures/write-index/mixed/index.js b/test/fixtures/write-index/mixed/index.js index 6b4bf06..253e7c7 100644 --- a/test/fixtures/write-index/mixed/index.js +++ b/test/fixtures/write-index/mixed/index.js @@ -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'; diff --git a/test/writeIndex.js b/test/writeIndex.js index 403a7fe..828969b 100644 --- a/test/writeIndex.js +++ b/test/writeIndex.js @@ -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'; `)); }); });