#2516·middleman

asset_hash plugin removes relative path specifier, breaking ES modules

Author: marcomsCreated Dec 27, 2021Updated Jan 19, 2024
Labelsnotstale

Expected behavior and actual behavior

ES modules don't allow module specifiers that don't have a slash as shown below:

Uncaught TypeError: Failed to resolve module specifier "chunk-3LNNNTUA-fcaa17b4.js". Relative references must start with either "/", "./", or "../".

This comes from my JS bundle which begins with:

javascript
import{a as z,b as se,c as Eo,d as G,e as je,f as ue}from"./chunk-3LNNNTUA.js";

But gets replaced with this by asset_hash:

javascript
import{a as z,b as se,c as Eo,d as G,e as je,f as ue}from"chunk-3LNNNTUA-fcaa17b4.js";

It's important the ./ is preserved as shown by the above error.

Additional information

  • Ruby version: 3.0.0
  • Middleman version: 4.x branch