You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to use aliases in an NPM package. Everything locally works - I register my aliases in code (and not package.json), all is well.
However, then I want to include this library in another project (or publish the library).
I want this other project, which may know nothing about module-alias, to be able to consume my library, both at runtime and using Jest. The parent project should NOT have to know anything about module-alias or the Jest resolver.
Is there any way to use module-alias in this way? Can I use aliases in a package and keep consumers of the package from having to know about how to deal with my library aliases?
The text was updated successfully, but these errors were encountered:
When working in a library, registering your aliases in code is the way to go, see Using within another NPM package.
However I would heavily recommend not exposing those aliases in your public API.
In any case, it will likely not work with Jest, since Jest overrides the default "require" behavior, see Usage with Jest.
Maybe you could look into "bundling" your lib into a single file before distributing it as a lib?
I want to use aliases in an NPM package. Everything locally works - I register my aliases in code (and not package.json), all is well.
However, then I want to include this library in another project (or publish the library).
I want this other project, which may know nothing about module-alias, to be able to consume my library, both at runtime and using Jest. The parent project should NOT have to know anything about module-alias or the Jest resolver.
Is there any way to use module-alias in this way? Can I use aliases in a package and keep consumers of the package from having to know about how to deal with my library aliases?
The text was updated successfully, but these errors were encountered: