Skip to content

Conversation

Copy link

Copilot AI commented Jan 28, 2026

CSS module class names generated by esbuild didn't match Ruby's expectations when using bun. The hash component of class names (e.g., base_0877ac8e_...) differed because Go calculated hashes from file system paths while Ruby used URL paths, and bun installs gems in different locations than traditional bundler.

Changes

Unified hash calculation on URL paths:

  • Ruby: Changed from Utils.css_module_digest(abs_path) to Utils.css_module_digest(url_path) where url_path is /node_modules/@rubygems/gem/file.module.css
  • Go: Changed from ast.CssLocalHash(args.Path) to ast.CssLocalHash(urlPath) where urlPath follows same format

Aligned path suffix transformation:

  • Ruby now matches esbuild's CssLocalAppendice: @_, /-, .-
  • Both sides now produce identical suffixes like node_modules-_rubygems-gem-file-module

Added hash replacement for direct imports:

  • Go plugin now replaces old file-path-based hashes in CSS content with new URL-path-based hashes for directly imported CSS modules

Example

Before:

# Ruby generates: base_67482c8c_---hue-app-components...
# Go generates:   base_0877ac8e_node_modules-_rubygems-hue-app-components...

After:

# Both generate:  base_<same-hash>_node_modules-_rubygems-hue-app-components...

Known Limitation

Nested CSS module imports (CSS importing other CSS modules) still contain file-path-based hashes in the CSS content itself. This requires updating the esbuild-internal fork to use URL paths throughout its CSS processing pipeline. Direct imports from JavaScript are fully fixed.

Original prompt

This section details on the original issue you should resolve

<issue_title>CSS module digest and path incorrect with bun</issue_title>
<issue_description>When using the bun package manager, the resulting CSS module class names do not match those used in Ruby code.

This is in the CSS file:

.base_0877ac8e_node_modules-_rubygems-hue-app-components-icon-component-module # css file

Vs what is in the ruby code:

.base_67482c8c_---hue-app-components-icon-component-module # ruby

Not yet sure which one is correct/incorrect.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits January 28, 2026 20:36
…tem path

Co-authored-by: joelmoss <4614+joelmoss@users.noreply.github.com>
… / -> -)

Co-authored-by: joelmoss <4614+joelmoss@users.noreply.github.com>
Co-authored-by: joelmoss <4614+joelmoss@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix CSS module digest and path issues with bun Fix CSS module digest calculation to use URL paths consistently Jan 28, 2026
Copilot AI requested a review from joelmoss January 28, 2026 20:52
@joelmoss joelmoss closed this Jan 28, 2026
@joelmoss joelmoss deleted the copilot/fix-css-module-paths branch January 29, 2026 17:44
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.

CSS module digest and path incorrect with bun

2 participants