bug: exposed methods in @openshift-console/dynamic-plugin-sdk/lib/utils/k8s refer to @console/internal
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).
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
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
/remove-lifecycle rotten /lifecycle frozen
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?
Hi, sorry for missing this issue.
Console plugin SDK packages are meant for building Console dynamic plugins which are loaded and executed in the Console web application. In other words, these packages are not meant for use in other kinds of projects, i.e. standalone web applications.
Console dynamic plugins must be built with webpack 5+ and must use ConsoleRemotePlugin in their webpack config.
@console/internal is an internal Console package representing code in frontend/public directory. This code is provided via corresponding webpack modules by the Console web application to its plugins.
Building with esbuild does not work because @console/internal is not a regular public npm package. As mentioned above, this is provided by Console to plugins via webpack module registry at runtime.
More importantly, Console treats the whole plugin SDK packages as shared modules, see shared-modules.ts for reference:
'@openshift-console/dynamic-plugin-sdk': { singleton: true, allowFallback: false },
'@openshift-console/dynamic-plugin-sdk-internal': { singleton: true, allowFallback: false },
both the "core" and "internal" SDK package (module) implementation is provided by Console itself.
So I'm not really sure what you're trying to do :confused:
Marking as resolved due to the reply from @vojtechszocs. Feel free to reopen with the command /reopen :)
/close
@logonoff: Closing this issue.
In response to this:
Marking as resolved due to the reply from @vojtechszocs. Feel free to reopen with the command
/reopen:)/close
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.