Registry / devops / antd-dayjs-webpack-plugin

antd-dayjs-webpack-plugin

JSON →
library1.0.6jsnpmunverified

A webpack plugin that replaces Moment.js with Day.js in Ant Design projects, reducing bundle size from ~65 KB gzipped to ~4 KB. Version 1.0.6 is stable with no recent updates. Key differentiator: single-step integration without manual code changes. Requires dayjs as a peer dependency and supports Ant Design 3.x via 'antdv3' preset, which introduces a mutable Day.js (BadMutable plugin). Commonly used to slim down antd-based React apps.

npm install antd-dayjs-webpack-plugin
INSTALL
IMPORT
SIG · ANTD-DAYJS-WEBPACK
A
antd-dayjs-webpack-plugin
devopsjavascriptv1.0.6
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.

AntdDayjsWebpackPlugin
const AntdDayjsWebpackPlugin = require('antd-dayjs-webpack-plugin');
import AntdDayjsWebpackPlugin from 'antd-dayjs-webpack-plugin';
CommonJS module — default export, cannot use ESM import directly. Works with webpack config files.
default
const AntdDayjsWebpackPlugin = require('antd-dayjs-webpack-plugin').default;
const AntdDayjsWebpackPlugin = require('antd-dayjs-webpack-plugin');
Since v1.0.0, the package changed default export to a named plugin. Using require directly gives the plugin function, not an object with .default. This is the correct way to get the default export if you treat it as ESM.
new AntdDayjsWebpackPlugin()
plugins: [new AntdDayjsWebpackPlugin()]
plugins: [AntdDayjsWebpackPlugin]
Must instantiate the plugin with 'new' — passing the class reference directly will not work.

Shows minimal webpack config to replace Moment.js with Day.js in Ant Design projects, including locale setup.

// webpack.config.js const AntdDayjsWebpackPlugin = require('antd-dayjs-webpack-plugin'); module.exports = { // ... plugins: [ new AntdDayjsWebpackPlugin() ] }; // Install dayjs: npm install dayjs // Import dayjs and set locale in your app entry import dayjs from 'dayjs'; import 'dayjs/locale/zh-cn'; dayjs.locale('zh-cn');
Debug
Known issues
breakingPlugin requires webpack 4+ and Node >=8. Older webpack versions are not supported.
fix
Upgrade webpack to 4+ or use an older version of this plugin.
affects: <1.0.0
deprecatedThe 'replaceMoment' option defaults to true. In future versions, this may be removed or changed.
fix
Set replaceMoment: true explicitly if needed, or rely on default.
affects: >=1.0.0
gotchaUsing 'antdv3' preset enables BadMutable plugin, making Day.js mutable. This can cause unexpected mutations.
fix
Consider upgrading to antd 4+ to avoid using the antdv3 preset. If you must use antd 3, handle Day.js objects as mutable.
affects: >=1.0.0
gotchaThe plugin does not replace moment in node_modules other than antd. Third-party libraries using moment directly will still have moment bundled.
fix
Manually alias moment to dayjs in webpack resolve.alias if needed, but be cautious of API differences.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'antd-dayjs-webpack-plugin'
Missing installation of the plugin.
fix
Run npm install antd-dayjs-webpack-plugin --save-dev
TypeError: AntdDayjsWebpackPlugin is not a constructor
Using default import instead of require in CJS context.
fix
Use const AntdDayjsWebpackPlugin = require('antd-dayjs-webpack-plugin');
Module parse failed: Unexpected token (1:0)
Trying to import the plugin in an ES module file that webpack processes as CJS (e.g., .js file with import statements).
fix
Use require() or ensure your webpack config supports ESM. The package exports a CommonJS module.
Upgrade
Version history
1.0.6latest on npm
Audit
Dependencies
dayjsrequiredPeer dependency — required at runtime for the replacement to work.
Agent activity
20 hits · last 30 days
node
16
OpenAI (training)
1
Resources
antd-dayjs-webpack-plugin — npm install antd-dayjs-webpack-plugin · libregistry