
1 minute read
How Does Vite Works?
It was difficult to deal with the browser support for Es6 modules during the launch of the ES modules in ES2016. Many browsers now frequently offer ES modules in native form to address that problem. It implies that import and export statements can now be defined natively.
In addition, you have complete freedom to directly import inside your HTML file by simply stating that you are importing a module using the type+” module” attribute in your script tag, as shown below:
Advertisement
<script type="module" src="filename.js"> </script>
And if I talk about ViteJS documentation, ES import syntax is served directly to the browser in our source code.
With the help of the native-supported browser is solely responsible for parsing them automatically, making HTTP requests for each import.
On the other hand, the development server typically receives HTTP requests from the browser and executes any necessary code changes. Simply put, it boosts the application speed and makes the Vite server insanely fast.
Why Should You Opt For Vite?
After having a look at how Vite works, it’s time to see the primary reasons for using Vite, a leading front-end build tool.
● Hot Module Replacement (HMR)
● Bare Module Resolving
● On-demand Compilation
● Configuration Option