Dynamically import one single module #12104
Replies: 4 comments 7 replies
-
It looks like this plugin will solve your problem |
Beta Was this translation helpful? Give feedback.
-
This plugin doesn't solve my problem, because it behaves like |
Beta Was this translation helpful? Give feedback.
-
That's because let module
if (dynamicModuleName === 'foo') {
module = await import(`../components/foo.astro`)
} else if (...) {
// ...
} Otherwise there's no way around it as it could break runtime. |
Beta Was this translation helpful? Give feedback.
-
@putnikproj Did you ever find a solution? Experiencing the same issue |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
I am using Astro and storyblok to build a blog application, so the following runs on Node.js. For this purpose I have several files (js modules) that should be loaded when they are used on a specific page, and should not be loaded when they are not used. I am trying to use this snippet:
But in my final bundle I see all the modules that exist in
/src/components
. This is probably due to@rollup/plugin-dynamic-import-vars
, which behavies like this:But my question is: Is it possible to import only one specific file into my final bundle in such a way?
Suggested solution
Maybe there is an existing solution I don't know about?
Alternative
No response
Additional context
No response
Validations
Beta Was this translation helpful? Give feedback.
All reactions