vite-plugin-moment-timezone is a Vite plugin designed to optimize bundle size by selectively stripping unneeded time zone data from the `moment-timezone` library during the build phase. This is particularly useful for applications that only require a subset of time zones or a specific date range, as `moment-timezone` can be quite large. The current stable version is 0.0.4. Given its low version number and explicit mention of "extremely limited testing" and being "new," it does not yet have a predictable release cadence and should be used with caution, thoroughly testing builds before deployment. Its key differentiator is providing build-time tree-shaking for `moment-timezone` data within a Vite environment, allowing configuration of `zones`, `startYear`, and `endYear` to significantly reduce the final JavaScript bundle size compared to including all available `moment-timezone` data.
npm install vite-plugin-moment-timezoneVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to install and configure the plugin in a Vite project to include specific time zones and year ranges.
Thoroughly test your application's build output and runtime behavior in various environments before deploying to production.
Always test your final production build artifact to ensure `moment-timezone` data is correctly stripped and your application functions as expected.
Ensure your project uses Node.js 20, Vite 5, and `moment-timezone` v0.5.0+ to maintain compatibility with the tested environment.
Run `npm install moment-timezone` or `yarn add moment-timezone` in your project.
Verify that `import momentTimezonePlugin from 'vite-plugin-moment-timezone';` is present and the plugin is added to the `plugins` array, e.g., `plugins: [momentTimezonePlugin({ ... })]`.