Skip to content

[DO NOT MERGE] Spike importmaps - #5790

Draft
andysellick wants to merge 7 commits into
mainfrom
importmaps
Draft

[DO NOT MERGE] Spike importmaps#5790
andysellick wants to merge 7 commits into
mainfrom
importmaps

Conversation

@andysellick

@andysellick andysellick commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

What

Spiking importmaps to try to allow the map component to work with ES modules.

References:

Note: this requires the line <%= javascript_importmap_tags %> to be added to the components gem, specifically in the HEAD of the public layout component, and in the component guide layout template HEAD.

Here's why this is difficult.

  • we can use importmaps to include the map component code as a module, this needs to be excluded from the normal sprockets compilation in assets.rb
  • we then need to do the same for the defra and maplibre dependencies, which the map code needs to import
  • they can't be called directly from node_modules so I created new files that require each of them, and put them into the new place for JS (app/javascript)
  • however at that point defra or maplibre start using their own import x from y commands, which fail because those other things don't exist (maplibre relies on babel, for example)
  • so then we need to add those dependencies into the mix as well, at which point we're manually maintaining an increasingly complex web of things, and dealing with new errors where variable names in these different files clash, for some reason

This isn't working yet, and I think it might be possible to get there, but the effort and maintenance burden is beginning to look a little high.

Why

See #5716

https://gov-uk.atlassian.net/jira/software/c/projects/PNP/boards/1356?selectedIssue=PNP-10149

Visual changes

- should be automatically included in Rails 7+, but seems like it needs to be installed manually
- ran command `bundle add importmap-rails`
- ran command `./bin/rails importmap:install`
- the result is probably wrong for our config, but keeping this in a separate commit for clarity before reconfiguring
- critically it failed to add anything to the application layout file, which we probably need to address in the layout component
@govuk-ci
govuk-ci had a problem deploying to govuk-frontend-app-pr-5790 September 11, 2026 07:26 Failure
@govuk-ci
govuk-ci temporarily deployed to govuk-frontend-app-pr-5790 September 11, 2026 07:27 Inactive
@govuk-ci
govuk-ci temporarily deployed to govuk-frontend-app-pr-5790 September 11, 2026 07:43 Inactive
@govuk-ci
govuk-ci temporarily deployed to govuk-frontend-app-pr-5790 September 11, 2026 08:09 Inactive
@govuk-ci
govuk-ci temporarily deployed to govuk-frontend-app-pr-5790 September 11, 2026 08:41 Inactive
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.

2 participants