Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add resolution for dayjs #104

Open
rak-phillip opened this issue Jan 16, 2025 · 1 comment
Open

Add resolution for dayjs #104

rak-phillip opened this issue Jan 16, 2025 · 1 comment

Comments

@rak-phillip
Copy link

rak-phillip commented Jan 16, 2025

It was discovered that the neuvector is using dayjs without explicitly listing it as a dependency during an update to Vue 3.5 (rancher/dashboard#13085). This appeared to be causing issues with the plugin tests, resulting in the following error for neuvector:

-  Building for production as library (umd-min)...
[BABEL] Note: The code generator has deoptimised the styling of /home/runner/work/dashboard/dashboard/manager-ext/pkg/neuvector-ui-ext/types/neuvector.ts as it exceeds the max of 500KB.
 ERROR  Failed to compile with 1 error5:49:49 PM

 error  in utils/common.ts:85:23

TS2694: Namespace 'dayjs' has no exported member 'ManipulateType'.
    83 |   base: string,
    84 |   interval: number,
  > 85 |   intervalUnit: dayjs.ManipulateType,
       |                       ^^^^^^^^^^^^^^
    86 |   pattern = "YYYYMMDDHHmmss"
    87 | ) {
    88 |   // base format: "YYYYMMDDHHmmss"

In order to resolve this issue, neuvector may need to specify a version of dayjs in the resolution property in package.json.

Additional details

It was also noted that the main branch of the neuvector extension repo did not appear to be up to date with latest changes made to the neuvector. In order to properly test integrations with the neuvector extension in the Dashboard extension, this will also need to be updated regularly.

See comment by @aalves08 in rancher/dashboard#13085 (comment)

@rak-phillip
Copy link
Author

It looks like the issue can be resolved with the following patch

diff --git a/pkg/neuvector-ui-ext/utils/common.ts b/pkg/neuvector-ui-ext/utils/common.ts
index 540a8ee..9255e3b 100644
--- a/pkg/neuvector-ui-ext/utils/common.ts
+++ b/pkg/neuvector-ui-ext/utils/common.ts
@@ -82,7 +82,7 @@ export function parseDatetimeStr(datetimeObj: any, pattern?: string) {
 export function getDateByInterval(
   base: string,
   interval: number,
-  intervalUnit: dayjs.ManipulateType,
+  intervalUnit: dayjs.OpUnitType,
   pattern = "YYYYMMDDHHmmss"
 ) {
   // base format: "YYYYMMDDHHmmss"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant