openshift / console

OpenShift Cluster Console UI
https://www.openshift.org
Apache License 2.0
401 stars 613 forks source link

bug: exposed methods in @openshift-console/dynamic-plugin-sdk/lib/utils/k8s refer to @console/internal #12255

Open mikaello opened 2 years ago

mikaello commented 2 years ago

When trying to use functions in @openshift-console/dynamic-plugin-sdk/lib/utils/k8s, the build is failing because it tries to resolve @console/internal. Webpack does not find this module, and hence fails.

A minimal setup reproducing the error:

package.json

{
  "name": "console-bug",
  "version": "1.0.0",
  "description": "Reproduction of bug in package @openshift-console/dynamic-plugin-sdk",
  "main": "index.mjs",
  "dependencies": {
    "@openshift-console/dynamic-plugin-sdk": "0.0.21"
  }
}

index.mjs

import { getReference } from "@openshift-console/dynamic-plugin-sdk/lib/utils/k8s";

console.log(getReference({ group: "group", version: "version", kind: "kind" }))

Install and build with esbuild:

$ npm install
$ npx esbuild index.mjs --bundle
✘ [ERROR] Could not resolve "@console/internal/models"

    node_modules/@openshift-console/dynamic-plugin-sdk/lib/utils/k8s/k8s-utils.js:7:29:
      7 │ const staticModels = require('@console/internal/models');

If you remove the offending line, node_modules/@openshift-console/dynamic-plugin-sdk/lib/utils/k8s/k8s-utils.js:7, it works (both Esbuild and Webpack are happy and the utils I am using works).

openshift-bot commented 1 year ago

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot commented 1 year ago

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten /remove-lifecycle stale

mikaello commented 1 year ago

/remove-lifecycle rotten /lifecycle frozen

mikaello commented 2 months ago

This is still, almost two years later, a problem as of the latest version (0.0.21) of @openshift-console/dynamic-plugin-sdk. Is this something you look into?