OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Export all classes and functions to one namespace like in Lodash

  • Thread starter Thread starter benifest
  • Start date Start date
B

benifest

Guest
In Lodash all function are in the _ namespace. This namespace is located in the window. So we can access the namespace anywhere. Want to achieve the same but facing an issue. I have to export all my classes manually to a namespace and then to the window.

I am using webpack to build the project. In the index.ts file:

Code:
import _Id from './model/general/Id'

namespace n {
    export import Id = _Id.Id
}

globalThis.n = n

Looks not good. How to solve the issue? Maybe there is a package that does the job in npm.

<p>In Lodash all function are in the <code>_</code> namespace. This namespace is located in the <code>window</code>. So we can access the namespace anywhere. Want to achieve the same but facing an issue. I have to export all my classes manually to a namespace and then to the <code>window</code>.</p>
<p>I am using webpack to build the project. In the index.ts file:</p>
<pre><code>import _Id from './model/general/Id'

namespace n {
export import Id = _Id.Id
}

globalThis.n = n
</code></pre>
<p>Looks not good. How to solve the issue? Maybe there is a package that does the job in npm.</p>
 
Top