Skip to content

Commit

Permalink
Merge pull request #390 from ember-cli/fix-issue-with-reexports
Browse files Browse the repository at this point in the history
Ensure reexported components do not throw an error.
  • Loading branch information
rwjblue authored Dec 11, 2019
2 parents c8c7b2a + a1e3131 commit fe901c8
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/colocated-broccoli-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ module.exports = class ColocatedTemplateProcessor extends Plugin {
}
);

if (!jsContents.includes('export default')) {
if (hasTemplate && !jsContents.includes('export default')) {
let message = `\`${relativePath}\` does not contain a \`default export\`. Did you forget to export the component class?`;
jsContents = `${jsContents}\nthrow new Error(${JSON.stringify(message)});`;
prefix = '';
Expand Down
49 changes: 49 additions & 0 deletions node-tests/colocated-broccoli-plugin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,55 @@ describe('ColocatedTemplateCompiler', function() {
);
});

it('works for re-exported component without a template', async function() {
input.write({
'app-name-here': {
'router.js': '// stuff here',
components: {
'foo.js': `export { default } from 'some-place';`,
},
templates: {
'application.hbs': `{{outlet}}`,
},
},
});

let tree = new ColocatedTemplateCompiler(input.path());

output = createBuilder(tree);
await output.build();

assert.deepStrictEqual(output.read(), {
'app-name-here': {
'router.js': '// stuff here',
components: {
'foo.js': `export { default } from 'some-place';`,
},
templates: {
'application.hbs': '{{outlet}}',
},
},
});

await output.build();

assert.deepStrictEqual(output.changes(), {}, 'NOOP update has no changes');

input.write({
'app-name-here': {
'router.js': '// other stuff here',
},
});

await output.build();

assert.deepStrictEqual(
output.changes(),
{ 'app-name-here/router.js': 'change' },
'has only related changes'
);
});

it('works for typescript component class with template', async function() {
input.write({
'app-name-here': {
Expand Down

0 comments on commit fe901c8

Please sign in to comment.