Open kenlyon opened 8 months ago
Can you provide a minimal reproduction repo?
@yejimeiming Sorry for the delay. Here is a project that I think is the leanest I could make that shows the problem.
npm install
npm run dev
If you proceed to change selection on the drop-down list to attempt to change locales and you can see the console error that it failed to import it.
I should also note that while I thought my initial fix solved the production build, it didn't. It had succeeded in finding all the files but our production environment never managed to load those modules.
So really I have two problems, but we can focus on the one I initially posted first if you like.
In my attached example, the built version will work if you add base: "",
to the vite configuration. That's why it wasn't working for me.
The dev environment continues to be a problem, though.
@yejimeiming Any update here?
Looks es-module-lexer
throw an error. I'm looking for a solution to this issue.
I have some code that dynamically loads the locale for use with the
date-fns
library:I was able to use
vite-plugin-dynamic-import
to get this to work in the build by making the following changes to myvite.config.ts
file:plugins
array:date-fns-
prefix.This works as intended when I perform
vite build
which is great! The problem is that when I try to start the project on my development workstation, it does not work.When I perform
yarn vite
, the output shows my dynamic import followed by this message:I can add a
/* @vite-ignore */
comment to suppress the warning, but the dynamic import does not work.It produces this error:
Is there a way to get
vite-plugin-dynamic-import
to work when usingvite
to run the dev server?