Documentation for dynamic-import-vars seems to be outdated (or wrong)
- Rollup Plugin Name: @rollup/plugin-dynamic-import-vars
- Rollup Plugin Version: 1.4.4
Documentation Is:
- [ ] Missing
- [ ] Needed
- [x] Confusing
- [x] Not Sure?
Please Explain in Detail...
Using Vite, instead of Rollup directly.
The documentation for the dynamic-vars-import seems to claim to import dynamicImportVars from '@rollup/plugin-dynamic-import-vars', though after checking the package internally, it seems that you need to import dynamicImportVariables as this is the default export of the index.ts
I also have the problem that even then, I have to refer to the default property of the import and invoke this one. Maybe a related or different issue.
I could work around it like that:
import dynamicImportVariables from '@rollup/plugin-dynamic-import-vars';
/** @type {import('vite').UserConfig} */
const config = {
plugins: [dynamicImportVariables.default()]
};
export default config;
Your Proposal for Changes
Either fix the documentation or the package.
Hi!
In general, default exports don't have fixed names. When importing such a default export in your code, you can choose any name you want. So nothing needs to be fixed in the docs in my eyes.
For the problem needing calling default(), see for example https://stackoverflow.com/questions/70824882/vitepluginstring-is-not-a-function
you can choose any name you want.
But I cant. The code doesnt work and throws an error if I use anything else but dynamicImportVariables. Maybe I am confused about the docs, but if I am, its a sign that the documentation is unclear.
Your stackoverflow answer you posted has a comment which criticizes the exact same problem. The documentation doesnt state the usage of a default() function anywhere. Actually the answer just repeats what I just described...
This is definitely a problem that needs to be fixed in either way.
PS: The stackoverflow question only proves to me that other people have the same problem and that it needs to be fixed.
you can choose any name you want.
But I cant. The code doesnt work and throws an error if I use anything else but
dynamicImportVariables. Maybe I am confused about the docs, but if I am, its a sign that the documentation is unclear.
Strange, never had a problem like that before. What error do you get exactly? (You still need to call "default()" of course...)
Your stackoverflow answer you posted has a comment which criticizes the exact same problem. The documentation doesnt state the usage of a
default()function anywhere. Actually the answer just repeats what I just described...This is definitely a problem that needs to be fixed in either way.
PS: The stackoverflow question only proves to me that other people have the same problem and that it needs to be fixed.
Yeah sorry that's what I meant to say. It's a known problem, but it IS indeed broken and needs to be fixed.
Hey folks. This issue hasn't received any traction for 60 days, so we're going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we'll consider reopening it. ⓘ