Skip to content

Move version cache buster to path for js#1582

Open
siliconfeces wants to merge 2 commits into
Difegue:devfrom
siliconfeces:path_based_cache_busting
Open

Move version cache buster to path for js#1582
siliconfeces wants to merge 2 commits into
Difegue:devfrom
siliconfeces:path_based_cache_busting

Conversation

@siliconfeces
Copy link
Copy Markdown
Contributor

I wasn't 100% pleased with how importmap-reliant JS imports were, so I changed approach. It also prevented most IDEs from resolving the imports for autocomplete, so that works better now.

Now the version cache-buster is part of the path and doesn't require importmap-entries for "ordinary" non-vendor javascript files. This allows you to do relative imports (like ./server.js instead of mod/server).

A disadvantage is that importing stuff from HTML files is a touch uglier again as you need to build the path each time rather than just once in the importmap.

# Routers used for all loginless routes
my $public_routes = $self->routes;

$public_routes->get( '/js/:version/*filepath' => [ version => qr/\d+\.\d+\.\d+/ ] )->to(
Copy link
Copy Markdown
Contributor

@psilabs-dev psilabs-dev May 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

paths need sanitization

Image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big oof!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mojolicious path class is a bit "special" (never got mergeand contains to do anything useful), but I think I've managed to block that stuff now, albeit a bit heavy-handed.

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