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'm building a plugin (say with a name plugin-name), which intercepts imports of a virtual module and creates it dynamically (with resolveId and load hooks). The problem I am having is how to declare types for the virtual module or rather how to include them in my package.
So let's say I have a declaration of a virtual module:
The problem is, how to package this. I compile my code with Rollup with typescript plugin, but it gives me errors saying it cannot find the module plugin-name/types, where the definition of Graph lies in. This is intuitive as this module does not yet exist (the bundling creates this module). Similar exception occurs if I rewrite that import into a relative one - "Import or export declaration in an ambient module declaration cannot reference module through relative module name.".
Obviously one solution would be to let the user of the plugin define such declaration of manually include it in my dist/ folder. But I consider these a hacks since this declaration is part of my package and therefore should be bundled as such.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi everybody,
I'm building a plugin (say with a name
plugin-name
), which intercepts imports of a virtual module and creates it dynamically (withresolveId
andload
hooks). The problem I am having is how to declare types for the virtual module or rather how to include them in my package.So let's say I have a declaration of a virtual module:
The problem is, how to package this. I compile my code with Rollup with typescript plugin, but it gives me errors saying it cannot find the module
plugin-name/types
, where the definition ofGraph
lies in. This is intuitive as this module does not yet exist (the bundling creates this module). Similar exception occurs if I rewrite that import into a relative one - "Import or export declaration in an ambient module declaration cannot reference module through relative module name.".Obviously one solution would be to let the user of the plugin define such declaration of manually include it in my
dist/
folder. But I consider these a hacks since this declaration is part of my package and therefore should be bundled as such.Do you have any advice on how to resolve this?
Thanks :).
Beta Was this translation helpful? Give feedback.
All reactions