Coder Social home page Coder Social logo

capaj / vite-lingui-poc Goto Github PK

View Code? Open in Web Editor NEW
9.0 6.0 3.0 419 KB

just a sample app showing how to use lingui.js with vite bundler

Home Page: https://capaj.github.io/vite-lingui-poc/

HTML 2.74% CSS 7.37% TypeScript 41.31% JavaScript 48.58%
vite vitejs linguijs i18n reactjs typescript esbuild vite-plugin

vite-lingui-poc's Introduction

Vite + Lingui.js POC

Showcase how to make lingui.js work with Vite. For babel macros to work correctly we need babel transpilation.

Solution proposed in this POC is to use a reactBabelRefreshPlugin which is mostly exact to what the official @vitejs/plugin-react-refresh is, but with a tweak that enables the babel transformation even in production builds. Alternative solution would be to use https://github.com/itsMapleLeaf/vite-plugin-babel-macros together with @vitejs/plugin-react-refresh, but this would be slower, because the code needs to be parsed 2x by Babel instead of just once as it is implemented here in the custom plugin.

To run this on your machine, just install deps and run npm run dev.

Word of caution:

The custom plugin we have is incompatible with a deprecated @babel/polyfill. Not sure why exactly that is, but if you replace it's import with

import 'core-js/stable'
import 'regenerator-runtime/runtime

it works fine even in build time.

vite-lingui-poc's People

Contributors

capaj avatar cztomsik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

vite-lingui-poc's Issues

Any plan?

Hi,

thanks for PoC! ๐ŸŽ‰

It looks like that you've found a solution how to use Lingui.js with Vite.js but it requires small changes in vite plugin for react fast refresh.

Do you plan some PR in Vite.js repo?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.