[OpenNMS/opennms] 9a116b: NMS-20150: Fix plugin UI issues (#8772)

Scott Theleman via opennms-cvs <[email protected]>
Newsgroups gmane.network.opennms.cvs
Message-ID <OpenNMS/opennms/push/refs/heads/release-36.x/[email protected]>
  Branch: refs/heads/release-36.x
  Home:   https://github.com/OpenNMS/opennms
  Commit: 9a116b0801e09440005beb6807cb7d5bcb633713
      https://github.com/OpenNMS/opennms/commit/9a116b0801e09440005beb6807cb7d5bcb633713
  Author: Scott Theleman <[email protected]>
  Date:   2026-08-11 (Tue, 11 Aug 2026)

  Changed paths:
    M .circleci/main/jobs/build/build-ui.yml
    M .gitignore
    M ui/eslint.config.js
    M ui/package.json
    M ui/packages/onms-ui-example-plugin/README.md
    M ui/packages/onms-ui-example-plugin/package.json
    A ui/packages/onms-ui-example-plugin/scripts/verify-dist.mjs
    M ui/packages/onms-ui-example-plugin/src/main.ts
    M ui/packages/onms-ui-example-plugin/vite.config.ts
    M ui/packages/onms-ui/README.md
    M ui/pnpm-lock.yaml
    M ui/tests/onms-ui/OnmsTooltip.test.ts
    M ui/tests/onms-ui/exports.test.ts
    M ui/vite.config.menu.ts
    M ui/vite.config.ts

  Log Message:
  -----------
  NMS-20150: Fix plugin UI issues (#8772)

* NMS-20150: Fix plugin UI dev-harness and vite config review items

- Load .env.local (first-wins) in dotenv.config() so plugin dev-harness
  env vars work from .env.local as documented (both vite configs)
- Install the plugin dev middleware after Vite's internal middlewares so
  it sits behind the DNS-rebinding host check; match on req.originalUrl
  because Vite 6's SPA html fallback (which runs before post-hooks)
  rewrites req.url for Accept: */* requests
- Gate the exampleUiExtension middleware on VITE_EXAMPLE_PLUGIN to match
  its route registration in main.ts
- Use fileURLToPath instead of URL#pathname for aliases (pathname
  percent-encodes, breaking checkouts with spaces in the path)
- Give vite.config.menu.ts the same absolute ProductLogo alias fix that
  vite.config.ts already carries
- Add missing AGPL headers to files introduced by NMS-20054

* NMS-20150: Run example plugin as a contract test in CI; extend PrimeVue ban to plugin code

- Add check:example-plugin (typecheck + build of
  @opennms/onms-ui-example-plugin) and run it in the build-ui CI job, so
  the reference plugin fails the build on any @opennms/onms-ui API drift
- Ban ALL primevue imports in plugin sources via no-restricted-imports
  (plugins compile against the host's window globals, which do not
  include PrimeVue)
- State the ban's actual scope in the onms-ui README

* NMS-20150: Example plugin README fixes for external readers

- Note that @opennms/onms-ui is private/unpublished and the dependency
  pinning advice applies only once it is published; document the interim
  (build against the window.OnmsUI runtime contract)
- Correct the dev-harness URL to /#/example-plugin (hash history)
- Remove internal task numbering; point at the actual files wiring the
  dev harness
- Update the stale claim that no repo-root gate reaches this package
  (CI now runs pnpm check:example-plugin)

* NMS-20150: Replace vite-plugin-externals with rollup-plugin-external-globals

vite-plugin-externals last shipped in 2023 and pulled deprecated
transitive deps (sourcemap-codec 1.4, magic-string 0.25, es-module-lexer
0.4, fs-extra 10) into the lockfile — a poor recommendation for the
plugin-developer toolchain the example package documents.

rollup-plugin-external-globals (0.13.0, rollup 4 peer) does the same
import-to-window-global rewrite for ES-module output. Plain rollup
external + output.globals is NOT equivalent here: output.globals only
applies to umd/iife, and plugins must build ES modules for the host's
<script type=module> loader.

Verified in the dev harness: module loads, mounts, and renders against
window.OnmsUI with zero PrimeVue/Vue code bundled (6.3 kB output).

* fix comments

* NMS-20150: Load config env via loadEnv so gates match import.meta.env

The VITE_EXAMPLE_PLUGIN gate (and VITE_APP_LOGO_NAME /
VITE_SERVICENOW_PLUGIN_DIST) read process.env populated by dotenv from
only .env.local/.env, while app code reads import.meta.env which also
includes the mode files (.env.development[.local]). Putting the flag in
a mode file registered the route without the middleware, so the module
request fell through to the SPA fallback and returned index.html.

Switch both vite configs to defineConfig(({ mode }) => ...) with
loadEnv(mode, __dirname, ''), which reads exactly the file set Vite
gives app code; drop the dotenv dependency.

* NMS-20150: Assert the built plugin artifact honors the externals contract

vite build exits 0 even when rollup-plugin-external-globals silently
bails (its transform returns early on a this.parse() failure, or when no
globals key appears as a substring of the code). Since the ids stay
external either way, a bail leaves a bare import in the ES output that
only breaks at runtime in the host browser — the CI gate previously only
proved the build ran.

Add scripts/verify-dist.mjs to the example package: fails if any
externalized id survives as a real import, or if the window.Vue /
window.OnmsUI rewrites are missing. Chain it into check:example-plugin,
document it in the README, and give **/scripts/**/*.mjs Node globals in
the eslint config.

* NMS-20150: Document why the redundant rollupOptions.external is kept

externalGlobals >= 0.13 installs its own resolver that already marks
every id in its map as external, so the explicit list is belt-and-braces:
it states the contract in standard rollup vocabulary and keeps older
plugin versions externalizing correctly.

* NMS-20150: Use primevue/** so the plugin PrimeVue ban crosses path levels

no-restricted-imports patterns are gitignore-style globs where * stops
at /, so primevue/* let deep subpaths like primevue/a/b escape the ban.

* NMS-20150: Declare rollup devDependency in the example plugin package

rollup-plugin-external-globals declares a rollup peerDependency
(^2.25.0 || ^3.3.0 || ^4.1.4) that was only satisfied via the hoisted
transitive dep from vite. This package is a template for external
plugin developers, so declare it explicitly rather than relying on
hoisting/auto-installed peers, which yarn and strict setups don't do.

* NMS-20150: Gitignore ui/*.local Vite env overrides

Both vite configs document .env.local / .env.development.local as the
place for dev-harness flags and machine-local paths, but nothing ignored
them. .env and .env.development stay tracked.

* NMS-20150: Run unit tests before the example-plugin contract check in CI

Surfaces test failures without waiting on the extra plugin
typecheck+build; build:all already ran, so ordering costs nothing.



To unsubscribe from these emails, change your notification settings at https://github.com/OpenNMS/opennms/settings/notifications


_______________________________________________
Please read the OpenNMS Mailing List FAQ:
http://www.opennms.org/wiki/index.php?page=MailingListFaq
opennms-cvs mailing list

To *unsubscribe* or change your subscription options, see the bottom of this page:
https://lists.sourceforge.net/lists/listinfo/opennms-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.