I’m trying to import an in-repo addon in my project. It builds an object and exports it in lib/myaddon/addon/index.js
.
lib/myaddon/index.js
:
var fs = require('fs');
var options = {};
fs.readdirSync('lib/myaddon/options').forEach(function(file) {
var option = require('./options/' + file);
options[option.key] = option.value;
});
var wstream = fs.createWriteStream('lib/myaddon/addon/index.js');
wstream.on('finish', function() {
console.log(' Options file written.')
});
wstream.write('export default JSON.parse(')
wstream.write(JSON.stringify(options));
wstream.write(');');
wstream.end();
module.exports = {
name: 'myaddon',
isDevelopingAddon: function() {
return true;
}
};
/lib/myaddon/addon/index.js
:
export default { /* the object */ }
where it’s imported:
import MyAddon from 'myaddon';
Console output:
loader.js:219 Uncaught Error: Could not find module 'myaddon' imported from 'the-file-using-the-import'
App package.json
:
"ember-addon": {
"paths": [
"lib/myaddon"
]
}
Addon package.json
:
{
"name": "myaddon",
"keywords": [
"ember-addon",
"myaddon"
],
"dependencies": {}
}