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
Is there a way of conditional importing different kind of files depending on the output bundle, if esm or cjs?
For example, I've done a package that uses class-transformer as peer dependency that uses an unexposed API by importing it directly from dist directory, which is a cjs bundle. The issue arises because class-transformer has both cjs and esm builds, so when you use both class-transformer and my package in a esm bundle, my package will always import class-transformer cjs file but class-transformer will uses internally the esm one when is been used. So we can't share the singleton instance that's created inside of the unexposed API.
It can be easily fixed in the webpack config that imports both packages by resolving aliases to a specific class-transformer bundle, the cjs one. But my idea was if maybe in my package I could import the file from dist from a bundle or the other depending on what build target I will be bundling, either esm or cjs.
The text was updated successfully, but these errors were encountered:
Is there a way of conditional importing different kind of files depending on the output bundle, if
esm
orcjs
?For example, I've done a package that uses
class-transformer
as peer dependency that uses an unexposed API by importing it directly from dist directory, which is a cjs bundle. The issue arises becauseclass-transformer
has both cjs and esm builds, so when you use bothclass-transformer
and my package in a esm bundle, my package will always importclass-transformer
cjs file butclass-transformer
will uses internally the esm one when is been used. So we can't share the singleton instance that's created inside of the unexposed API.It can be easily fixed in the webpack config that imports both packages by resolving aliases to a specific
class-transformer
bundle, the cjs one. But my idea was if maybe in my package I could import the file from dist from a bundle or the other depending on what build target I will be bundling, either esm or cjs.The text was updated successfully, but these errors were encountered: