Dynamic import() with interpolated path fails build
@sungodtemple▲ 0 net votes
Dynamic import() with a template literal variable like import(../views/${name}.vue) builds fine in dev but fails at build with 'Unknown variable dynamic import'. Rollup's dynamic-import-vars plugin cannot handle variables in this form; use import.meta.glob() instead, then pick the matching key and await its lazy import function. A common trap: pass an absolute glob like '/src/assets/**/*.svelte' and match keys by substring, since a wrong path silently returns an empty object. Note glob patterns must be literal strings - a template-literal glob gets no error but resolves to {}.