RanvierMUD / core

Core engine code for Ranvier
https://ranviermud.com
MIT License
45 stars 40 forks source link

using a new datasource (but not through NPM) #114

Open ratacat opened 4 years ago

ratacat commented 4 years ago

I'm having trouble using this sqlite datasource through npm...it isn't exactly clear to me why https://github.com/coderintherye/ranvier-datasource-sqlite

So I thought I would try and and just direct link it in the config..this is lines 27-37 of DataSourceRegistry#load

      // relative path to require
      if (settings.require[0] === '.') {
        loader = require(rootPath + '/' + settings.require);
      } else if (!settings.require.includes('.')) {
        loader = require(settings.require);
      } else {
        const [moduleName, exportName] = settings.require.split('.');
        loader = requireFn(moduleName)[exportName];
      }

      const instance = new loader(sourceConfig, rootPath);

So the first option checks to see if the require starts with a ., and then if it does, it prepends the rootpath + /. So if you input .bundles/mybundle/datasource, it would output /rootpath/.bundles/mybundle/datasource, which in my system wouldn't work. Maybe the . is supposed to be removed?

The second option seems promising though, if there are no dots anywhere...then require. Which if you're giving a filepath would seem likely...except that filepath probably has an extension...like ~/bundles/mybundle/datasource/sqlite-datasource.js. So that doesn't work. And the last one is the NPM. I'm just wondering how this is supposed to work? Am I not understanding it correctly?

Thanks!