Skip to content

With the combination of Propshaft and importmap-rails, the app/javascript directory added by importmap-rails cannot be excluded #261

@shrkw

Description

@shrkw

Rails (8.1.1)
propshaft (1.3.1)
importmap-rails (2.2.2)

When Propshaft and importmap-rails are used together, the contents of Rails.application.config.assets look like this. Some entries such as app/javascript are registered as Pathname objects:

blog81b(dev):001> Rails.application.config.assets
=> 
{:paths=>
  ["/workspaces/sandbox-ruby/blog-81b/app/assets/images",
   "/workspaces/sandbox-ruby/blog-81b/app/assets/stylesheets",
   #<Pathname:/workspaces/sandbox-ruby/blog-81b/app/javascript>,
   #<Pathname:/workspaces/sandbox-ruby/blog-81b/vendor/javascript>,
   "/usr/local/lib/ruby/gems/3.3.0/gems/actionview-8.1.1/app/assets/javascripts"],

However, when Propshaft evaluates excluded_paths, they are processed as strings, so any paths registered as Pathname objects cannot be excluded.

app.config.assets.paths = app.config.assets.paths.without(Array(app.config.assets.excluded_paths).collect(&:to_s))

https://github.com/rails/propshaft/blob/main/lib/propshaft/railtie.rb#L31

A straightforward fix would look like this, but would it be acceptable to open a PR like this?

app.config.assets.paths = app.config.assets.paths.without(Array(app.config.assets.excluded_paths).collect(&:to_s))
app.config.assets.paths = app.config.assets.paths.without(Array(app.config.assets.excluded_paths))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions