Skip to content

Add javascript_modules setting to import modules on every page - #9148

Open
senid231 wants to merge 3 commits into
activeadmin:masterfrom
senid231:javascript-modules
Open

senid231 wants to merge 3 commits into
activeadmin:masterfrom
senid231:javascript-modules

Conversation

@senid231

@senid231 senid231 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Adds config.javascript_modules, a list of import map specifiers that every Active Admin page imports after the active_admin entry point.

Active Admin pages render only ActiveAdmin.importmap, so a module pinned in the host's config/importmap.rb loads nothing on them, with no error. Today the only way to add a module is to copy _html_head.html.erb, which then misses later fixes to that partial. With this setting, the host pins the module into ActiveAdmin.importmap and appends it to the list. An engine does the same from an initializer that runs after active_admin.importmap. The docs cover both cases.

It is an application setting, because ActiveAdmin.importmap is global too. Settings store their default in a class attribute, so << would change the one shared array. Application#settings gives each application its own copy, and a spec covers that.

Part of #9146. A Cucumber feature checks the default output and the import order.

@codecov

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.11%. Comparing base (e1dad93) to head (82cb611).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #9148   +/-   ##
=======================================
  Coverage   99.11%   99.11%           
=======================================
  Files         139      140    +1     
  Lines        4071     4083   +12     
=======================================
+ Hits         4035     4047   +12     
  Misses         36       36           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Active Admin pages render only ActiveAdmin.importmap and import only its
active_admin entry point, so a module pinned in the host's importmap loads
nothing. Themes and plugins copied _html_head to add their imports.

Co-Authored-By: Clanker
The setting default is one shared array, so appending to it leaked into every later Application.

Co-Authored-By: Clanker

This branch has not been deployed

No deployments
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.

1 participant