importmap-rails icon indicating copy to clipboard operation
importmap-rails copied to clipboard

Fix path mangling when .js is a substring e.g. foo.jszip.js

Open pulver opened this issue 1 year ago • 0 comments

The importmap path is incorrect when .js is a substring of the module path.

Reproduction

Add to config/importmap.rb:

pin_all_from 'app/javascript/test', under: 'test'

Add to app/javascript/application.js:

import 'test/foo.jszip'

Create file app/javascript/test/foo.jszip.js with content:

export function asdf() { return 3; }

Run:

$ RAILS_ENV=production bin/rails assets:clobber
$ RAILS_ENV=production bin/rails assets:precompile --trace

Test:

$ RAILS_ENV=production bin/importmap json|grep foo
    "test/foozip": "/assets/test/foo.jszip-2be366e5912d407e15016b08dd7eedbdf5b28865f4d003766b4c47052cab606c.js"

Problem

The "test/foozip" path is incorrect.

It is expected to be "test/foo.jszip".

It appears there is code somewhere that is removing .js from the middle of the path rather than just the end.

pulver avatar Dec 02 '24 19:12 pulver