Missing Dependencies for chartjs-adapter-moment

Describe the issue in as much detail as possible. Please remove the sections below if the issue is obvious enough and doesn’t require extra details.

Missing Dependencies :
chartjs-adapter-moment
[wp-content/plugins/hivepress/node_modules/chartjs-adapter-moment/dist/chartjs-adapter-moment.min.js]
chartjs (missing), moment

Steps to reproduce

List the steps to reproduce the issue.
-) Install Debugger plugin like query monitor for easier to debug
-) Go to homepage, click the scripts tab in query monitor

Actual result

Describe the actual result.

Expected result

Describe the expected result.

Extra details

Add a link to your site, screenshots or any other details that may help us pinpoint the issue.

Hi,

Please send a screenshot of the plugins you are using. Also, please disable third-party plugins and customizations (if there are any) and check if this issue persists. If you use a caching plugin, make sure that caching is disabled for logged-in users.

This bug still exist since last year. There’s also a screenshot in this post:

Hi,

We checked this issue from our side, and it seems okay. On our end, we couldn’t reproduce the issue, and the error doesn’t show up in the console. Also, please note that we couldn’t confirm this issue last year either, so it’s not a bug for now.

Please provide more details regarding this issue (e.g., your actions step by step with screenshots, screencast, etc.). This will help us to reproduce and resolve the issue faster.

This is obviously a bug.

Just check this file /wp-content/plugins/hivepress/includes/configs/scripts.php (line 69), you will see ‘chartjs’ and ‘chartjs-adapter-moment’ have a different scope, thus it complain chartjs missing on frontned :

	'chartjs'                => [
		'handle' => 'chartjs',
		'src'    => hivepress()->get_url() . '/node_modules/chart.js/dist/chart.min.js',
		'scope'  => [ 'backend' ],
	],

	'chartjs_adapter_moment' => [
		'handle' => 'chartjs-adapter-moment',
		'src'    => hivepress()->get_url() . '/node_modules/chartjs-adapter-moment/dist/chartjs-adapter-moment.min.js',
		'deps'   => [ 'chartjs', 'moment' ],
		'scope'  => [ 'frontend', 'backend' ],
	],

@ihor could you please sometimes do a random check on andrii’s response. I read most of his response is just ignoring user submitted problems/inputs without even doing real checking. :folded_hands:

There is no error in the console. The website still functions, however there is no need to load something when it is not used. As reported in Moments.js Javascript error on all pages except dashboard .

Please install the Query monitor plugin Query Monitor – The developer tools panel for WordPress – WordPress plugin | WordPress.org (must have, can not live without) and it will show you that it is loaded on all pages, the only page where there is no issiue (Moments loaded without CharJS) is in the vendor dashbaord where the gapsh are.

1 Like

This is clearly a bug. I have the same issue, and this is the message of Query monitor on the frontend.

Position Handle Host Source Dependencies Dependents Version
Missing Dependencies chartjs-adapter-moment ###.com wp-content/plugins/hivepress/node_modules/chartjs-adapter-moment/dist/chartjs-adapter-moment.min.js chartjs (missing), moment

While it’s not a solution, apparently moments.js has been deprecated since 2020, and newer/better versions now exist.

Why Is Moment.js Deprecated?

Moment.js was a go-to solution for years because it made working with dates and times straightforward. However, it has some drawbacks that led to its deprecation in 2020:

  1. Large Size:
  • At around 16KB (minified and gzipped), moment.js adds unnecessary weight to projects, slowing down page load times—especially critical for mobile users.
  1. Mutable Design:
  • Moment.js lets you change date objects directly (e.g., moment().add(1, ‘day’) modifies the original object). This can lead to tricky bugs, as changes might ripple through your code unexpectedly.
  1. Confusing API:
  • Some parts of moment.js are inconsistent or hard to use, like its handling of time zones and locales, which can trip up developers.
  1. Better Options Exist:
  • Newer libraries have popped up that solve these problems with smaller, cleaner, and more modern approaches.

The moment.js team recognized these issues and decided to step back, pointing users toward better alternatives.


Recommended Alternatives

Instead of moment.js, the community and the moment.js team recommend these modern libraries:

  1. Luxon:
  • Created by the same folks behind moment.js, Luxon is its spiritual successor.
  • Highlights:
    • Immutable: Functions return new date objects instead of changing existing ones, making your code safer and easier to debug.
    • Great Time Zone Support: Handles complex time zone and locale needs out of the box.
    • Lighter than Moment.js: Still not the smallest, but more efficient.
  • Best For: Projects needing robust date features with time zone handling.
  1. date-fns:
  • A lightweight, modular library with a wide range of date utilities.
  • Highlights:
    • Modular: Import only what you need (e.g., import { format } from ‘date-fns’), keeping your project lean.
    • Immutable: No surprises from changing dates—everything is predictable.
    • Tiny Size: Even smaller than Luxon, perfect for performance-focused apps.
  • Best For: Simple, flexible date tasks without heavy time zone requirements (though it has some time zone support via add-ons).

Other options worth mentioning:

  • Day.js: Super lightweight (around 2KB) and mimics moment.js’s API, making it an easy switch.
  • Native JavaScript (Intl API): For basic formatting or calculations, modern JavaScript’s built-in Intl tools might be enough—no extra library needed.

Why Switch? The Benefits

Moving to these alternatives isn’t just about following trends—it’s practical:

  • Faster Load Times: Smaller libraries mean less code for users to download.
  • Fewer Bugs: Immutable designs (in Luxon and date-fns) reduce errors from accidental changes.
  • Future-Proofing: Active development ensures updates, fixes, and compatibility with new JavaScript features.
  • Simpler Code: Cleaner APIs make development smoother and maintenance easier.

Perhaps something else for the to-do list, @andrii / @ihor

Cheers,
Chris :victory_hand:

Hi,

Thanks for the details. As I clarified in my previous reply, we were unable to reproduce this issue locally. If possible, please send temporary WP access to support@hivepress.io with details for reproducing this issue, and we’ll check it (please send only the link, without login and password). You can create a temporary access link using this plugin Temporary Login Without Password – WordPress plugin | WordPress.org.

You didnt even check the code I mentioned.

In your script ‘chartjs’ only loaded at backend, but ‘chartjs_adapter_moment’ require ‘chartjs’ in the frontend. Thats why there’s this error.

You dont need to reproduce, just read the code I sent you. Even 5 years old will understand this logic.

@ihor HivePress is an incredibly well-designed platform, and it’s clear you’ve put a lot of thoughtful effort into building something exceptional. However, to truly reach its full potential, it needs to be supported by a team that shares your level of commitment and drive. Without that shared dedication, even the best product can struggle to grow.

Thanks for your feedback, we’ll try to improve the quality of technical support.

Regarding the issue, if there’s no JS error in the console and this is just a Query Monitor warning, please ignore it until this is fixed. We set dependencies this way on purpose, this is a bit hacky way to prevent the script from loading without duplicating code.

For example, the Marketplace and Statistics extensions just add scope to the chart script without redefining the script and there’s no need to do this for Moment.js adapter since it already has all the scopes and starts loading because the chart script starts loading on the front end. We’ll try to do this in a more elegant way but this warning message shouldn’t cause any functional issues.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.