In-repo Addon Not found


#1

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": {}
}

#2

Digging into the loader.js findModule. On the module.exports object, my plugin is not found. That’s obvious from the console error.

I guess my question is, shouldn’t the export of the addon from its index file add it to the list of exports? I don’t see anything special in regards to this looking at other addons.

I decided to try another in-repo addon, but without anything special, just exporting a static object. The issue persists.


#3

OK, this now works. I had to rerun ember serve for it to pick up. I was running ember build to build it.

I’ve asked this question three times in the slack -help channel and I’ve seen this question posed before here. The fact that no one answers these questions is really disappointing.