Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support engine resolution in scoped packages #330

Merged
merged 1 commit into from Feb 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 9 additions & 8 deletions addon/resolvers/classic/index.js
Expand Up @@ -45,17 +45,18 @@ function parseName(fullName) {
let prefix, type, name;
let fullNameParts = fullName.split('@');

// HTMLBars uses helper:@content-helper which collides
// with ember-cli namespace detection.
// This will be removed in a future release of HTMLBars.
if (fullName !== 'helper:@content-helper' &&
fullNameParts.length === 2) {
if (fullNameParts.length === 2) {
let prefixParts = fullNameParts[0].split(':');

if (prefixParts.length === 2) {
prefix = prefixParts[1];
type = prefixParts[0];
name = fullNameParts[1];
if (prefixParts[1].length === 0) {
type = prefixParts[0];
name = `@${fullNameParts[1]}`;
} else {
prefix = prefixParts[1];
type = prefixParts[0];
name = fullNameParts[1];
}
} else {
let nameParts = fullNameParts[1].split(':');

Expand Down
16 changes: 16 additions & 0 deletions tests/unit/resolvers/classic/basic-test.js
Expand Up @@ -206,6 +206,22 @@ test('can lookup an engine', function(assert) {
assert.equal(engine, expected, 'default export was returned');
});

test('can lookup an engine from a scoped package', function(assert) {
assert.expect(3);

let expected = {};
define('@some-scope/some-module/engine', [], function(){
assert.ok(true, "engine was invoked properly");

return { default: expected };
});

var engine = resolver.resolve('engine:@some-scope/some-module');

assert.ok(engine, 'engine was returned');
assert.equal(engine, expected, 'default export was returned');
});

test('can lookup a route-map', function(assert) {
assert.expect(3);

Expand Down