Skip to content

Commit a1e3131

Browse files
author
Robert Jackson
committed
Ensure reexported components do not throw an error.
1 parent c8c7b2a commit a1e3131

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

lib/colocated-broccoli-plugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ module.exports = class ColocatedTemplateProcessor extends Plugin {
150150
}
151151
);
152152

153-
if (!jsContents.includes('export default')) {
153+
if (hasTemplate && !jsContents.includes('export default')) {
154154
let message = `\`${relativePath}\` does not contain a \`default export\`. Did you forget to export the component class?`;
155155
jsContents = `${jsContents}\nthrow new Error(${JSON.stringify(message)});`;
156156
prefix = '';

node-tests/colocated-broccoli-plugin-test.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,55 @@ describe('ColocatedTemplateCompiler', function() {
137137
);
138138
});
139139

140+
it('works for re-exported component without a template', async function() {
141+
input.write({
142+
'app-name-here': {
143+
'router.js': '// stuff here',
144+
components: {
145+
'foo.js': `export { default } from 'some-place';`,
146+
},
147+
templates: {
148+
'application.hbs': `{{outlet}}`,
149+
},
150+
},
151+
});
152+
153+
let tree = new ColocatedTemplateCompiler(input.path());
154+
155+
output = createBuilder(tree);
156+
await output.build();
157+
158+
assert.deepStrictEqual(output.read(), {
159+
'app-name-here': {
160+
'router.js': '// stuff here',
161+
components: {
162+
'foo.js': `export { default } from 'some-place';`,
163+
},
164+
templates: {
165+
'application.hbs': '{{outlet}}',
166+
},
167+
},
168+
});
169+
170+
await output.build();
171+
172+
assert.deepStrictEqual(output.changes(), {}, 'NOOP update has no changes');
173+
174+
input.write({
175+
'app-name-here': {
176+
'router.js': '// other stuff here',
177+
},
178+
});
179+
180+
await output.build();
181+
182+
assert.deepStrictEqual(
183+
output.changes(),
184+
{ 'app-name-here/router.js': 'change' },
185+
'has only related changes'
186+
);
187+
});
188+
140189
it('works for typescript component class with template', async function() {
141190
input.write({
142191
'app-name-here': {

0 commit comments

Comments
 (0)