-
Notifications
You must be signed in to change notification settings - Fork 393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Official vite support? #1246
Comments
Any idea? I'm still facing this blocker right now and cannot use lingui in the app yet 🙁 |
Can you reproduce the issue in https://github.com/skovhus/vite-lingui? If you create a PR against that repository I'm fine with having a look. |
Also related to #1224 |
Thanks, it is a pleasure to see some activity there, I'm gonna try your repo. |
It probably does, and it would be great to avoid that. But note that we still saw huge performance wins migrating from Webpack to Vite for our application. |
Technically, you don't need export default defineConfig({
plugins: [
react({
babel: {
plugins: ['macros'],
},
}),
],
}) That will run on dev and prod, and just once :) Taking your repo as example @skovhus, there is the benchmark: BeforeBenchmark 1: rm -rf dist node_modules/.vite && yarn vite build
Time (mean ± σ): 3.051 s ± 0.401 s [User: 3.133 s, System: 0.371 s]
Range (min … max): 2.460 s … 3.659 s 10 runs AfterBenchmark 1: rm -rf dist node_modules/.vite && yarn vite build
Time (mean ± σ): 2.455 s ± 0.299 s [User: 2.745 s, System: 0.317 s]
Range (min … max): 2.234 s … 3.263 s 10 runs
|
First it works removing the vite-babel-plugin and saying to react plugin to use babel config file. I tried to move the index.html at top-level and then import the app everything with the root unchanged and now looks to works. |
@semoal awesome! I completely overlooked the option of not using I'll just updated the example repository. 👏 |
So now everything work nice in our app too, in order to summarize my issues:
In addition the vite plugin to dynamically compile the catalog is also working fine maybe it could be worth to have a vite documentation page that specify the need of enabling macros in the react babel options and some could use a vite plugin to compile on the fly catalogs. I would love to see an official support there I guess it can be helpful to lot of people specially with the growing vite community. |
Thanks for documenting this, I'm sure it will be helpful for someone else.
Note that I raised this issue here: vitejs/vite#7680 |
I wrote a plugin for vite and more, which can compiles messages on the fly! It contains a demo for vite integration in the playground catalogs, Hope this helps. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
What if we have multiple apps in a monorepo that use multiple lingui configs? |
I wonder if lingui could provide a official support of vite?
I have seen related topic #1016 and even https://github.com/skovhus/vite-lingui but I am facing an issue with vite/esbuild and lingui/babel-macros.
At the end vite/esbuild/rollup work in ESM mode and will convert the macro into ESM renaming the import file and so not detected as a macro anymore.
I have found out that we can tell vite to exclude lingui macro from CommonJs to ESM process with the following:
I did not found a working solution in the other topic yet and I would appreciate some help here and even if possible an official support of vite 🙂
In addition:
vite.config.js
linguiVitePlugin.js
The text was updated successfully, but these errors were encountered: