Registry / devops / vite-plugin-moment-timezone

vite-plugin-moment-timezone

JSON →
library0.0.4jsnpmunverified

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-timezone
INSTALL
IMPORT
SIG · VITE-PLUGIN-MOMENT
V
vite-plugin-moment-timezone
devopsjavascriptv0.0.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

momentTimezonePlugin
import momentTimezonePlugin from 'vite-plugin-moment-timezone';
const momentTimezonePlugin = require('vite-plugin-moment-timezone');
This plugin is designed for ESM environments like Vite and typically imported as a default export.
UserConfig
import { defineConfig, type UserConfig } from 'vite';
While not directly from this package, `UserConfig` is a common type import when configuring Vite plugins with TypeScript.

Demonstrates how to install and configure the plugin in a Vite project to include specific time zones and year ranges.

import { defineConfig } from 'vite'; import momentTimezonePlugin from 'vite-plugin-moment-timezone'; export default defineConfig({ plugins: [ momentTimezonePlugin({ zones: ['America/Los_Angeles', 'Europe/London'], startYear: 2020, endYear: 2025 }), ], build: { // Example of a common Vite build setting, not directly related to the plugin but good context minify: 'esbuild', sourcemap: true, }, });
Debug
Known issues
gotchaThe plugin explicitly states "extremely limited testing" and is a new project. Production deployments should proceed with caution and thorough testing.
fix
Thoroughly test your application's build output and runtime behavior in various environments before deploying to production.
affects: >=0.0.1
breakingThis plugin only runs during the build phase. Any `moment-timezone` data manipulation or loading behavior observed in development mode might differ from the production build.
fix
Always test your final production build artifact to ensure `moment-timezone` data is correctly stripped and your application functions as expected.
affects: >=0.0.1
breakingThe plugin has only been tested with Node.js 20, Vite 5, and moment-timezone v0.5.0 or higher. Using older or significantly newer versions of these dependencies may lead to unexpected behavior or build failures.
fix
Ensure your project uses Node.js 20, Vite 5, and `moment-timezone` v0.5.0+ to maintain compatibility with the tested environment.
affects: >=0.0.1
Errors
Common errors & fixes
Error: Cannot find module 'moment-timezone'
The `moment-timezone` package is a peer dependency and must be installed separately.
fix
Run `npm install moment-timezone` or `yarn add moment-timezone` in your project.
TypeError: Cannot read properties of undefined (reading 'plugins')
The `momentTimezonePlugin` was not correctly imported or included in the `plugins` array in `vite.config.js`.
fix
Verify that `import momentTimezonePlugin from 'vite-plugin-moment-timezone';` is present and the plugin is added to the `plugins` array, e.g., `plugins: [momentTimezonePlugin({ ... })]`.
Upgrade
Version history
0.0.4latest on npm
Audit
Dependencies
moment-timezonerequiredThis is a peer dependency that the plugin modifies and optimizes. It must be installed separately in the project.
Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
1
Resources
vite-plugin-moment-timezone — npm install vite-plugin-moment-timezone · libregistry