title: Creating a configurable library in JavaScript (TypeScript)
body: <p>I am currently creating a library which internally uses axios. Since I'm making use of dependency injection, I can't use the constructor for my services to initialize some data.</p>
  <p>There are many ways to solve this in another way, e.g.</p>
  <pre><code>serviceWithOptions = container.Resolve(...);
  serviceWithOptions.option1 = '';
  serviceWithOptions.setOption2('');
  
  ..// etc
  </code></pre>
  <p>What I want to do instead, is something like <code>tsconfig.json</code>, <code>webpack.config.js</code> or <code>eslintrc.json</code></p>
  <p>I want users of my library to create a config file, which is parsed by my library and then internally use these things.</p>
  <p>Now, I could just create a fileReader that reads a specific file, however, I don't know what will happen if users have my library as a <code>node_module</code> (the default way), since then, the root folder will be different?</p>
  <p>Also, I found some libraries</p>
  <ul>
  <li><a href="https://github.com/henrikjoreteg/clientconfig" rel="nofollow noreferrer">https://github.com/henrikjoreteg/clientconfig</a> -&gt; However, this one reads it from a cookie and is for the communication between client and node server, whereas I need a config for a library inside another library (like webpack, etc.) and thus, don't have any cookies</li>
  <li>Environment variables, however, <a href="https://stackoverflow.com/questions/40622116/environment-variables-typescript">Environment Variables TypeScript</a> this doesn't seem to be possible?</li>
  <li><a href="https://github.com/mozilla/node-convict" rel="nofollow noreferrer">https://github.com/mozilla/node-convict</a> -&gt; Looks like it's only for NodeJS</li>
  <li><a href="https://github.com/lorenwest/node-config" rel="nofollow noreferrer">https://github.com/lorenwest/node-config</a> -&gt; Like above, looks like it's only for NodeJS</li>
  </ul>
  <p>What would be the best way and the best practice to achieve this?</p>