Open karlhorky opened 8 months ago
Oh, after some searching I just found the following issue:
@bluwy is this related?
I will also post some details over there
You can use it as follows.
const fileName = __NAME__;
await import(`./x/${fileName}.ts`);
This may be related to the implementation of the @rollup/plugin-dynamic-import-vars
plugin.
ref: https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations
Describe the bug
Files which are imported using Vite's dynamic import feature relying on an interpolated value (eg. from the
define
option) are not found after build:main.ts
vite.config.ts
Error message:
The dynamically imported files are resolved in development mode.
Reproduction
https://github.com/karlhorky/vite-dynamic-import-build-missing-files
Steps to reproduce
create-vite
define
valuedefine
value in a dynamic import inmain.ts
vite build
Alternative: clone repo above
System Info
Used Package Manager
pnpm
Logs
No response
Validations