Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asset_hash plugin removes relative path specifier, breaking ES modules #2516

Open
marcoms opened this issue Dec 27, 2021 · 5 comments
Open
Labels

Comments

@marcoms
Copy link

marcoms commented Dec 27, 2021

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:

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:

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
@markets
Copy link
Member

markets commented Feb 1, 2022

Hi @marcoms 👋🏼 not sure if this is going to help with your problem or it's even related, but just in case ...

Couple of days ago I raised this issue: #2530. The point is that the current JavaScript minifier (only in v4 branch, in master is already changed to Terser) relies on the Uglifier gem, which doesn't support well ES6 syntax. So maybe your problem is somehow related? This only applies if you are using the :minify_javascript setting of course. The :asset_hash extension is a different one, but since I got some different problems due to Uglifier maybe it's worth a try 🤷

@stale
Copy link

stale bot commented May 4, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 4, 2022
@tdreyno
Copy link
Member

tdreyno commented May 4, 2022

@Stale keep open

@stale stale bot removed the stale label May 4, 2022
@stale
Copy link

stale bot commented Aug 2, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 2, 2022
@tdreyno tdreyno added notstale and removed stale labels Aug 2, 2022
@markets
Copy link
Member

markets commented Jan 19, 2024

Hello @marcoms 👋🏼

Could you please try running your site under current main branch?

 gem "middleman", git: "https://github.com/middleman/middleman.git"

We pushed some fixes in the last months, so maybe this is gone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants