Skip to content

Commit 04df5d5

Browse files
committed
fix: Respect unresolvalbe file types when they don't have a collection.
1 parent 84d8073 commit 04df5d5

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

lib/get-module-specifier.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ module.exports = function (modulePrefix, moduleConfig, modulePath) {
5252
if (parts.length > 0) {
5353
name = parts.pop();
5454
} else {
55+
if (moduleConfig.types[type].unresolvable) {
56+
return null;
57+
}
5558
throw new Error(`The name of module '${modulePath}' could not be identified`);
5659
}
5760
} else {

test/unresolvable-types-test.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
'use strict';
2+
3+
const buildResolutionMap = require('..').buildResolutionMap;
4+
const createTempDir = require('broccoli-test-helper').createTempDir;
5+
const fs = require('fs');
6+
const path = require('path');
7+
const assert = require('assert');
8+
9+
describe('buildResolutionMap', function () {
10+
let configPath = path.join(__dirname, 'fixtures/config/environment.json');
11+
let config = JSON.parse(fs.readFileSync(configPath));
12+
let srcFixture;
13+
14+
beforeEach(function () {
15+
return createTempDir().then(src => {
16+
srcFixture = src;
17+
18+
srcFixture.write({
19+
"src": {
20+
"ui": {
21+
"components": {
22+
"my-app": {
23+
"README.md": "## My-App Component\n",
24+
"component.ts": "",
25+
"page-banner": {
26+
"-utils": {
27+
"ignore-me.ts": ""
28+
},
29+
"component.ts": "",
30+
"ignore-me.d.ts": "",
31+
"template.hbs": "",
32+
"titleize.ts": ""
33+
},
34+
"template.hbs": ""
35+
},
36+
"unresolvable.js": "console.log(1);",
37+
},
38+
"index.html": "<html>\n <head></head>\n <body></body>\n</html>\n"
39+
},
40+
"unresolvable.js": "console.log(1);",
41+
}
42+
});
43+
});
44+
});
45+
46+
afterEach(function () {
47+
srcFixture.dispose();
48+
});
49+
50+
it('never includes unresolvalbe types', function () {
51+
config.moduleConfiguration.types.unresolvable = { unresolvable: true };
52+
config.moduleConfiguration.collections.main.types.push('unresolvable');
53+
config.moduleConfiguration.collections.components.types.push('unresolvable');
54+
55+
let map = buildResolutionMap({
56+
projectDir: srcFixture.path(),
57+
moduleConfig: config.moduleConfiguration,
58+
modulePrefix: config.modulePrefix
59+
});
60+
61+
assert.deepEqual(map, {
62+
'component:/my-app/components/my-app': 'src/ui/components/my-app/component',
63+
'component:/my-app/components/my-app/page-banner': 'src/ui/components/my-app/page-banner/component',
64+
'template:/my-app/components/my-app/page-banner': 'src/ui/components/my-app/page-banner/template',
65+
'component:/my-app/components/my-app/page-banner/titleize': 'src/ui/components/my-app/page-banner/titleize',
66+
'template:/my-app/components/my-app': 'src/ui/components/my-app/template',
67+
})
68+
});
69+
});

0 commit comments

Comments
 (0)