feat: use es2015 syntax to re-export default export (#32)
BREAKING CHANGE: This changes the output generated by create-index and can effect CI if it runs linting tests against create-index.
This commit is contained in:
committed by
Gajus Kuizinas
parent
893d9931d4
commit
65892e3bb8
@@ -14,7 +14,7 @@ const buildExportBlock = (files) => {
|
|||||||
let importBlock;
|
let importBlock;
|
||||||
|
|
||||||
importBlock = _.map(files, (fileName) => {
|
importBlock = _.map(files, (fileName) => {
|
||||||
return 'export ' + safeVariableName(fileName) + ' from \'./' + fileName + '\';';
|
return 'export { default as ' + safeVariableName(fileName) + ' } from \'./' + fileName + '\';';
|
||||||
});
|
});
|
||||||
|
|
||||||
importBlock = importBlock.join('\n');
|
importBlock = importBlock.join('\n');
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ describe('createIndexCode()', () => {
|
|||||||
expect(indexCode).to.equal(codeExample(`
|
expect(indexCode).to.equal(codeExample(`
|
||||||
// @create-index
|
// @create-index
|
||||||
|
|
||||||
export foo from './foo';
|
export { default as foo } from './foo';
|
||||||
`));
|
`));
|
||||||
});
|
});
|
||||||
it('describes multiple children', () => {
|
it('describes multiple children', () => {
|
||||||
@@ -29,8 +29,8 @@ export foo from './foo';
|
|||||||
expect(indexCode).to.equal(codeExample(`
|
expect(indexCode).to.equal(codeExample(`
|
||||||
// @create-index
|
// @create-index
|
||||||
|
|
||||||
export bar from './bar';
|
export { default as bar } from './bar';
|
||||||
export foo from './foo';
|
export { default as foo } from './foo';
|
||||||
`));
|
`));
|
||||||
});
|
});
|
||||||
context('file with extension', () => {
|
context('file with extension', () => {
|
||||||
@@ -40,7 +40,7 @@ export foo from './foo';
|
|||||||
expect(indexCode).to.equal(codeExample(`
|
expect(indexCode).to.equal(codeExample(`
|
||||||
// @create-index
|
// @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(`
|
expect(indexCode).to.equal(codeExample(`
|
||||||
// @create-index
|
// @create-index
|
||||||
|
|
||||||
export bar from './bar';
|
export { default as bar } from './bar';
|
||||||
export foo from './foo';
|
export { default as foo } from './foo';
|
||||||
`));
|
`));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
// @create-index
|
// @create-index
|
||||||
|
|
||||||
export bar from './bar';
|
export { default as bar } from './bar';
|
||||||
export foo from './foo.js';
|
export { default as foo } from './foo.js';
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -29,8 +29,8 @@ describe('writeIndex()', () => {
|
|||||||
expect(indexCode).to.equal(codeExample(`
|
expect(indexCode).to.equal(codeExample(`
|
||||||
// @create-index
|
// @create-index
|
||||||
|
|
||||||
export bar from './bar';
|
export { default as bar } from './bar';
|
||||||
export foo from './foo.js';
|
export { default as foo } from './foo.js';
|
||||||
`));
|
`));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user