Skip to content

Commit bc05c97

Browse files
committed
fix(barrel): fix export syntax for named exports
1 parent 020748d commit bc05c97

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

src/core/temlpates/components/BarrelTemplate.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ export class BarrelTemplate extends TemplateBase implements Template {
1818
? this.vars.componentName
1919
: 'default'
2020
),
21-
t.identifier(this.vars.componentName)
21+
t.identifier(
22+
config.exportType === 'named'
23+
? this.vars.componentName
24+
: 'default'
25+
)
2226
),
2327
],
2428
t.stringLiteral(`./${this.vars.fileName}`)

src/tests/e2e/Component.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,28 +81,30 @@ describe('Component', () => {
8181
await runGenerator({}, { answers, type });
8282
});
8383

84-
it('should create component: ts/css/test (arrow/default)', async () => {
84+
it('should create component: ts/css/test/barrel (arrow/default)', async () => {
8585
config.update({
8686
styles: 'css',
8787
typescript: true,
8888
arrowFunction: true,
8989
exportType: 'default',
9090
});
9191

92-
answers.name = 'ts/css/test (arrow-fn)';
92+
answers.name = 'ts/css/test/barrel (arrow-fn)';
93+
answers.barrel = true;
9394

9495
await runGenerator({}, { answers, type });
9596
});
9697

97-
it('should create component: js/css/test (arrow/exported)', async () => {
98+
it('should create component: js/css/test/barrel (arrow/exported)', async () => {
9899
config.update({
99100
styles: 'css',
100101
arrowFunction: false,
101102
jsxExt: false,
102103
exportType: 'named',
103104
});
104105

105-
answers.name = 'js/css/test (export-named)';
106+
answers.name = 'js/css/test/barrel (export-named)';
107+
answers.barrel = true;
106108

107109
await runGenerator({}, { answers, type });
108110
});

0 commit comments

Comments
 (0)