Skip to content

Fix CheckBoxTree rendering by aliasing react-checkbox-tree to its ESM bundle#9989

Open
dpage wants to merge 1 commit into
pgadmin-org:masterfrom
dpage:fix-9972-checkbox-tree-rendering
Open

Fix CheckBoxTree rendering by aliasing react-checkbox-tree to its ESM bundle#9989
dpage wants to merge 1 commit into
pgadmin-org:masterfrom
dpage:fix-9972-checkbox-tree-rendering

Conversation

@dpage
Copy link
Copy Markdown
Contributor

@dpage dpage commented May 29, 2026

Summary

  • react-checkbox-tree v2 (bumped to ^2.0.1 in fix: Bump runtime and development dependencies #9870) marks the package as "type": "module" while still pointing its require exports condition at a UMD bundle. Babel transforms our import statements to require(), so webpack picks the UMD file and then treats it as ESM (because of "type": "module"). The UMD wrapper's module.exports = factory(...) never runs in that context and the default export is undefined — which is why dialogs that mount CheckBoxTree (Tools → Import/Export Servers and similar) fail with "Element type is invalid".
  • Add a webpack resolve.alias for react-checkbox-tree pointing at the package's ESM bundle (lib/index.esm.js). That file is explicitly exposed by the package's own "./*": "./*" exports passthrough, has a real default export, and is what webpack would have picked if our build didn't down-transform imports to requires.
  • The $ suffix makes it an exact-match alias, so any future subpath imports (e.g. CSS) continue to resolve normally.

Test plan

  • yarn run linter — clean
  • yarn run jest — all 140 suites / 824 tests pass
  • yarn run bundle:dev and yarn run bundle both compile cleanly (only the pre-existing asset-size advisory warnings)
  • Bundle inspection: before the fix, app.bundle.js contained node_modules/react-checkbox-tree/lib/index.js (the UMD wrapper); after the fix, only lib/index.esm.js is bundled and the webpackUniversalModuleDefinition wrapper is gone
  • Manual smoke test: Tools → Import Servers and Tools → Export Servers render their dialogs without the "Element type is invalid" error

Closes #9972

Summary by CodeRabbit

  • Chores
    • Updated webpack configuration to resolve compatibility issues with the react-checkbox-tree dependency by ensuring the correct module bundle is loaded during the build process.

Review Change Stack

react-checkbox-tree v2 marks the package as "type": "module" but its
"require" exports condition still points at a UMD bundle. babel-loader
turns our ESM imports into require() calls, so webpack picks the UMD
file and treats it as ESM (because of "type": "module"). The UMD
wrapper's module.exports = factory(...) never runs in that context, and
the default export ends up undefined - causing CheckBoxTree to render
"Element type is invalid" in dialogs like Import/Export Servers.

Alias react-checkbox-tree to its ESM bundle (lib/index.esm.js, exposed
by the package's own "./*": "./*" exports map) so webpack picks the file
that actually has a default export.

Closes pgadmin-org#9972
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3d7a9277-8805-4587-af65-bbafcb43cf70

📥 Commits

Reviewing files that changed from the base of the PR and between 0d11dbc and ecd242a.

📒 Files selected for processing (1)
  • web/webpack.shim.js

Walkthrough

A webpack alias configuration is added to web/webpack.shim.js that directs react-checkbox-tree module requests to the package's ESM entry file, bypassing resolution issues caused by the package's "type": "module" declaration and broken CommonJS main entry.

Changes

Webpack Alias for react-checkbox-tree

Layer / File(s) Summary
Webpack react-checkbox-tree ESM alias
web/webpack.shim.js
resolveAlias map adds react-checkbox-tree$ pointing to the package's ESM bundle (react-checkbox-tree/lib/index.esm.js) with inline comments explaining the workaround for the package's module type and entry point configuration.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: fixing CheckBoxTree rendering through a webpack alias to react-checkbox-tree's ESM bundle.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@KijongHan
Copy link
Copy Markdown
Contributor

KijongHan commented May 29, 2026

Hey @dpage ! Thanks for looking into this one. It looks like we had the same idea actually, I opened a PR for this last week over in #9973.

Could you please take a look so we can avoid duplicating the review effort? Keen to get your feedback and your help in getting it across the line

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

Successfully merging this pull request may close these issues.

pgAdmin can't render import/export servers menu prompt (Something went wrong)

2 participants