EDIT: Updating the index.js prop from @company/my-addon -> my-addon fixes this issue.
/* eslint-env node */
'use strict';
module.exports = {
name: 'my-addon' // works now
};
Output from ember version --verbose && npm --version && yarn --version:
ember-cli: 2.14.0
http_parser: 2.7.0
node: 6.11.1
v8: 5.1.281.103
uv: 1.11.0
zlib: 1.2.11
ares: 1.10.1-DEV
icu: 58.2
modules: 48
openssl: 1.0.2k
os: darwin x64
5.3.0
0.27.5
Seeing an issue when working with a scoped package addon
package.json name prop = @company/my-addon
index.js name prop = @company/my-addon
directory name = my-addon
So in my addon, when I run a generator to create a new component for example and execute ember cli's default blueprint
ember g component x-foo
the output of the /app namespace export will be export { default } from 'my-addon/components/x-foo';, which doesn't actually work and throws a runtime exception if I, for example use {{x-foo}} in any routes template rendered to the screen
<h2 id="title">Welcome to Ember</h2>
{{x-foo thing="test"}}
``bash
ember.debug.js:26513 Error: Could not find modulemy-addon/components/x-fooimported fromdummy/components/x-foo`
at missingModule (loader.js:244)
at findModule (loader.js:255)
at Module.findDeps (loader.js:165)
at findModule (loader.js:259)
at requireModule (loader.js:26)
at Class._extractDefaultExport (index.js:387)
at Class.resolveOther (index.js:108)
at Class.superWrapper [as resolveOther] (ember.debug.js:45374)
at Class.resolve (ember.debug.js:12695)
at resolve (ember.debug.js:10640)
it should output the default blueprint as `export { default } from '@company/my-addon/components/x-foo';` to correctly resolve because that is the modules defined name in `vendor.js`
```js
;define('@company/my-addon/components/x-foo', ['exports', 'ember', '@company/my-addon/templates/components/x-foo'], function (exports, _ember, _xFoo) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _ember.default.Component.extend({
layout: _xFoo.default
});
});
This all happens because this line
https://github.com/ember-cli/ember-cli-legacy-blueprints/blob/master/blueprints/component-addon/index.js#L40
calls this
https://github.com/ember-cli/ember-cli/blob/9a3d7e02f06ee0039d024acdd702bdaaf415f407/lib/models/project.js#L152-L155
which ultimately calls this
https://github.com/ember-cli/ember-cli/blob/v2.14.0/lib/utilities/get-package-base-name.js#L16-L18
which strips off the scoped namespace prefix
Even though the work around is simple, I do not want to encourage folks to be having name in index.js differ from the name in package.json.
This is a bug we should fix.
looks like this may be fixed by https://github.com/ember-cli/ember-cli/pull/8964
Whoops, you are correct @lifeart!
Most helpful comment
Even though the work around is simple, I do not want to encourage folks to be having
nameinindex.jsdiffer from thenameinpackage.json.This is a bug we should fix.