{"id":15492,"library":"vite-plugin-moment-timezone","title":"Vite Plugin for Moment Timezone Data Optimization","description":"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.","status":"active","version":"0.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/cbetori/vite-plugin-moment-timezone","tags":["javascript","vite","vite plugin","vitejs","vitejs plugin","vite-plugin","moment","moment-timezone","timezone","typescript"],"install":[{"cmd":"npm install vite-plugin-moment-timezone","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-moment-timezone","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-moment-timezone","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This is a peer dependency that the plugin modifies and optimizes. It must be installed separately in the project.","package":"moment-timezone","optional":false}],"imports":[{"note":"This plugin is designed for ESM environments like Vite and typically imported as a default export.","wrong":"const momentTimezonePlugin = require('vite-plugin-moment-timezone');","symbol":"momentTimezonePlugin","correct":"import momentTimezonePlugin from 'vite-plugin-moment-timezone';"},{"note":"While not directly from this package, `UserConfig` is a common type import when configuring Vite plugins with TypeScript.","symbol":"UserConfig","correct":"import { defineConfig, type UserConfig } from 'vite';"}],"quickstart":{"code":"import { defineConfig } from 'vite';\nimport momentTimezonePlugin from 'vite-plugin-moment-timezone';\n\nexport default defineConfig({\n  plugins: [\n    momentTimezonePlugin({\n      zones: ['America/Los_Angeles', 'Europe/London'],\n      startYear: 2020,\n      endYear: 2025\n    }),\n  ],\n  build: {\n    // Example of a common Vite build setting, not directly related to the plugin but good context\n    minify: 'esbuild',\n    sourcemap: true,\n  },\n});","lang":"javascript","description":"Demonstrates how to install and configure the plugin in a Vite project to include specific time zones and year ranges."},"warnings":[{"fix":"Thoroughly test your application's build output and runtime behavior in various environments before deploying to production.","message":"The plugin explicitly states \"extremely limited testing\" and is a new project. Production deployments should proceed with caution and thorough testing.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Always test your final production build artifact to ensure `moment-timezone` data is correctly stripped and your application functions as expected.","message":"This 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.","severity":"breaking","affected_versions":">=0.0.1"},{"fix":"Ensure your project uses Node.js 20, Vite 5, and `moment-timezone` v0.5.0+ to maintain compatibility with the tested environment.","message":"The 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.","severity":"breaking","affected_versions":">=0.0.1"}],"env_vars":null,"search_vec":"'0.0.4':71 'allow':127 'applic':44 'avail':146 'build':37,104,113 'build-tim':112 'bundl':20,140 'cadenc':95 'caution':101 'compar':142 'configur':128 'current':67 'data':6,28,122,150 'date':56 'deploy':106 'design':17 'differenti':109 'endyear':133 'environ':126 'explicit':78 'extrem':81 'final':138 'given':72 'includ':144 'javascript':139,151 'key':108 'larg':65 'librari':34 'limit':82 'low':74 'mention':79 'moment':4,11,32,60,120,148,161,163 'moment-timezon':31,59,119,147,162 'new':86 'number':76 'optim':7,19 'particular':41 'phase':38 'plugin':2,10,16,154,157,160 'predict':93 'provid':111 'quit':64 'rang':57 'reduc':136 'releas':94 'requir':47 'select':23 'shake':117 'signific':135 'size':21,141 'specif':55 'stabl':68 'startyear':131 'strip':24 'subset':49 'test':83,103 'thorough':102 'time':26,51,114 'timezon':5,12,33,61,121,149,164,165 'tree':116 'tree-shak':115 'typescript':166 'unneed':25 'use':42,99 'version':69,75 'vite':1,9,15,125,152,153,159 'vite-plugin':158 'vite-plugin-moment-timezon':8 'vitej':155,156 'within':123 'yet':90 'zone':27,52,130","created_at":"2026-04-21T05:53:52.815091+00:00","updated_at":"2026-04-21T05:53:52.815091+00:00","problems":[{"fix":"Run `npm install moment-timezone` or `yarn add moment-timezone` in your project.","cause":"The `moment-timezone` package is a peer dependency and must be installed separately.","error":"Error: Cannot find module 'moment-timezone'"},{"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({ ... })]`.","cause":"The `momentTimezonePlugin` was not correctly imported or included in the `plugins` array in `vite.config.js`.","error":"TypeError: Cannot read properties of undefined (reading 'plugins')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/cbetori/vite-plugin-moment-timezone","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/vite-plugin-moment-timezone","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-20","install_tag":null}}